Subversion Repositories tpanel

Rev

Rev 88 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88 Rev 137
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 68... Line 68...
68
            mEncoding = "UTF-8";
68
            mEncoding = "UTF-8";
69
            mSetEncoding = ENC_UTF8;
69
            mSetEncoding = ENC_UTF8;
70
    }
70
    }
71
}
71
}
72
 
72
 
73
bool TExpat::parse()
73
bool TExpat::parse(bool debug)
74
{
74
{
75
    DECL_TRACER("TExpat::parse()");
75
    DECL_TRACER("TExpat::parse()");
76
 
76
 
77
    if (!isValidFile(mFile))
77
    if (!isValidFile(mFile))
78
    {
78
    {
Line 130... Line 130...
130
        TError::setError();
130
        TError::setError();
131
        return false;
131
        return false;
132
    }
132
    }
133
 
133
 
134
    XML_ParserFree(parser);
134
    XML_ParserFree(parser);
135
/*
135
 
136
    if (TStreamError::checkFilter(HLOG_DEBUG))
136
    if (TStreamError::checkFilter(HLOG_DEBUG) && debug && mElements.size() > 0)
137
    {
137
    {
138
        // Print out the whole XML file formatted
138
        // Print out the whole XML file formatted
139
        vector<_ELEMENT_t>::iterator iter;
139
        vector<_ELEMENT_t>::iterator iter;
-
 
140
        size_t cnt = 0;
140
 
141
 
141
        for (iter = mElements.begin(); iter != mElements.end(); ++iter)
142
        for (iter = mElements.begin(); iter != mElements.end(); ++iter)
142
        {
143
        {
143
            string sIndent;
144
            string sIndent;
144
 
145
 
145
            for (int i = 0; i < iter->depth; i++)
146
            for (int i = 0; i < iter->depth; i++)
146
                sIndent += "   ";
147
                sIndent += "   ";
147
 
148
 
148
            if (iter->eType == _ET_START)
149
            string attrs;
-
 
150
 
-
 
151
            if ((iter->eType == _ET_START || iter->eType == _ET_ATOMIC) && iter->attrs.size() > 0)
149
            {
152
            {
150
                string attrs;
153
                vector<ATTRIBUTE_t>::iterator atiter;
151
 
154
 
152
                if (iter->attrs.size() > 0)
155
                for (atiter = iter->attrs.begin(); atiter != iter->attrs.end(); ++atiter)
153
                {
156
                {
-
 
157
                    if (!attrs.empty())
154
                    vector<ATTRIBUTE_t>::iterator atiter;
158
                        attrs += " ";
155
 
159
 
156
                    for (atiter = iter->attrs.begin(); atiter != iter->attrs.end(); ++atiter)
160
                    attrs += atiter->name + " = \"" + atiter->content + "\"";
157
                    {
161
                }
158
                        if (!attrs.empty())
-
 
159
                            attrs += " ";
-
 
160
 
-
 
161
                        attrs += atiter->name + " = \"" + atiter->content + "\"";
-
 
162
                    }
162
            }
163
 
163
 
-
 
164
            if (iter->eType == _ET_START)
-
 
165
            {
-
 
166
                if (iter->attrs.size() > 0)
-
 
167
                {
164
                    MSG_DEBUG("(" << iter->depth << ") " << sIndent << "<" << iter->name << " " << attrs << ">");
168
                    MSG_DEBUG(std::setw(3) << std::setfill(' ') << "[" << cnt << "] (" << std::setw(0) << iter->depth << ") " << sIndent << "<" << iter->name << " " << attrs << ">");
165
                }
169
                }
166
                else
170
                else
167
                {
171
                {
168
                    MSG_DEBUG("(" << iter->depth << ") " << sIndent << "<" << iter->name << ">");
172
                    MSG_DEBUG(std::setw(3) << std::setfill(' ') << "[" << cnt << "] (" << std::setw(0) << iter->depth << ") " << sIndent << "<" << iter->name << ">");
169
                }
173
                }
170
            }
174
            }
171
            else if (iter->eType == _ET_ATOMIC)
175
            else if (iter->eType == _ET_ATOMIC)
172
            {
176
            {
-
 
177
                if (iter->attrs.size() > 0)
-
 
178
                {
-
 
179
                    MSG_DEBUG(std::setw(3) << std::setfill(' ') << "[" << cnt << "] (" << std::setw(0) << iter->depth << ") " << sIndent << "<" << iter->name << " " << attrs << ">" << iter->content << "</" << iter->name << ">");
-
 
180
                }
-
 
181
                else
-
 
182
                {
173
                MSG_DEBUG("(" << iter->depth << ") " << sIndent << "<" << iter->name << ">" << iter->content << "</" << iter->name << ">");
183
                    MSG_DEBUG(std::setw(3) << std::setfill(' ') << "[" << cnt << "] (" << std::setw(0) << iter->depth << ") " << sIndent << "<" << iter->name << ">" << iter->content << "</" << iter->name << ">");
-
 
184
                }
174
            }
185
            }
175
            else
186
            else
176
            {
187
            {
177
                MSG_DEBUG("(" << iter->depth << ") " << sIndent << "</" << iter->name << ">");
188
                MSG_DEBUG(std::setw(3) << std::setfill(' ') << "[" << cnt << "] (" << std::setw(0) << iter->depth << ") " << sIndent << "</" << iter->name << ">");
178
            }
189
            }
-
 
190
 
-
 
191
            cnt++;
179
        }
192
        }
180
    }
193
    }
181
*/
194
 
182
    return true;
195
    return true;
183
}
196
}
184
 
197
 
185
string TExpat::getElement(const string &name, int depth, bool *valid)
198
string TExpat::getElement(const string &name, int depth, bool *valid)
186
{
199
{