1 #include "../../include/freenet/boardlistxml.h"
\r
7 BoardListXML::BoardListXML()
\r
12 void BoardListXML::AddBoard(const std::string &name, const std::string &description)
\r
14 if(name!="" && description!="")
\r
16 std::string lowername=name;
\r
17 StringFunctions::LowerCase(lowername,lowername);
\r
18 m_boards.push_back(board(lowername,description));
\r
22 const std::string BoardListXML::GetDescription(const long index)
\r
24 if(index>=0 && index<GetCount())
\r
26 return m_boards[index].m_description;
\r
34 const std::string BoardListXML::GetName(const long index)
\r
36 if(index>=0 && index<GetCount())
\r
38 return m_boards[index].m_name;
\r
46 std::string BoardListXML::GetXML()
\r
49 TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
\r
53 td.LinkEndChild(tdec);
\r
54 tid=new TiXmlElement("BoardList");
\r
55 td.LinkEndChild(tid);
\r
57 for(std::vector<board>::iterator i=m_boards.begin(); i!=m_boards.end(); i++)
\r
59 std::string boardname=(*i).m_name;
\r
60 StringFunctions::Convert(boardname,boardname);
\r
61 TiXmlElement *tr=new TiXmlElement("Board");
\r
62 tid->LinkEndChild(tr);
\r
63 tr->LinkEndChild(XMLCreateCDATAElement("Name",boardname));
\r
64 tr->LinkEndChild(XMLCreateCDATAElement("Description",(*i).m_description));
\r
68 return std::string(tp.CStr());
\r
71 void BoardListXML::Initialize()
\r
76 const bool BoardListXML::ParseXML(const std::string &xml)
\r
79 std::string description;
\r
81 td.Parse(xml.c_str());
\r
86 TiXmlHandle hnd(&td);
\r
91 node=hnd.FirstChild("BoardList").FirstChild("Board").ToElement();
\r
97 TiXmlHandle hnd2(node);
\r
98 txt=hnd2.FirstChild("Name").FirstChild().ToText();
\r
101 name=txt->ValueStr();
\r
102 StringFunctions::LowerCase(name,name);
\r
104 txt=hnd2.FirstChild("Description").FirstChild().ToText();
\r
107 description=txt->ValueStr();
\r
110 if(name!="" && description!="")
\r
112 m_boards.push_back(board(name,description));
\r
115 node=node->NextSibling("Board");
\r