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

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 "attribute.h"
00047 #include "mirrors.h"
00048 
00049 #include "license.h"
00050 
00051 using namespace libsvx;
00052 
00055 License::License(TiXmlElement & Element)
00056  :ElementText(Element,"license")
00057  ,ElementDownloadable(Element,"license")
00058  ,m_A_type(NULL)
00059  ,m_A_name(NULL)
00060 {
00061   assert(Element.Value().compare("license") == 0);
00062 
00063   // attributes
00064   if (Element.Attribute("type") != NULL)
00065   {
00066     m_A_type = new Attribute(*Element.Attribute("type"),"type");
00067   }
00068 
00069   if (Element.Attribute("name") != NULL)
00070   {
00071     m_A_name = new Attribute(*Element.Attribute("name"),"name");
00072   }
00073 }
00074 
00075 License::License(const License & a_license)
00076  :ElementText(a_license)
00077  ,ElementDownloadable(a_license)
00078 {
00079   if (a_license.m_A_type != NULL)
00080     m_A_type = new Attribute(*a_license.m_A_type);
00081   else
00082     m_A_type = NULL;
00083 
00084   if (a_license.m_A_name != NULL)
00085     m_A_name = new Attribute(*a_license.m_A_name);
00086   else
00087     m_A_name = NULL;
00088 }
00089 
00093 License::~License()
00094 {
00095   if (m_A_type != NULL)
00096     delete m_A_type;
00097   if (m_A_name != NULL)
00098     delete m_A_name;
00099 }
00100 
00104 bool License::IsValid() const
00105 {
00106   return (m_A_type != NULL && m_A_name != NULL && (
00107          m_A_name->String().compare("free-software") == 0 ||
00108          m_A_name->String().compare("osi-approved") == 0 ||
00109          m_A_name->String().compare("freeware") == 0 ||
00110          m_A_name->String().compare("commercial") == 0 ||
00111          m_A_name->String().compare("shareware") == 0 ||
00112          m_A_name->String().compare("adware") == 0 ||
00113          m_A_name->String().compare("cardware") == 0
00114        ));
00115 }
00116 
00117 TiXmlElement & License::XmlElement()
00118 {
00119   TiXmlElement * a_Node = ElementText::m_Node;
00120 
00121   ElementText::XmlElement(*a_Node);
00122 
00123   ElementDownloadable::XmlElement(*a_Node);
00124 
00125   if (m_A_type != NULL)
00126     m_A_type->XmlElement(*a_Node);
00127 
00128   if (m_A_name != NULL)
00129     m_A_name->XmlElement(*a_Node);
00130 
00131   return *a_Node;
00132 }
00133 
00134 bool License::operator!=(const License & the_object_to_compare) const
00135 {
00136   bool result = !(IsValid() && the_object_to_compare.IsValid());
00137 
00138   result = result || (static_cast<const ElementDownloadable&>(*this) != the_object_to_compare);
00139   result = result || (static_cast<const ElementText&>(*this) != the_object_to_compare);
00140   result = result || (m_A_type == NULL && the_object_to_compare.m_A_type != NULL);
00141   result = result || (m_A_type != NULL && the_object_to_compare.m_A_type == NULL);
00142   result = result || (m_A_name == NULL && the_object_to_compare.m_A_name != NULL);
00143   result = result || (m_A_name != NULL && the_object_to_compare.m_A_name == NULL);
00144   
00145   if (!result)
00146   {
00147     if (m_A_type != NULL && the_object_to_compare.m_A_type != NULL)
00148       result = result || (*m_A_type != *the_object_to_compare.m_A_type);
00149 
00150     if (m_A_name != NULL && the_object_to_compare.m_A_name != NULL)
00151       result = result || (*m_A_name != *the_object_to_compare.m_A_name);
00152   }
00153 
00154   return result;
00155 }
00156 
00157 License & License::operator+=(const License & the_object_to_add)
00158 {
00159   assert(IsValid());
00160 
00161   if (the_object_to_add.IsValid())
00162   {
00163     // hierarchy classes
00164     static_cast<ElementText&>(*this) += the_object_to_add;
00165     static_cast<ElementDownloadable&>(*this) += the_object_to_add;
00166 
00167     // attributes
00168     if (the_object_to_add.m_A_type != NULL)
00169     {
00170       if (m_A_type == NULL)
00171       {
00172         delete m_A_type;
00173       }
00174       m_A_type = new Attribute(*the_object_to_add.m_A_type);
00175     }
00176 
00177     if (the_object_to_add.m_A_name != NULL)
00178     {
00179       if (m_A_name == NULL)
00180       {
00181         delete m_A_name; 
00182       }
00183       m_A_name = new Attribute(*the_object_to_add.m_A_name);
00184     }
00185   }
00186 
00187   return *this;
00188 }

Generated on Sat Apr 13 15:45:48 2002 for libsvx by doxygen1.2.15