-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathXml.cpp
More file actions
69 lines (69 loc) · 1.84 KB
/
Copy pathXml.cpp
File metadata and controls
69 lines (69 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* -*- c++ -*- */
///////////////////////////////////////////
// Json
// -------------------------------------
// file : Json.cpp
// author : Ben Kietzman
// begin : 2011-07-06
// copyright : Ben Kietzman
// email : ben@kietzman.org
///////////////////////////////////////////
/*! \file Json.cpp
* \brief Json Functions
*/
// {{{ includes
#include "Xml"
// }}}
extern "C++"
{
namespace common
{
unsigned long long gullUniqueXml = 0;
// {{{ cleanTicketList()
void xmlCleanTicketList(struct xmlItem &tItem)
{
tItem.strData = "";
if (!tItem.child.empty())
{
for (map<string, struct xmlItem>::iterator i = tItem.child.begin(); i != tItem.child.end(); i++)
{
xmlCleanTicketList(i->second);
}
tItem.child.clear();
}
}
// }}}
// {{{ xmlData()
void xmlData(void *data, const XML_Char *s, int len)
{
struct xmlItem *ptItem = (struct xmlItem *)data;
ptItem->ptCurrent->strData.append(s, len);
}
// }}}
// {{{ xmlEnd()
void xmlEnd(void *data, const char *el)
{
struct xmlItem *ptItem = (struct xmlItem *)data;
ptItem->ptCurrent = ptItem->ptCurrent->ptParent;
}
// }}}
// {{{ xmlStart()
void xmlStart(void *data, const char *el, const char *attr[])
{
struct xmlItem *ptItem = (struct xmlItem *)data;
stringstream ssKey;
if (ptItem->ptCurrent->child.find(el) != ptItem->ptCurrent->child.end())
{
ssKey << setw(32) << setfill('0') << gullUniqueXml++ << "#";
}
ssKey << el;
for (int i = 0; attr[i]; i += 2)
{
ptItem->ptCurrent->child[ssKey.str()].attr[attr[i]] = attr[i+1];
}
ptItem->ptCurrent->child[ssKey.str()].ptParent = ptItem->ptCurrent;
ptItem->ptCurrent = &ptItem->ptCurrent->child[ssKey.str()];
}
// }}}
}
}