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 if(lowername.size()>40)
\r
20 lowername.erase(40);
\r
22 m_boards.push_back(board(lowername,description));
\r
26 const std::string BoardListXML::GetDescription(const long index)
\r
28 if(index>=0 && index<GetCount())
\r
30 return m_boards[index].m_description;
\r
38 const std::string BoardListXML::GetName(const long index)
\r
40 if(index>=0 && index<GetCount())
\r
42 return m_boards[index].m_name;
\r
50 std::string BoardListXML::GetXML()
\r
53 TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
\r
57 td.LinkEndChild(tdec);
\r
58 tid=new TiXmlElement("BoardList");
\r
59 td.LinkEndChild(tid);
\r
61 for(std::vector<board>::iterator i=m_boards.begin(); i!=m_boards.end(); i++)
\r
63 std::string boardname=(*i).m_name;
\r
64 StringFunctions::LowerCase(boardname,boardname);
\r
65 TiXmlElement *tr=new TiXmlElement("Board");
\r
66 tid->LinkEndChild(tr);
\r
67 tr->LinkEndChild(XMLCreateCDATAElement("Name",boardname));
\r
68 tr->LinkEndChild(XMLCreateCDATAElement("Description",(*i).m_description));
\r
72 return std::string(tp.CStr());
\r
75 void BoardListXML::Initialize()
\r
80 const bool BoardListXML::ParseXML(const std::string &xml)
\r
83 std::string description;
\r
85 td.Parse(xml.c_str());
\r
90 TiXmlHandle hnd(&td);
\r
95 node=hnd.FirstChild("BoardList").FirstChild("Board").ToElement();
\r
101 TiXmlHandle hnd2(node);
\r
102 txt=hnd2.FirstChild("Name").FirstChild().ToText();
\r
105 name=txt->ValueStr();
\r
106 StringFunctions::LowerCase(name,name);
\r
112 txt=hnd2.FirstChild("Description").FirstChild().ToText();
\r
115 description=txt->ValueStr();
\r
118 if(name!="" && description!="")
\r
120 m_boards.push_back(board(name,description));
\r
123 node=node->NextSibling("Board");
\r