diff --git a/source/ps/XeroXMB.cpp b/source/ps/XeroXMB.cpp index f1397566cd..78a50f6335 100755 --- a/source/ps/XeroXMB.cpp +++ b/source/ps/XeroXMB.cpp @@ -1,4 +1,4 @@ -// $Id: XeroXMB.cpp,v 1.6 2004/07/24 14:03:44 philip Exp $ +// $Id: XeroXMB.cpp,v 1.7 2004/10/07 20:49:25 philip Exp $ #include "precompiled.h" @@ -57,7 +57,7 @@ std::string XMBFile::ReadZStrA() return String; } -XMBElement XMBFile::getRoot() +XMBElement XMBFile::getRoot() const { return XMBElement(m_Pointer); } @@ -65,19 +65,19 @@ XMBElement XMBFile::getRoot() #ifdef XERO_USEMAP -int XMBFile::getElementID(const char* Name) +int XMBFile::getElementID(const char* Name) const { return m_ElementNames[Name]; } -int XMBFile::getAttributeID(const char* Name) +int XMBFile::getAttributeID(const char* Name) const { return m_AttributeNames[Name]; } #else // #ifdef XERO_USEMAP -int XMBFile::getElementID(const char* Name) +int XMBFile::getElementID(const char* Name) const { char* Pos = m_ElementPointer; @@ -97,7 +97,7 @@ int XMBFile::getElementID(const char* Name) return -1; } -int XMBFile::getAttributeID(const char* Name) +int XMBFile::getAttributeID(const char* Name) const { char* Pos = m_AttributePointer; @@ -121,7 +121,7 @@ int XMBFile::getAttributeID(const char* Name) // Relatively inefficient, so only use when // laziness overcomes the need for speed -std::string XMBFile::getElementString(const int ID) +std::string XMBFile::getElementString(const int ID) const { char* Pos = m_ElementPointer; for (int i = 0; i < ID; ++i) @@ -129,7 +129,7 @@ std::string XMBFile::getElementString(const int ID) return std::string(Pos+4); } -std::string XMBFile::getAttributeString(const int ID) +std::string XMBFile::getAttributeString(const int ID) const { char* Pos = m_AttributePointer; for (int i = 0; i < ID; ++i) @@ -139,12 +139,12 @@ std::string XMBFile::getAttributeString(const int ID) -int XMBElement::getNodeName() +int XMBElement::getNodeName() const { return *(int*)(m_Pointer + 4); // == ElementName } -XMBElementList XMBElement::getChildNodes() +XMBElementList XMBElement::getChildNodes() const { return XMBElementList( m_Pointer + 20 + *(int*)(m_Pointer + 16), // == Children[] @@ -152,7 +152,7 @@ XMBElementList XMBElement::getChildNodes() ); } -XMBAttributeList XMBElement::getAttributes() +XMBAttributeList XMBElement::getAttributes() const { return XMBAttributeList( m_Pointer + 24 + *(int*)(m_Pointer + 20), // == Attributes[] @@ -160,7 +160,7 @@ XMBAttributeList XMBElement::getAttributes() ); } -utf16string XMBElement::getText() +utf16string XMBElement::getText() const { // Return empty string if there's no text if (*(int*)(m_Pointer + 20) == 0) @@ -169,9 +169,9 @@ utf16string XMBElement::getText() return utf16string((utf16_t*)(m_Pointer + 28)); } -int XMBElement::getLineNumber() +int XMBElement::getLineNumber() const { - // Make sure there actually *was* some text to record the line of + // Make sure there actually was some text to record the line of if (*(int*)(m_Pointer + 20) == 0) return -1; else @@ -204,7 +204,7 @@ XMBElement XMBElementList::item(const int id) return XMBElement(Pos); } -utf16string XMBAttributeList::getNamedItem(const int AttributeName) +utf16string XMBAttributeList::getNamedItem(const int AttributeName) const { char* Pos = m_Pointer; diff --git a/source/ps/XeroXMB.h b/source/ps/XeroXMB.h index 2f0fb3c8f4..63eb23f350 100755 --- a/source/ps/XeroXMB.h +++ b/source/ps/XeroXMB.h @@ -1,4 +1,4 @@ -/* $Id: XeroXMB.h,v 1.5 2004/07/12 15:49:31 philip Exp $ +/* $Id: XeroXMB.h,v 1.6 2004/10/07 20:49:25 philip Exp $ Xeromyces - XMB reading library @@ -120,18 +120,18 @@ public: void Initialise(char* FileData); // Returns the root element - XMBElement getRoot(); + XMBElement getRoot() const; // Returns internal ID for a given ASCII element/attribute string. - int getElementID(const char* Name); - int getAttributeID(const char* Name); + int getElementID(const char* Name) const; + int getAttributeID(const char* Name) const; // For lazy people (e.g. me) when speed isn't vital: // Returns element/attribute string for a given internal ID - std::string getElementString(const int ID); - std::string getAttributeString(const int ID); + std::string getElementString(const int ID) const; + std::string getAttributeString(const int ID) const; private: char* m_Pointer; @@ -155,11 +155,11 @@ public: XMBElement(char* offset) : m_Pointer(offset) {} - int getNodeName(); - XMBElementList getChildNodes(); - XMBAttributeList getAttributes(); - utf16string getText(); - int getLineNumber(); + int getNodeName() const; + XMBElementList getChildNodes() const; + XMBAttributeList getAttributes() const; + utf16string getText() const; + int getLineNumber() const; private: // Pointer to the start of the node @@ -203,7 +203,7 @@ public: : Count(count), m_Pointer(offset) {}; // Get the attribute value directly (unlike Xerces) - utf16string getNamedItem(const int AttributeName); + utf16string getNamedItem(const int AttributeName) const; // Returns an attribute by position in the list XMBAttribute item(const int id); diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index 254baf9046..5fd2cd26fa 100755 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -180,7 +180,7 @@ bool CBaseEntity::loadXML( CStr filename ) return true; } -void CBaseEntity::XMLLoadProperty( CXeromyces& XeroFile, XMBElement& Source, CStrW BasePropertyName ) +void CBaseEntity::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, CStrW BasePropertyName ) { // Add a property, put the node text into it. CStrW PropertyName = BasePropertyName + CStr8( XeroFile.getElementString( Source.getNodeName() ) ); diff --git a/source/simulation/BaseEntity.h b/source/simulation/BaseEntity.h index 52f1255797..66dac978b7 100755 --- a/source/simulation/BaseEntity.h +++ b/source/simulation/BaseEntity.h @@ -35,9 +35,7 @@ public: // Load from XML bool loadXML( CStr filename ); // Load a tree of properties from an XML (XMB) node. - // MT: XeroFile/Source seem to me like they should be const, but the functions they require aren't const members - // and I'm reluctant to go messing round with xerophilic fungi I don't understand. - void XMLLoadProperty( CXeromyces& XeroFile, XMBElement& Source, CStrW BasePropertyName ); + void XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, CStrW BasePropertyName ); // Base stats