aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/Device.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-22 09:47:32 +0100
committerMax Kellermann <max@duempel.org>2014-01-22 09:55:51 +0100
commit9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e (patch)
treefb45a43c97fbd145908d46647dc36ef2b0055b21 /src/db/upnp/Device.cxx
parent7b44dea4b1dcfcd74b2648e8be0d6e38918cbe0b (diff)
downloadmpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.tar.gz
mpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.tar.xz
mpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.zip
db/upnp/Device: replace std::vector with a std::string pointer
Diffstat (limited to '')
-rw-r--r--src/db/upnp/Device.cxx71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/db/upnp/Device.cxx b/src/db/upnp/Device.cxx
index 2f39e8829..dd1a8f43c 100644
--- a/src/db/upnp/Device.cxx
+++ b/src/db/upnp/Device.cxx
@@ -33,61 +33,64 @@
*/
class UPnPDeviceParser final : public CommonExpatParser {
UPnPDevice &m_device;
- std::vector<std::string> m_path;
+
+ std::string *value;
+
UPnPService m_tservice;
public:
UPnPDeviceParser(UPnPDevice& device)
- :m_device(device) {}
+ :m_device(device),
+ value(nullptr) {}
protected:
virtual void StartElement(const XML_Char *name, const XML_Char **) {
- m_path.push_back(name);
- }
-
- virtual void EndElement(const XML_Char *name) {
- if (!strcmp(name, "service")) {
- m_device.services.emplace_back(std::move(m_tservice));
- m_tservice.clear();
- }
-
- m_path.pop_back();
- }
-
- virtual void CharacterData(const XML_Char *s, int len) {
- const auto &current = m_path.back();
- std::string str = trimstring(s, len);
- switch (current[0]) {
+ switch (name[0]) {
case 'c':
- if (!current.compare("controlURL"))
- m_tservice.controlURL = std::move(str);
+ if (strcmp(name, "controlURL") == 0)
+ value = &m_tservice.controlURL;
break;
case 'd':
- if (!current.compare("deviceType"))
- m_device.deviceType = std::move(str);
+ if (strcmp(name, "deviceType") == 0)
+ value = &m_device.deviceType;
break;
case 'f':
- if (!current.compare("friendlyName"))
- m_device.friendlyName = std::move(str);
+ if (strcmp(name, "friendlyName") == 0)
+ value = &m_device.friendlyName;
break;
case 'm':
- if (!current.compare("manufacturer"))
- m_device.manufacturer = std::move(str);
- else if (!current.compare("modelName"))
- m_device.modelName = std::move(str);
+ if (strcmp(name, "manufacturer") == 0)
+ value = &m_device.manufacturer;
+ else if (strcmp(name, "modelName") == 0)
+ value = &m_device.modelName;
break;
case 's':
- if (!current.compare("serviceType"))
- m_tservice.serviceType = std::move(str);
+ if (strcmp(name, "serviceType") == 0)
+ value = &m_tservice.serviceType;
break;
case 'U':
- if (!current.compare("UDN"))
- m_device.UDN = std::move(str);
- else if (!current.compare("URLBase"))
- m_device.URLBase = std::move(str);
+ if (strcmp(name, "UDN") == 0)
+ value = &m_device.UDN;
+ else if (strcmp(name, "URLBase") == 0)
+ value = &m_device.URLBase;
break;
}
}
+
+ virtual void EndElement(const XML_Char *name) {
+ if (value != nullptr) {
+ trimstring(*value);
+ value = nullptr;
+ } else if (!strcmp(name, "service")) {
+ m_device.services.emplace_back(std::move(m_tservice));
+ m_tservice.clear();
+ }
+ }
+
+ virtual void CharacterData(const XML_Char *s, int len) {
+ if (value != nullptr)
+ value->append(s, len);
+ }
};
bool