11/* ****************************************************************************
22 *
3- * PROJECT: Multi Theft Auto v1.0
3+ * PROJECT: Multi Theft Auto
44 * LICENSE: See LICENSE in the top level directory
55 * FILE: xml/CXMLImpl.cpp
66 * PURPOSE: XML handler class
@@ -32,11 +32,8 @@ CXMLFile* CXMLImpl::CreateXML(const char* szFilename, bool bUseIDs, bool bReadOn
3232 CXMLFile* xmlFile = new CXMLFileImpl (szFilename, bUseIDs, bReadOnly);
3333 if (xmlFile->IsValid ())
3434 return xmlFile;
35- else
36- {
37- delete xmlFile;
38- return NULL ;
39- }
35+ delete xmlFile;
36+ return nullptr ;
4037}
4138
4239void CXMLImpl::DeleteXML (CXMLFile* pFile)
@@ -46,99 +43,72 @@ void CXMLImpl::DeleteXML(CXMLFile* pFile)
4643
4744CXMLNode* CXMLImpl::ParseString (const char * strXmlContent)
4845{
49- TiXmlElement *xmlDocumentRoot;
50- CXMLNodeImpl *xmlBaseNode;
51- CXMLNode *xmlRootNode;
52-
53- TiXmlDocument* xmlDoc = new TiXmlDocument ();
54-
46+ TiXmlDocument* xmlDoc = new TiXmlDocument ();
5547 if (xmlDoc)
5648 {
5749 if (xmlDoc->Parse (strXmlContent, 0 , TIXML_ENCODING_UTF8))
5850 {
59- xmlDocumentRoot = xmlDoc->RootElement ();
60-
61- xmlBaseNode = new CXMLNodeImpl (NULL , NULL , *xmlDocumentRoot);
62-
63- xmlRootNode = CXMLImpl::BuildNode (xmlBaseNode, xmlDocumentRoot);
64-
51+ TiXmlElement* xmlDocumentRoot = xmlDoc->RootElement ();
52+ CXMLNodeImpl* xmlBaseNode = new CXMLNodeImpl (nullptr , nullptr , *xmlDocumentRoot);
53+ CXMLNode* xmlRootNode = CXMLImpl::BuildNode (xmlBaseNode, xmlDocumentRoot);
6554 return xmlRootNode;
6655 }
67- else
68- return NULL ;
69- }
70- else
71- {
72- return NULL ;
7356 }
57+ return nullptr ;
7458}
7559
7660CXMLNode* CXMLImpl::BuildNode (CXMLNodeImpl* xmlParent, TiXmlNode* xmlNode)
7761{
78- TiXmlNode *xmlChild;
79- TiXmlElement *xmlChildElement;
80- CXMLNodeImpl *xmlChildNode;
81-
82- xmlChild = 0 ;
62+ TiXmlNode* xmlChild = nullptr ;
63+ TiXmlElement* xmlChildElement;
64+ CXMLNodeImpl* xmlChildNode;
8365 while (xmlChild = xmlNode->IterateChildren (xmlChild))
8466 {
8567 xmlChildElement = xmlChild->ToElement ();
86-
87- xmlChildNode = new CXMLNodeImpl (NULL , xmlParent, *xmlChildElement);
88-
68+ xmlChildNode = new CXMLNodeImpl (nullptr , xmlParent, *xmlChildElement);
8969 CXMLImpl::BuildNode (xmlChildNode, xmlChildElement);
9070 }
91-
9271 return xmlParent;
9372}
9473
9574CXMLNode* CXMLImpl::CreateDummyNode ()
9675{
97- CXMLNode* xmlNode = new CXMLNodeImpl (NULL , NULL , *new TiXmlElement (" dummy_storage" ));
76+ CXMLNode* xmlNode = new CXMLNodeImpl (nullptr , nullptr , *new TiXmlElement (" dummy_storage" ));
9877 if (xmlNode->IsValid ())
9978 return xmlNode;
100- else
101- {
102- delete xmlNode;
103- return NULL ;
104- }
79+ delete xmlNode;
80+ return nullptr ;
10581}
10682
10783CXMLAttribute* CXMLImpl::GetAttrFromID (unsigned long ulID)
10884{
10985 // Grab it and verify the type
11086 CXMLCommon* pCommon = CXMLArray::GetEntry (ulID);
11187 if (pCommon && pCommon->GetClassType () == CXML_ATTR)
112- {
11388 return reinterpret_cast <CXMLAttribute*>(pCommon);
114- }
11589
11690 // Doesn't exist or bad type
117- return NULL ;
91+ return nullptr ;
11892}
11993
12094CXMLFile* CXMLImpl::GetFileFromID (unsigned long ulID)
12195{
12296 // Grab it and verify the type
12397 CXMLCommon* pCommon = CXMLArray::GetEntry (ulID);
12498 if (pCommon && pCommon->GetClassType () == CXML_FILE)
125- {
12699 return reinterpret_cast <CXMLFile*>(pCommon);
127- }
128100
129101 // Doesn't exist or bad type
130- return NULL ;
102+ return nullptr ;
131103}
132104
133105CXMLNode* CXMLImpl::GetNodeFromID (unsigned long ulID)
134106{
135107 // Grab it and verify the type
136108 CXMLCommon* pCommon = CXMLArray::GetEntry (ulID);
137109 if (pCommon && pCommon->GetClassType () == CXML_NODE)
138- {
139110 return reinterpret_cast <CXMLNode*>(pCommon);
140- }
141111
142112 // Doesn't exist or bad type
143- return NULL ;
113+ return nullptr ;
144114}
0 commit comments