Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

element_license.cxx

Go to the documentation of this file.
00001 /******************************************************************************
00002 
00003                            Copyright Notice.
00004 
00005                Licensed material - Property of Steve Lhomme
00006 
00007 This source file is part of Steve Lhomme's libSVX.
00008 (C) Copyright Steve Lhomme, France, 2001-2002.
00009 All rights reserved. Modifications (C) copyrighted by their respective
00010 contributors, all rights reserved.
00011 
00012 The contents of this file are subject to the Bixoft Public License
00013 Version 1.0 (the "License"); you may not use this file in any way except
00014 in compliance with the License. You should have received a copy of the
00015 License with this source; see <file or member name>. You may also obtain
00016 a copy of the License at http://www.bixoft.nl/english/license.htm
00017 or http://mukoli.free.fr/BXAPL/
00018 
00019 ANY USE OF THE SOFTWARE CONSTITUTES ACCEPTANCE OF THE LICENSE.
00020 
00021 Anything distributed under the License is distributed on an "AS IS" basis,
00022 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
00023 the specific language governing rights and limitations under the License.
00024 
00025 Definitions required by the License:
00026 Copyright Holder: Steve Lhomme, France
00027           e-mail: steve.lhomme@free.fr
00028 Country: France, i.e. the laws of France apply.
00029 Court  : ????
00030 Programming Tool status: This source is not a Programming Tool.
00031 
00032 Contributor(s):                      Contribution:
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   //elements
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 /* done automatically
00084   while (m_List_License.size() != 0)
00085   {
00086     License * tmp = m_List_License.front();
00087     m_List_License.pop_front();
00088     delete tmp;
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     // lists
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         // add this license to the list
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         // merge the same license
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 }

Generated on Sat Apr 13 22:56:50 2002 for libsvx by doxygen1.2.15