Switch to unified view

a/libupnpp/control/cdircontent.cxx b/libupnpp/control/cdircontent.cxx
...
...
45
protected:
45
protected:
46
    class StackEl {
46
    class StackEl {
47
    public:
47
    public:
48
        StackEl(const string& nm) : name(nm) {}
48
        StackEl(const string& nm) : name(nm) {}
49
        string name;
49
        string name;
50
        XML_Size sta;
50
        map<string,string> attributes;
51
        map<string,string> attributes;
51
        string data;
52
        string data;
52
    };
53
    };
53
54
54
    virtual void StartElement(const XML_Char *name, const XML_Char **attrs)
55
    virtual void StartElement(const XML_Char *name, const XML_Char **attrs)
55
    {
56
    {
56
        //LOGDEB("startElement: name [" << name << "]" << endl);
57
        //LOGDEB("startElement: name [" << name << "]" << " bpos " <<
58
        //             XML_GetCurrentByteIndex(expat_parser) << endl);
57
59
58
        m_path.push_back(StackEl(name));
60
        m_path.push_back(StackEl(name));
61
        m_path.back().sta = XML_GetCurrentByteIndex(expat_parser);
59
        for (int i = 0; attrs[i] != 0; i += 2) {
62
        for (int i = 0; attrs[i] != 0; i += 2) {
60
            m_path.back().attributes[attrs[i]] = attrs[i+1];
63
            m_path.back().attributes[attrs[i]] = attrs[i+1];
61
        }
64
        }
62
65
63
        switch (name[0]) {
66
        switch (name[0]) {
...
...
118
            parentname = "root";
121
            parentname = "root";
119
        } else {
122
        } else {
120
            parentname = m_path[m_path.size()-2].name;
123
            parentname = m_path[m_path.size()-2].name;
121
        }
124
        }
122
        //LOGDEB("Closing element " << name << " inside element " << 
125
        //LOGDEB("Closing element " << name << " inside element " << 
123
        //    parentname << " data " << m_path.back().data << endl);
126
        //       parentname << " data " << m_path.back().data << endl);
124
        if (!strcmp(name, "container")) {
127
        if (!strcmp(name, "container")) {
125
            if (checkobjok()) {
128
            if (checkobjok()) {
126
                m_dir.m_containers.push_back(m_tobj);
129
                m_dir.m_containers.push_back(m_tobj);
127
            }
130
            }
128
        } else if (!strcmp(name, "item")) {
131
        } else if (!strcmp(name, "item")) {
129
            if (checkobjok()) {
132
            if (checkobjok()) {
133
                unsigned int len = XML_GetCurrentByteIndex(expat_parser) - 
134
                    m_path.back().sta;
135
                m_tobj.m_didlfrag = m_input.substr(m_path.back().sta, len)
136
                    + "</item></DIDL-Lite>";
130
                m_dir.m_items.push_back(m_tobj);
137
                m_dir.m_items.push_back(m_tobj);
131
            }
138
            }
132
        } else if (!parentname.compare("item") || 
139
        } else if (!parentname.compare("item") || 
133
                   !parentname.compare("container")) {
140
                   !parentname.compare("container")) {
134
            switch (name[0]) {
141
            switch (name[0]) {
...
...
177
bool UPnPDirContent::parse(const std::string& input)
184
bool UPnPDirContent::parse(const std::string& input)
178
{
185
{
179
    UPnPDirParser parser(*this, input);
186
    UPnPDirParser parser(*this, input);
180
    return parser.Parse();
187
    return parser.Parse();
181
}
188
}
189
190
static const string didl_header(
191
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
192
"<DIDL-Lite xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\""
193
" xmlns:dc=\"http://purl.org/dc/elements/1.1/\""
194
" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\""
195
" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\">");
196
197
// Maybe we'll do something about building didl from scratch if this
198
// proves necessary.
199
string UPnPDirObject::getdidl()
200
{
201
    return didl_header + m_didlfrag;
202
}