projects
/
fms.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
version 0.3.2
[fms.git]
/
src
/
freenet
/
introductionpuzzlexml.cpp
diff --git
a/src/freenet/introductionpuzzlexml.cpp
b/src/freenet/introductionpuzzlexml.cpp
index
1dea038
..
735ddf9
100644
(file)
--- a/
src/freenet/introductionpuzzlexml.cpp
+++ b/
src/freenet/introductionpuzzlexml.cpp
@@
-11,25
+11,20
@@
IntroductionPuzzleXML::IntroductionPuzzleXML()
\r
std::string IntroductionPuzzleXML::GetXML()
\r
{
\r
\r
std::string IntroductionPuzzleXML::GetXML()
\r
{
\r
- TiXmlDocument td;
\r
- TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
\r
- TiXmlElement *tid;
\r
- TiXmlPrinter tp;
\r
+ Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;
\r
+ Poco::AutoPtr<Poco::XML::Element> root=doc->createElement("IntroductionPuzzle");
\r
\r
\r
- td.LinkEndChild(tdec);
\r
- tid=new TiXmlElement("IntroductionPuzzle");
\r
- td.LinkEndChild(tid);
\r
+ doc->appendChild(root);
\r
\r
\r
-
tid->LinkEndChild(XMLCreateTextElement(
"Type",m_type));
\r
+
root->appendChild(XMLCreateTextElement(doc,
"Type",m_type));
\r
\r
\r
-
tid->LinkEndChild(XMLCreateCDATAElement(
"UUID",m_uuid));
\r
+
root->appendChild(XMLCreateCDATAElement(doc,
"UUID",m_uuid));
\r
\r
\r
-
tid->LinkEndChild(XMLCreateTextElement(
"MimeType",m_mimetype));
\r
+
root->appendChild(XMLCreateTextElement(doc,
"MimeType",m_mimetype));
\r
\r
\r
-
tid->LinkEndChild(XMLCreateTextElement(
"PuzzleData",m_puzzledata));
\r
+
root->appendChild(XMLCreateTextElement(doc,
"PuzzleData",m_puzzledata));
\r
\r
\r
- td.Accept(&tp);
\r
- return std::string(tp.CStr());
\r
+ return GenerateXML(doc);
\r
}
\r
\r
void IntroductionPuzzleXML::Initialize()
\r
}
\r
\r
void IntroductionPuzzleXML::Initialize()
\r
@@
-42,45
+37,55
@@
void IntroductionPuzzleXML::Initialize()
\r
const bool IntroductionPuzzleXML::ParseXML(const std::string &xml)
\r
{
\r
\r
const bool IntroductionPuzzleXML::ParseXML(const std::string &xml)
\r
{
\r
-
TiXmlDocument td
;
\r
-
td.Parse(xml.c_str())
;
\r
+
bool parsed=false
;
\r
+
Poco::XML::DOMParser dp
;
\r
\r
\r
- if(!td.Error())
\r
- {
\r
- TiXmlText *txt;
\r
- TiXmlHandle hnd(&td);
\r
+ Initialize();
\r
\r
\r
- Initialize();
\r
+ try
\r
+ {
\r
+ Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
\r
+ Poco::XML::Element *root=XMLGetFirstChild(doc,"IntroductionPuzzle");
\r
+ Poco::XML::Element *txt=NULL;
\r
\r
\r
- txt=
hnd.FirstChild("IntroductionPuzzle").FirstChild("Type").FirstChild().ToText(
);
\r
+ txt=
XMLGetFirstChild(root,"Type"
);
\r
if(txt)
\r
{
\r
if(txt)
\r
{
\r
- m_type=txt->ValueStr();
\r
+ if(txt->firstChild())
\r
+ {
\r
+ m_type=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
+ }
\r
}
\r
}
\r
-
\r
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("UUID").FirstChild().ToText();
\r
+ txt=XMLGetFirstChild(root,"UUID");
\r
if(txt)
\r
{
\r
if(txt)
\r
{
\r
- m_uuid=txt->ValueStr();
\r
+ if(txt->firstChild())
\r
+ {
\r
+ m_uuid=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
+ }
\r
}
\r
}
\r
-
\r
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("MimeType").FirstChild().ToText();
\r
+ txt=XMLGetFirstChild(root,"MimeType");
\r
if(txt)
\r
{
\r
if(txt)
\r
{
\r
- m_mimetype=txt->ValueStr();
\r
+ if(txt->firstChild())
\r
+ {
\r
+ m_mimetype=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
+ }
\r
}
\r
}
\r
-
\r
- txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("PuzzleData").FirstChild().ToText();
\r
+ txt=XMLGetFirstChild(root,"PuzzleData");
\r
if(txt)
\r
{
\r
if(txt)
\r
{
\r
- m_puzzledata=txt->ValueStr();
\r
+ if(txt->firstChild())
\r
+ {
\r
+ m_puzzledata=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
+ }
\r
}
\r
\r
}
\r
\r
- return true;
\r
-
\r
+ parsed=true;
\r
}
\r
}
\r
- else
\r
+ catch(...)
\r
{
\r
{
\r
- return false;
\r
}
\r
}
\r
+
\r
+ return parsed;
\r
}
\r
}
\r