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

verification.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 "crc32.h"
00047 #include "md5.h"
00048 #include "csv.h"
00049 #include "sfv.h"
00050 
00051 #include "verification.h"
00052 
00053 using namespace libsvx;
00054 
00057 Verification::Verification(TiXmlElement & a_Element)
00058  :Element(a_Element,"verification")
00059  ,m_Crc32(NULL)
00060  ,m_Md5(NULL)
00061  ,m_Csv(NULL)
00062  ,m_Sfv(NULL)
00063 {
00064   assert(a_Element.Value().compare("verification") == 0);
00065 
00066   // elements
00067   if (a_Element.FirstChildElement("CRC32") != NULL)
00068   {
00069     m_Crc32 = new Crc32(*a_Element.FirstChildElement("CRC32"));
00070   }
00071 
00072   if (a_Element.FirstChildElement("MD5") != NULL)
00073   {
00074     m_Md5 = new Md5(*a_Element.FirstChildElement("MD5"));
00075   }
00076 
00077   if (a_Element.FirstChildElement("CSV") != NULL)
00078   {
00079     m_Csv = new Csv(*a_Element.FirstChildElement("CSV"));
00080   }
00081 
00082   if (a_Element.FirstChildElement("SFV") != NULL)
00083   {
00084     m_Sfv = new Sfv(*a_Element.FirstChildElement("SFV"));
00085   }
00086 
00087 }
00088 
00089 Verification::Verification(const Verification & a_verification)
00090  :Element(a_verification)
00091  ,m_Crc32(a_verification.m_Crc32)
00092  ,m_Md5(a_verification.m_Md5)
00093  ,m_Csv(a_verification.m_Csv)
00094  ,m_Sfv(a_verification.m_Sfv)
00095 {}
00096 
00100 Verification::~Verification()
00101 {
00102   if (m_Crc32 != NULL)
00103     delete m_Crc32;
00104   if (m_Md5 != NULL)
00105     delete m_Md5;
00106   if (m_Csv != NULL)
00107     delete m_Csv;
00108   if (m_Sfv != NULL)
00109     delete m_Sfv;
00110 }
00111 
00115 bool Verification::IsValid() const
00116 {
00117   return true;
00118 }
00119 
00120 TiXmlElement & Verification::XmlElement()
00121 {
00122   if (m_Crc32 != NULL)
00123     m_Node->InsertEndChild(m_Crc32->XmlElement());
00124 
00125   if (m_Md5 != NULL)
00126     m_Node->InsertEndChild(m_Md5->XmlElement());
00127 
00128   if (m_Csv != NULL)
00129     m_Node->InsertEndChild(m_Csv->XmlElement());
00130 
00131   if (m_Sfv != NULL)
00132     m_Node->InsertEndChild(m_Sfv->XmlElement());
00133 
00134   return *m_Node;
00135 }
00136 
00137 bool Verification::operator!=(const Verification & the_object_to_compare) const
00138 {
00139   bool result = !(IsValid() && the_object_to_compare.IsValid());
00140 
00141   result = result || (static_cast<const Element&>(*this) != the_object_to_compare);
00142   
00143   if (!result)
00144   {
00145     if (m_Crc32 != NULL && the_object_to_compare.m_Crc32 != NULL)
00146       result = result || (*m_Crc32 != *the_object_to_compare.m_Crc32);
00147 
00148     if (m_Md5 != NULL && the_object_to_compare.m_Md5 != NULL)
00149       result = result || (*m_Md5 != *the_object_to_compare.m_Md5);
00150 
00151     if (m_Csv != NULL && the_object_to_compare.m_Csv != NULL)
00152       result = result || (*m_Csv != *the_object_to_compare.m_Csv);
00153 
00154     if (m_Sfv != NULL && the_object_to_compare.m_Sfv != NULL)
00155       result = result || (*m_Sfv != *the_object_to_compare.m_Sfv);
00156     }
00157 
00158   return result;
00159 }

Generated on Tue Apr 9 21:41:11 2002 for libsvx by doxygen1.2.15