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 "license.h"
00047 #include "element_license.h"
00048
00049 using namespace libsvx;
00050
00053 ElementLicense::ElementLicense(TiXmlElement & Element, const std::string the_name)
00054 :ElementGeneric(Element,the_name)
00055 {
00056
00057 m_List_License.clear();
00058 TiXmlElement * txIterator = Element.FirstChildElement("license");
00059
00060 while (txIterator != NULL)
00061 {
00062 License * tmpText = new License(*txIterator);
00063 m_List_License.push_back(tmpText);
00064 txIterator = txIterator->NextSiblingElement("license");
00065 }
00066 }
00067
00068 ElementLicense::ElementLicense(const ElementLicense & a_element)
00069 :ElementGeneric(a_element)
00070 {
00071 for (size_t i = 0; i < a_element.m_List_License.size();i++)
00072 {
00073 License * tmpText = new License(a_element.m_List_License[i]);
00074 m_List_License.push_back(tmpText);
00075 }
00076 }
00077
00081 ElementLicense::~ElementLicense()
00082 {
00083
00084
00085
00086
00087
00088
00089
00090
00091 }
00092
00096 bool ElementLicense::IsValid() const
00097 {
00098 return true;
00099 }
00100
00101 void ElementLicense::XmlElement(TiXmlElement & the_element_to_fill)
00102 {
00103 for (size_t i = 0; i < m_List_License.size();i++)
00104 {
00105 the_element_to_fill.InsertEndChild(m_List_License[i].XmlElement());
00106 }
00107 }
00108
00109 ElementLicense & ElementLicense::operator+=(const ElementLicense & the_object_to_add)
00110 {
00111 assert(IsValid());
00112
00113 if (the_object_to_add.IsValid())
00114 {
00115 static_cast<ElementGeneric&>(*this) += the_object_to_add;
00116
00117
00118 size_t i = 0;
00119 License * tmpFoundVersion;
00120 while (i < the_object_to_add.m_List_License.size())
00121 {
00122 tmpFoundVersion = FindLicense(the_object_to_add.m_List_License[i]);
00123 if (tmpFoundVersion == NULL)
00124 {
00125
00126 License * tmpText = new License(the_object_to_add.m_List_License[i]);
00127 m_List_License.push_back(tmpText);
00128 }
00129 else
00130 {
00131
00132 *tmpFoundVersion += the_object_to_add.m_List_License[i];
00133 }
00134
00135 i++;
00136 }
00137 }
00138
00139 return *this;
00140 }
00141
00145 bool ElementLicense::operator!=(const ElementLicense & the_object_to_compare) const
00146 {
00147 bool result = !(IsValid() && the_object_to_compare.IsValid());
00148
00149 result = result || (static_cast<const ElementGeneric&>(*this) != the_object_to_compare);
00150
00151 return result;
00152 }
00153
00154 License * ElementLicense::FindLicense(const License & the_license) const
00155 {
00156 size_t current_version = 0;
00157
00158 while (current_version < m_List_License.size() &&
00159 m_List_License[current_version] != the_license)
00160 {
00161 current_version++;
00162 }
00163
00164 if (current_version < m_List_License.size())
00165 return &m_List_License[current_version];
00166 else
00167 return NULL;
00168 }