00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00044 #include "../tinyxml/tinyxml.h"
00045
00046 #include "text.h"
00047 #include "element_text.h"
00048
00049 using namespace libsvx;
00050
00053 ElementText::ElementText(TiXmlElement & Element, const std::string the_name)
00054 :ElementGeneric(Element,the_name)
00055 {
00056
00057 m_List_Text.clear();
00058 TiXmlElement * txIterator = Element.FirstChildElement("text");
00059
00060 while (txIterator != NULL)
00061 {
00062 Text * tmpText = new Text(*txIterator);
00063 m_List_Text.push_back(tmpText);
00064 txIterator = txIterator->NextSiblingElement("text");
00065 }
00066 }
00067
00068 ElementText::ElementText(const ElementText & a_element)
00069 :ElementGeneric(a_element)
00070 {
00071 for (size_t i = 0; i < a_element.m_List_Text.size();i++)
00072 {
00073 Text * tmpText = new Text(a_element.m_List_Text[i]);
00074 m_List_Text.push_back(tmpText);
00075 }
00076 }
00077
00081 ElementText::~ElementText()
00082 {
00083
00084
00085
00086
00087
00088
00089
00090
00091 }
00092
00096 bool ElementText::IsValid() const
00097 {
00098 return true;
00099 }
00100
00101
00102 void ElementText::XmlElement(TiXmlElement & the_element_to_fill)
00103 {
00104 for (size_t i = 0; i < m_List_Text.size();i++)
00105 {
00106 the_element_to_fill.InsertEndChild(m_List_Text[i].XmlElement());
00107 }
00108 }
00109
00113 Text * ElementText::FindText(const Text & the_item) const
00114 {
00115 size_t current_version = 0;
00116
00117 while (current_version < m_List_Text.size() &&
00118 m_List_Text[current_version] != the_item)
00119 {
00120 current_version++;
00121 }
00122
00123 if (current_version < m_List_Text.size())
00124 return &m_List_Text[current_version];
00125 else
00126 return NULL;
00127 }
00128
00129 ElementText & ElementText::operator+=(const ElementText & the_object_to_add)
00130 {
00131 assert(IsValid());
00132
00133 if (the_object_to_add.IsValid())
00134 {
00135
00136 static_cast<ElementGeneric&>(*this) += the_object_to_add;
00137
00138
00139 size_t i = 0;
00140 Text * tmpFoundText;
00141 while (i < the_object_to_add.m_List_Text.size())
00142 {
00143 tmpFoundText = FindText(the_object_to_add.m_List_Text[i]);
00144 if (tmpFoundText == NULL)
00145 {
00146
00147 Text * tmpText = new Text(the_object_to_add.m_List_Text[i]);
00148 m_List_Text.push_back(tmpText);
00149 }
00150 else
00151 {
00152
00153 *tmpFoundText += the_object_to_add.m_List_Text[i];
00154 }
00155
00156 i++;
00157 }
00158 }
00159
00160 return *this;
00161 }
00165 bool ElementText::operator!=(const ElementText & the_object_to_compare) const
00166 {
00167 bool result = !(IsValid() && the_object_to_compare.IsValid());
00168
00169 result = result || (static_cast<const ElementGeneric&>(*this) != the_object_to_compare);
00170
00171 return result;
00172 }