Commit d8641f7f authored by cutealien's avatar cutealien

Initialize CXMLReader::IsEmptyElement in constructor.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4080 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b51d8a14
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#ifdef _DEBUG #ifdef _DEBUG
#define IRR_DEBUGPRINT(x) printf((x)); #define IRR_DEBUGPRINT(x) printf((x));
#else // _DEBUG #else // _DEBUG
#define IRR_DEBUGPRINT(x) #define IRR_DEBUGPRINT(x)
#endif // _DEBUG #endif // _DEBUG
...@@ -32,7 +32,7 @@ public: ...@@ -32,7 +32,7 @@ public:
//! Constructor //! Constructor
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true) CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
: TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE), : TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE),
SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII) SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII), IsEmptyElement(false)
{ {
if (!callback) if (!callback)
return; return;
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
// read whole xml file // read whole xml file
readFile(callback); readFile(callback);
// clean up // clean up
if (deleteCallBack) if (deleteCallBack)
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
// set pointer to text begin // set pointer to text begin
P = TextBegin; P = TextBegin;
} }
//! Destructor //! Destructor
virtual ~CXMLReaderImpl() virtual ~CXMLReaderImpl()
...@@ -64,8 +64,8 @@ public: ...@@ -64,8 +64,8 @@ public:
} }
//! Reads forward to the next xml node. //! Reads forward to the next xml node.
//! \return Returns false, if there was no further node. //! \return Returns false, if there was no further node.
virtual bool read() virtual bool read()
{ {
// if not end reached, parse the node // if not end reached, parse the node
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
} }
//! Returns the value of an attribute. //! Returns the value of an attribute.
virtual const char_type* getAttributeValue(int idx) const virtual const char_type* getAttributeValue(int idx) const
{ {
if ((unsigned int)idx >= Attributes.size()) if ((unsigned int)idx >= Attributes.size())
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
} }
//! Returns the value of an attribute. //! Returns the value of an attribute.
virtual const char_type* getAttributeValue(const char_type* name) const virtual const char_type* getAttributeValue(const char_type* name) const
{ {
const SAttribute* attr = getAttributeByName(name); const SAttribute* attr = getAttributeByName(name);
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
//! Returns the value of an attribute as integer. //! Returns the value of an attribute as integer.
int getAttributeValueAsInt(const char_type* name) const int getAttributeValueAsInt(const char_type* name) const
{ {
const SAttribute* attr = getAttributeByName(name); const SAttribute* attr = getAttributeByName(name);
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
} }
//! Returns the value of an attribute as integer. //! Returns the value of an attribute as integer.
int getAttributeValueAsInt(int idx) const int getAttributeValueAsInt(int idx) const
{ {
const char_type* attrvalue = getAttributeValue(idx); const char_type* attrvalue = getAttributeValue(idx);
...@@ -160,7 +160,7 @@ public: ...@@ -160,7 +160,7 @@ public:
} }
//! Returns the value of an attribute as float. //! Returns the value of an attribute as float.
float getAttributeValueAsFloat(const char_type* name) const float getAttributeValueAsFloat(const char_type* name) const
{ {
const SAttribute* attr = getAttributeByName(name); const SAttribute* attr = getAttributeByName(name);
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
} }
//! Returns the value of an attribute as float. //! Returns the value of an attribute as float.
float getAttributeValueAsFloat(int idx) const float getAttributeValueAsFloat(int idx) const
{ {
const char_type* attrvalue = getAttributeValue(idx); const char_type* attrvalue = getAttributeValue(idx);
...@@ -245,14 +245,14 @@ private: ...@@ -245,14 +245,14 @@ private:
switch(*P) switch(*P)
{ {
case L'/': case L'/':
parseClosingXMLElement(); parseClosingXMLElement();
break; break;
case L'?': case L'?':
ignoreDefinition(); ignoreDefinition();
break; break;
case L'!': case L'!':
if (!parseCDATA()) if (!parseCDATA())
parseComment(); parseComment();
break; break;
default: default:
parseOpeningXMLElement(); parseOpeningXMLElement();
...@@ -265,7 +265,7 @@ private: ...@@ -265,7 +265,7 @@ private:
//! sets the state that text was found. Returns true if set should be set //! sets the state that text was found. Returns true if set should be set
bool setText(char_type* start, char_type* end) bool setText(char_type* start, char_type* end)
{ {
// check if text is more than 2 characters, and if not, check if there is // check if text is more than 2 characters, and if not, check if there is
// only white space, so that this text won't be reported // only white space, so that this text won't be reported
if (end - start < 3) if (end - start < 3)
{ {
...@@ -369,7 +369,7 @@ private: ...@@ -369,7 +369,7 @@ private:
// read the attribute value // read the attribute value
// check for quotes and single quotes, thx to murphy // check for quotes and single quotes, thx to murphy
while( (*P != L'\"') && (*P != L'\'') && *P) while( (*P != L'\"') && (*P != L'\'') && *P)
++P; ++P;
if (!*P) // malformatted xml file if (!*P) // malformatted xml file
...@@ -379,7 +379,7 @@ private: ...@@ -379,7 +379,7 @@ private:
++P; ++P;
const char_type* attributeValueBegin = P; const char_type* attributeValueBegin = P;
while(*P != attributeQuoteChar && *P) while(*P != attributeQuoteChar && *P)
++P; ++P;
...@@ -390,10 +390,10 @@ private: ...@@ -390,10 +390,10 @@ private:
++P; ++P;
SAttribute attr; SAttribute attr;
attr.Name = core::string<char_type>(attributeNameBegin, attr.Name = core::string<char_type>(attributeNameBegin,
(int)(attributeNameEnd - attributeNameBegin)); (int)(attributeNameEnd - attributeNameBegin));
core::string<char_type> s(attributeValueBegin, core::string<char_type> s(attributeValueBegin,
(int)(attributeValueEnd - attributeValueBegin)); (int)(attributeValueEnd - attributeValueBegin));
attr.Value = replaceSpecialCharacters(s); attr.Value = replaceSpecialCharacters(s);
...@@ -416,7 +416,7 @@ private: ...@@ -416,7 +416,7 @@ private:
IsEmptyElement = true; IsEmptyElement = true;
endName--; endName--;
} }
NodeName = core::string<char_type>(startName, (int)(endName - startName)); NodeName = core::string<char_type>(startName, (int)(endName - startName));
++P; ++P;
...@@ -465,7 +465,7 @@ private: ...@@ -465,7 +465,7 @@ private:
// find end of CDATA // find end of CDATA
while(*P && !cDataEnd) while(*P && !cDataEnd)
{ {
if (*P == L'>' && if (*P == L'>' &&
(*(P-1) == L']') && (*(P-1) == L']') &&
(*(P-2) == L']')) (*(P-2) == L']'))
{ {
...@@ -548,7 +548,7 @@ private: ...@@ -548,7 +548,7 @@ private:
// find next & // find next &
oldPos = pos; oldPos = pos;
pos = origstr.findNext(L'&', pos); pos = origstr.findNext(L'&', pos);
} }
if (oldPos < (int)origstr.size()-1) if (oldPos < (int)origstr.size()-1)
...@@ -562,7 +562,7 @@ private: ...@@ -562,7 +562,7 @@ private:
//! reads the xml file and converts it into the wanted character format. //! reads the xml file and converts it into the wanted character format.
bool readFile(IFileReadCallBack* callback) bool readFile(IFileReadCallBack* callback)
{ {
long size = callback->getSize(); long size = callback->getSize();
if (size<0) if (size<0)
return false; return false;
size += 4; // We need four terminating 0's at the end. size += 4; // We need four terminating 0's at the end.
...@@ -581,7 +581,7 @@ private: ...@@ -581,7 +581,7 @@ private:
memset(data8+size-4, 0, 4); memset(data8+size-4, 0, 4);
char16* data16 = reinterpret_cast<char16*>(data8); char16* data16 = reinterpret_cast<char16*>(data8);
char32* data32 = reinterpret_cast<char32*>(data8); char32* data32 = reinterpret_cast<char32*>(data8);
// now we need to convert the data to the desired target format // now we need to convert the data to the desired target format
// based on the byte order mark. // based on the byte order mark.
...@@ -593,7 +593,7 @@ private: ...@@ -593,7 +593,7 @@ private:
const u32 UTF32_LE = 0x0000FEFF; const u32 UTF32_LE = 0x0000FEFF;
// check source for all utf versions and convert to target data format // check source for all utf versions and convert to target data format
if (size >= 4 && data32[0] == static_cast<char32>(UTF32_BE)) if (size >= 4 && data32[0] == static_cast<char32>(UTF32_BE))
{ {
// UTF-32, big endian // UTF-32, big endian
...@@ -649,7 +649,7 @@ private: ...@@ -649,7 +649,7 @@ private:
void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader) void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader)
{ {
// convert little to big endian if necessary // convert little to big endian if necessary
if (sizeof(src_char_type) > 1 && if (sizeof(src_char_type) > 1 &&
isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat)) isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat))
convertToLittleEndian(source); convertToLittleEndian(source);
...@@ -663,9 +663,9 @@ private: ...@@ -663,9 +663,9 @@ private:
} }
else else
{ {
// convert source into target data format. // convert source into target data format.
// TODO: implement a real conversion. This one just // TODO: implement a real conversion. This one just
// copies bytes. This is a problem when there are // copies bytes. This is a problem when there are
// unicode symbols using more than one character. // unicode symbols using more than one character.
TextData = new char_type[sizeWithoutHeader]; TextData = new char_type[sizeWithoutHeader];
...@@ -695,7 +695,7 @@ private: ...@@ -695,7 +695,7 @@ private:
template<class src_char_type> template<class src_char_type>
void convertToLittleEndian(src_char_type* t) void convertToLittleEndian(src_char_type* t)
{ {
if (sizeof(src_char_type) == 4) if (sizeof(src_char_type) == 4)
{ {
// 32 bit // 32 bit
...@@ -710,7 +710,7 @@ private: ...@@ -710,7 +710,7 @@ private:
} }
else else
{ {
// 16 bit // 16 bit
while(*t) while(*t)
{ {
...@@ -740,7 +740,7 @@ private: ...@@ -740,7 +740,7 @@ private:
//! generates a list with xml special characters //! generates a list with xml special characters
void createSpecialCharacterList() void createSpecialCharacterList()
{ {
// list of strings containing special symbols, // list of strings containing special symbols,
// the first character is the special character, // the first character is the special character,
// the following is the symbol string without trailing &. // the following is the symbol string without trailing &.
...@@ -749,7 +749,7 @@ private: ...@@ -749,7 +749,7 @@ private:
SpecialCharacters.push_back(">gt;"); SpecialCharacters.push_back(">gt;");
SpecialCharacters.push_back("\"quot;"); SpecialCharacters.push_back("\"quot;");
SpecialCharacters.push_back("'apos;"); SpecialCharacters.push_back("'apos;");
} }
...@@ -775,13 +775,13 @@ private: ...@@ -775,13 +775,13 @@ private:
switch(sizeof(char_type)) switch(sizeof(char_type))
{ {
case 1: case 1:
TargetFormat = ETF_UTF8; TargetFormat = ETF_UTF8;
break; break;
case 2: case 2:
TargetFormat = ETF_UTF16_LE; TargetFormat = ETF_UTF16_LE;
break; break;
case 4: case 4:
TargetFormat = ETF_UTF32_LE; TargetFormat = ETF_UTF32_LE;
break; break;
default: default:
...@@ -809,7 +809,7 @@ private: ...@@ -809,7 +809,7 @@ private:
core::array< core::string<char_type> > SpecialCharacters; // see createSpecialCharacterList() core::array< core::string<char_type> > SpecialCharacters; // see createSpecialCharacterList()
core::array<SAttribute> Attributes; // attributes of current element core::array<SAttribute> Attributes; // attributes of current element
}; // end CXMLReaderImpl }; // end CXMLReaderImpl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment