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 "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
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 }