1 // XML.h:structure definitions for SourceSafe files
3 //////////////////////////////////////////////////////////////////////
5 #if !defined(AFX_XML_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_)
6 #define AFX_XML_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_
10 #endif // _MSC_VER > 1000
12 typedef std::map
<std::string
, std::string
> AttribMap
;
14 // ---------------------------------------------------------------
18 static bool isSpecialChar (std::string::value_type v
)
20 std::string punct
= "&<>'\"";
21 std::string::iterator it
= punct
.begin();
23 while(it
!= punct
.end())
31 void ToXml (const T
& element
)
35 void ToXml (const std::string
& element
)
37 if (std::find_if (element
.begin (), element
.end (), isSpecialChar
) == element
.end ())
40 std::cout
<< "<![CDATA[" << element
<< "]]>";
42 void ToXml (const char& element
)
44 if (std::find_if (&element
, &element
+ strlen (&element
), isSpecialChar
) == &element
+ strlen (&element
))
47 std::cout
<< "<![CDATA[" << element
<< "]]>";
52 // ---------------------------------------------------------------
53 class XMLNode
: protected XMLEntity
56 XMLNode (XMLNode
* pParent
, std::string name
)
57 : m_pParent (pParent
), m_Name (name
)
59 std::cout
<< "<" << name
<< ">" << std::endl
;
62 XMLNode (XMLNode
* pParent
, std::string name
, AttribMap attrib
)
63 : m_pParent (pParent
), m_Name (name
)
65 std::cout
<< "<" << name
;
66 AttribMap::iterator itor
= attrib
.begin ();
67 for (; itor
!= attrib
.end (); ++itor
)
69 std::cout
<< " " << itor
->first
<< "=\"" << itor
->second
<< "\"";
71 std::cout
<< ">" << std::endl
;
75 std::cout
<< "</" << m_Name
<< ">" << std::endl
;
84 class XMLElement
: protected XMLEntity
88 XMLElement (XMLNode
* pParent
, std::string name
, const T
& element
)
90 std::cout
<< "<" << name
<< ">";
92 std::cout
<< "</" << name
<< ">" << std::endl
;
96 XMLElement (XMLNode
* pParent
, std::string name
, AttribMap attrib
, const T
& element
)
98 std::cout
<< "<" << name
;
99 AttribMap::iterator itor
= attrib
.begin ();
100 for (; itor
!= attrib
.end (); ++itor
)
102 std::cout
<< " " << itor
->first
<< "=\"" << itor
->second
<< "\"";
106 std::cout
<< "</" << name
<< ">" << std::endl
;
110 class XMLValue
: protected XMLEntity
114 XMLValue (XMLNode
* pParent
, const T
& element
)
121 #endif // !defined(AFX_XML_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_)