Changed: Replace a lot of const char* by std::string parameters

This commit is contained in:
kervala 2016-12-10 12:30:57 +01:00
parent bbeac21e82
commit a625bccce3
10 changed files with 152 additions and 163 deletions

View file

@ -83,9 +83,8 @@ class CPropertyString : public IProperty
{ {
public: public:
CPropertyString () {} CPropertyString () {}
CPropertyString (const char *str);
CPropertyString (const std::string &str); CPropertyString (const std::string &str);
CPropertyString (const char *str, bool _default); CPropertyString (const std::string &str, bool _default);
virtual ~CPropertyString () {} virtual ~CPropertyString () {}
std::string String; std::string String;
@ -287,42 +286,42 @@ public:
* If the property already exist, the method does nothing and returns false. * If the property already exist, the method does nothing and returns false.
* The pointer will be deleted by the primitive using the ::delete operator. * The pointer will be deleted by the primitive using the ::delete operator.
**/ **/
bool addPropertyByName (const char *property_name, IProperty *result); bool addPropertyByName (const std::string &property_name, IProperty *result);
/** /**
* Get a property with its name * Get a property with its name
**/ **/
bool getPropertyByName (const char *property_name, const IProperty *&result) const; bool getPropertyByName (const std::string &property_name, const IProperty *&result) const;
/** /**
* Get a property with its name * Get a property with its name
**/ **/
bool getPropertyByName (const char *property_name, IProperty *&result) const; bool getPropertyByName (const std::string &property_name, IProperty *&result) const;
/** /**
* Get a string property with its name. Return false if the property is not found or is not a string property. * Get a string property with its name. Return false if the property is not found or is not a string property.
**/ **/
bool getPropertyByName (const char *property_name, std::string *&result) const; bool getPropertyByName (const std::string &property_name, std::string *&result) const;
/** /**
* Get a string array property with its name. Return false if the property is not found or is not a string array property. * Get a string array property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, std::vector<std::string> *&result) const; bool getPropertyByName (const std::string &property_name, std::vector<std::string> *&result) const;
/** /**
* Get a string property with its name. Return false if the property is not found or is not a string property. * Get a string property with its name. Return false if the property is not found or is not a string property.
**/ **/
bool getPropertyByName (const char *property_name, std::string &result) const; bool getPropertyByName (const std::string &property_name, std::string &result) const;
/** /**
* Get a string array property with its name. Return false if the property is not found or is not a string array property. * Get a string array property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, const std::vector<std::string> *&result) const; bool getPropertyByName (const std::string &property_name, const std::vector<std::string> *&result) const;
/** /**
* Get a color property with its name. Return false if the property is not found or is not a string array property. * Get a color property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const; bool getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const;
/** /**
* Remove a property * Remove a property
@ -333,7 +332,7 @@ public:
/** /**
* Remove a property by its name * Remove a property by its name
**/ **/
bool removePropertyByName (const char *property_name); bool removePropertyByName (const std::string &property_name);
/** /**
* Remove all the properties * Remove all the properties
@ -347,10 +346,10 @@ public:
void initDefaultValues (CLigoConfig &config); void initDefaultValues (CLigoConfig &config);
// Read the primitive, calls initDefaultValue (CLigoConfig &config) // Read the primitive, calls initDefaultValue (CLigoConfig &config)
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &property_name, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &property_name) const;
// Get the vertices // Get the vertices
virtual uint getNumVector () const = 0; virtual uint getNumVector () const = 0;
@ -435,7 +434,7 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -474,10 +473,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -509,10 +508,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -568,10 +567,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -632,9 +631,9 @@ public:
uint32 getFullAlias() const; uint32 getFullAlias() const;
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Create a copy of this primitive // Create a copy of this primitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
// serial for binary save // serial for binary save
@ -686,13 +685,13 @@ public:
void convert (const CPrimRegion &region); void convert (const CPrimRegion &region);
// Read the primitive // Read the primitive
bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); bool read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config);
// Write the primitive // Write the primitive
void write (xmlDocPtr xmlNode, const char *filename) const; void write (xmlDocPtr xmlNode, const std::string &filename) const;
// Write the primitive // Write the primitive
void write (xmlNodePtr root, const char *filename) const; void write (xmlNodePtr root, const std::string &filename) const;
// serial the primitive. Used for binary files. // serial the primitive. Used for binary files.
void serial(NLMISC::IStream &f); void serial(NLMISC::IStream &f);

View file

@ -120,11 +120,11 @@ public:
/** Get the first child node pointer named childName. NULL if no node named childName. /** Get the first child node pointer named childName. NULL if no node named childName.
*/ */
static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const char *childName); static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const std::string &childName);
/** Get the next child node pointer name childName, brother of previous. NULL if no node named childName. /** Get the next child node pointer name childName, brother of previous. NULL if no node named childName.
*/ */
static xmlNodePtr getNextChildNode (xmlNodePtr last, const char *childName); static xmlNodePtr getNextChildNode (xmlNodePtr last, const std::string &childName);
/** Get the first child node pointer of type. NULL if no node of type. /** Get the first child node pointer of type. NULL if no node of type.
*/ */
@ -136,7 +136,7 @@ public:
/** Count number of sub node named with a given name for a given node. /** Count number of sub node named with a given name for a given node.
*/ */
static uint countChildren (xmlNodePtr node, const char *childName); static uint countChildren (xmlNodePtr node, const std::string &childName);
/** Count number of sub node of type for a given node. /** Count number of sub node of type for a given node.
*/ */
@ -147,22 +147,22 @@ public:
* *
* Returns true and the result if the property has been found, else false. * Returns true and the result if the property has been found, else false.
*/ */
static bool getPropertyString (std::string &result, xmlNodePtr node, const char *property); static bool getPropertyString (std::string &result, xmlNodePtr node, const std::string &property);
/** /**
* Read an integer property - if the property is not found the default value is returned * Read an integer property - if the property is not found the default value is returned
*/ */
static int getIntProperty(xmlNodePtr node, const char *property, int defaultValue); static int getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue);
/** /**
* Read a floating point property - if the property is not found the default value is returned * Read a floating point property - if the property is not found the default value is returned
*/ */
static double getFloatProperty(xmlNodePtr node, const char *property, float defaultValue); static double getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue);
/** /**
* Read a string property - if the property is not found the default value is returned * Read a string property - if the property is not found the default value is returned
*/ */
static std::string getStringProperty(xmlNodePtr node, const char *property, const std::string& defaultValue); static std::string getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue);
/** /**
* Read the content of the node as a string * Read the content of the node as a string
@ -198,12 +198,12 @@ private:
virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBuffer(uint8 *buf, uint len);
virtual void serialBit(bool &bit); virtual void serialBit(bool &bit);
virtual bool xmlPushBeginInternal (const char *nodeName); virtual bool xmlPushBeginInternal (const std::string &nodeName);
virtual bool xmlPushEndInternal (); virtual bool xmlPushEndInternal ();
virtual bool xmlPopInternal (); virtual bool xmlPopInternal ();
virtual bool xmlSetAttribInternal (const char *attribName); virtual bool xmlSetAttribInternal (const std::string &attribName);
virtual bool xmlBreakLineInternal (); virtual bool xmlBreakLineInternal ();
virtual bool xmlCommentInternal (const char *comment); virtual bool xmlCommentInternal (const std::string &comment);
// Internal functions // Internal functions
void serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true ); void serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true );

View file

@ -95,7 +95,7 @@ public:
* \param version is the version to write in the XML header. Default is 1.0. * \param version is the version to write in the XML header. Default is 1.0.
* \return true if initialisation is successful, false if the stream passed is not an output stream. * \return true if initialisation is successful, false if the stream passed is not an output stream.
*/ */
bool init (IStream *stream, const char *version="1.0"); bool init (IStream *stream, const std::string &version = "1.0");
/** Return the error string. /** Return the error string.
* if not empty, something wrong appends * if not empty, something wrong appends
@ -120,7 +120,7 @@ public:
/** Return true if the string is valid to be stored in a XML property without modification. /** Return true if the string is valid to be stored in a XML property without modification.
*/ */
static bool isStringValidForProperties (const char *str); static bool isStringValidForProperties (const std::string &str);
private: private:
@ -144,15 +144,15 @@ private:
virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBuffer(uint8 *buf, uint len);
virtual void serialBit(bool &bit); virtual void serialBit(bool &bit);
virtual bool xmlPushBeginInternal (const char *nodeName); virtual bool xmlPushBeginInternal (const std::string &nodeName);
virtual bool xmlPushEndInternal (); virtual bool xmlPushEndInternal ();
virtual bool xmlPopInternal (); virtual bool xmlPopInternal ();
virtual bool xmlSetAttribInternal (const char *attribName); virtual bool xmlSetAttribInternal (const std::string &attribName);
virtual bool xmlBreakLineInternal (); virtual bool xmlBreakLineInternal ();
virtual bool xmlCommentInternal (const char *comment); virtual bool xmlCommentInternal (const std::string &comment);
// Internal functions // Internal functions
void serialSeparatedBufferOut( const char *value ); void serialSeparatedBufferOut( const std::string &value );
inline void flushContentString (); inline void flushContentString ();
// Push mode // Push mode

View file

@ -724,7 +724,7 @@ public:
* xmlSerial() serial a values into a node. * xmlSerial() serial a values into a node.
*/ */
template<class T> template<class T>
void xmlSerial (T& value0, const char *nodeName) void xmlSerial (T& value0, const std::string &nodeName)
{ {
// Open the node // Open the node
xmlPush (nodeName); xmlPush (nodeName);
@ -736,7 +736,7 @@ public:
xmlPop (); xmlPop ();
} }
template<class T> template<class T>
void xmlSerial (T& value0, T& value1, const char *nodeName) void xmlSerial (T& value0, T& value1, const std::string &nodeName)
{ {
// Open the node // Open the node
xmlPush (nodeName); xmlPush (nodeName);
@ -748,7 +748,7 @@ public:
xmlPop (); xmlPop ();
} }
template<class T> template<class T>
void xmlSerial (T& value0, T& value1, T& value2, const char *nodeName) void xmlSerial (T& value0, T& value1, T& value2, const std::string &nodeName)
{ {
// Open the node // Open the node
xmlPush (nodeName); xmlPush (nodeName);
@ -760,7 +760,7 @@ public:
xmlPop (); xmlPop ();
} }
template<class T> template<class T>
void xmlSerial (T& value0, T& value1, T& value2, T& value3, const char *nodeName) void xmlSerial (T& value0, T& value1, T& value2, T& value3, const std::string &nodeName)
{ {
// Open the node // Open the node
xmlPush (nodeName); xmlPush (nodeName);
@ -778,7 +778,7 @@ public:
* \name is the name of the node to open * \name is the name of the node to open
* \return true if you can open the node, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call. * \return true if you can open the node, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call.
*/ */
bool xmlPush (const char *name) bool xmlPush (const std::string &name)
{ {
// XML Mode ? // XML Mode ?
if (_XML) if (_XML)
@ -802,7 +802,7 @@ public:
* \name is the name of the node to open * \name is the name of the node to open
* \return true if you can open the node header, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call. * \return true if you can open the node header, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call.
*/ */
bool xmlPushBegin (const char *name) bool xmlPushBegin (const std::string &name)
{ {
// XML Mode ? // XML Mode ?
if (_XML) if (_XML)
@ -854,7 +854,7 @@ public:
* \param name is the name of the node header attribute serialised. * \param name is the name of the node header attribute serialised.
* \return true if the attribute name have been set, false if the node header is not open (the call is not between xmlPushBegin and xmlPushEnd) * \return true if the attribute name have been set, false if the node header is not open (the call is not between xmlPushBegin and xmlPushEnd)
*/ */
bool xmlSetAttrib (const char *name) bool xmlSetAttrib (const std::string &name)
{ {
// XML Mode ? // XML Mode ?
if (_XML) if (_XML)
@ -888,7 +888,7 @@ public:
* *
* \return true if the comment is added, return false if no node is opened. * \return true if the comment is added, return false if no node is opened.
*/ */
bool xmlComment (const char *comment) bool xmlComment (const std::string &comment)
{ {
// XML Mode ? // XML Mode ?
if (_XML) if (_XML)
@ -910,7 +910,7 @@ protected:
void setXMLMode (bool on); void setXMLMode (bool on);
/// xmlPushBegin implementation /// xmlPushBegin implementation
virtual bool xmlPushBeginInternal (const char * /* name */) { return true; }; virtual bool xmlPushBeginInternal (const std::string &/* name */) { return true; };
/// xmlPushEnd implementation /// xmlPushEnd implementation
virtual bool xmlPushEndInternal () { return true; }; virtual bool xmlPushEndInternal () { return true; };
@ -919,13 +919,13 @@ protected:
virtual bool xmlPopInternal () { return true; }; virtual bool xmlPopInternal () { return true; };
/// xmlBreakLine implementation /// xmlBreakLine implementation
virtual bool xmlSetAttribInternal (const char * /* name */) { return true; }; virtual bool xmlSetAttribInternal (const std::string &/* name */) { return true; };
/// xmlBreakLine implementation /// xmlBreakLine implementation
virtual bool xmlBreakLineInternal () { return true; }; virtual bool xmlBreakLineInternal () { return true; };
/// xmlComment implementation /// xmlComment implementation
virtual bool xmlCommentInternal (const char * /* comment */) { return true; }; virtual bool xmlCommentInternal (const std::string &/* comment */) { return true; };
/** /**
* for Deriver: reset the PtrTable in the stream. * for Deriver: reset the PtrTable in the stream.

View file

@ -42,7 +42,7 @@ CPrimitiveContext *CPrimitiveContext::_Instance = NULL;
// XML helpers // XML helpers
// *************************************************************************** // ***************************************************************************
void Error (const char *filename, const char *format, ...) void Error (const std::string &filename, const char *format, ...)
{ {
va_list args; va_list args;
va_start( args, format ); va_start( args, format );
@ -50,12 +50,12 @@ void Error (const char *filename, const char *format, ...)
vsnprintf( buffer, 1024, format, args ); vsnprintf( buffer, 1024, format, args );
va_end( args ); va_end( args );
nlwarning ("In File (%s) %s", filename, buffer); nlwarning ("In File (%s) %s", filename.c_str(), buffer);
} }
// *************************************************************************** // ***************************************************************************
void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... ) void XMLError (xmlNodePtr xmlNode, const std::string &filename, const char *format, ... )
{ {
va_list args; va_list args;
va_start( args, format ); va_start( args, format );
@ -69,20 +69,20 @@ void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ...
// *************************************************************************** // ***************************************************************************
xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const char *filename, const char *childName) xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const std::string &filename, const std::string &childName)
{ {
// Call the CIXml version // Call the CIXml version
xmlNodePtr result = CIXml::getFirstChildNode (xmlNode, childName); xmlNodePtr result = CIXml::getFirstChildNode (xmlNode, childName);
if (result) return result; if (result) return result;
// Output a formated error // Output a formated error
XMLError (xmlNode, filename, "Can't find XML node named (%s)", childName); XMLError (xmlNode, filename.c_str(), "Can't find XML node named (%s)", childName);
return NULL; return NULL;
} }
// *************************************************************************** // ***************************************************************************
bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) bool GetPropertyString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName)
{ {
// Call the CIXml version // Call the CIXml version
if (!CIXml::getPropertyString (result, xmlNode, propName)) if (!CIXml::getPropertyString (result, xmlNode, propName))
@ -96,7 +96,7 @@ bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode
// *************************************************************************** // ***************************************************************************
bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePtr xmlNode) bool ReadInt (const std::string &propName, int &result, const std::string &filename, xmlNodePtr xmlNode)
{ {
string value; string value;
if (GetPropertyString (value, filename, xmlNode, propName)) if (GetPropertyString (value, filename, xmlNode, propName))
@ -109,15 +109,15 @@ bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePt
// *************************************************************************** // ***************************************************************************
void WriteInt (const char *propName, int value, xmlNodePtr xmlNode) void WriteInt (const std::string &propName, int value, xmlNodePtr xmlNode)
{ {
// Set properties // Set properties
xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ()));
} }
// *************************************************************************** // ***************************************************************************
bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNodePtr xmlNode) bool ReadUInt (const std::string &propName, uint &result, const std::string &filename, xmlNodePtr xmlNode)
{ {
string value; string value;
if (GetPropertyString (value, filename, xmlNode, propName)) if (GetPropertyString (value, filename, xmlNode, propName))
@ -130,15 +130,15 @@ bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNode
// *************************************************************************** // ***************************************************************************
void WriteUInt (const char *propName, uint value, xmlNodePtr xmlNode) void WriteUInt (const std::string &propName, uint value, xmlNodePtr xmlNode)
{ {
// Set properties // Set properties
xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ()));
} }
// *************************************************************************** // ***************************************************************************
bool ReadFloat (const char *propName, float &result, const char *filename, xmlNodePtr xmlNode) bool ReadFloat (const std::string &propName, float &result, const std::string &filename, xmlNodePtr xmlNode)
{ {
string value; string value;
if (GetPropertyString (value, filename, xmlNode, propName)) if (GetPropertyString (value, filename, xmlNode, propName))
@ -151,15 +151,15 @@ bool ReadFloat (const char *propName, float &result, const char *filename, xmlNo
// *************************************************************************** // ***************************************************************************
void WriteFloat (const char *propName, float value, xmlNodePtr xmlNode) void WriteFloat (const std::string &propName, float value, xmlNodePtr xmlNode)
{ {
// Set properties // Set properties
xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ()));
} }
// *************************************************************************** // ***************************************************************************
bool ReadVector (CPrimVector &point, const char *filename, xmlNodePtr xmlNode) bool ReadVector (CPrimVector &point, const std::string &filename, xmlNodePtr xmlNode)
{ {
CPrimVector pos; CPrimVector pos;
if (ReadFloat ("X", pos.x, filename, xmlNode)) if (ReadFloat ("X", pos.x, filename, xmlNode))
@ -198,7 +198,7 @@ void WriteVector (const CPrimVector &point, xmlNodePtr xmlNode)
// *************************************************************************** // ***************************************************************************
bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, const char *nodeName) bool GetNodeString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &nodeName)
{ {
// Look for the node // Look for the node
xmlNodePtr node = CIXml::getFirstChildNode (xmlNode, nodeName); xmlNodePtr node = CIXml::getFirstChildNode (xmlNode, nodeName);
@ -220,7 +220,7 @@ bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, co
// *************************************************************************** // ***************************************************************************
bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode) bool GetContentString (string &result, const std::string &filename, xmlNodePtr xmlNode)
{ {
// Get the node string // Get the node string
if (!CIXml::getContentString (result, xmlNode)) if (!CIXml::getContentString (result, xmlNode))
@ -236,11 +236,6 @@ bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode)
// CPropertyString // CPropertyString
// *************************************************************************** // ***************************************************************************
CPropertyString::CPropertyString (const char *str)
{
String = str;
}
CPropertyString::CPropertyString (const std::string &str) CPropertyString::CPropertyString (const std::string &str)
{ {
String = str; String = str;
@ -248,7 +243,7 @@ CPropertyString::CPropertyString (const std::string &str)
// *************************************************************************** // ***************************************************************************
CPropertyString::CPropertyString (const char *str, bool _default) CPropertyString::CPropertyString (const std::string &str, bool _default)
{ {
String = str; String = str;
Default = _default; Default = _default;
@ -390,7 +385,7 @@ bool CPrimZone::contains (const NLMISC::CVector &v, const std::vector<NLMISC::CV
// CPrimNode // CPrimNode
// *************************************************************************** // ***************************************************************************
bool CPrimNode::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimNode::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
return IPrimitive::read (xmlNode, filename, version, config); return IPrimitive::read (xmlNode, filename, version, config);
} }
@ -488,7 +483,7 @@ NLLIGO::IPrimitive *CPrimPoint::copy () const
// *************************************************************************** // ***************************************************************************
bool CPrimPoint::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimPoint::read(xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
// Read points // Read points
xmlNodePtr ptNode = GetFirstChildNode (xmlNode, filename, "PT"); xmlNodePtr ptNode = GetFirstChildNode (xmlNode, filename, "PT");
@ -518,7 +513,7 @@ bool CPrimPoint::read (xmlNodePtr xmlNode, const char *filename, uint version, C
// *************************************************************************** // ***************************************************************************
void CPrimPoint::write (xmlNodePtr xmlNode, const char *filename) const void CPrimPoint::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
// Save the point // Save the point
xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PT", NULL); xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PT", NULL);
@ -570,7 +565,7 @@ CPrimVector *CPrimPath::getPrimVector ()
// *************************************************************************** // ***************************************************************************
bool CPrimPath::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimPath::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
// Read points // Read points
VPoints.clear (); VPoints.clear ();
@ -595,7 +590,7 @@ bool CPrimPath::read (xmlNodePtr xmlNode, const char *filename, uint version, CL
// *************************************************************************** // ***************************************************************************
void CPrimPath::write (xmlNodePtr xmlNode, const char *filename) const void CPrimPath::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
// Save the points // Save the points
for (uint i=0; i<VPoints.size (); i++) for (uint i=0; i<VPoints.size (); i++)
@ -642,7 +637,7 @@ CPrimVector *CPrimZone::getPrimVector ()
// *************************************************************************** // ***************************************************************************
bool CPrimZone::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimZone::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
// Read points // Read points
VPoints.clear (); VPoints.clear ();
@ -667,7 +662,7 @@ bool CPrimZone::read (xmlNodePtr xmlNode, const char *filename, uint version, CL
// *************************************************************************** // ***************************************************************************
void CPrimZone::write (xmlNodePtr xmlNode, const char *filename) const void CPrimZone::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
// Save the points // Save the points
for (uint i=0; i<VPoints.size (); i++) for (uint i=0; i<VPoints.size (); i++)
@ -1314,7 +1309,7 @@ bool IPrimitive::getProperty (uint index, std::string &property_name, IProperty
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, const IProperty *&result) const bool IPrimitive::getPropertyByName (const std::string &property_name, const IProperty *&result) const
{ {
// Look for the property // Look for the property
std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name); std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name);
@ -1328,7 +1323,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const IProperty *
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&result) const bool IPrimitive::getPropertyByName (const std::string &property_name, IProperty *&result) const
{ {
// Look for the property // Look for the property
std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name); std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name);
@ -1342,7 +1337,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&resul
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, std::string *&result) const bool IPrimitive::getPropertyByName (const std::string &property_name, std::string *&result) const
{ {
// Get the property // Get the property
IProperty *prop; IProperty *prop;
@ -1356,7 +1351,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res
} }
else else
{ {
nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str());
} }
} }
return false; return false;
@ -1364,7 +1359,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, std::string &result) const bool IPrimitive::getPropertyByName (const std::string &property_name, std::string &result) const
{ {
// Get the property // Get the property
const IProperty *prop; const IProperty *prop;
@ -1378,7 +1373,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu
} }
else else
{ {
nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str());
} }
} }
return false; return false;
@ -1386,7 +1381,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, std::vector<std::string> *&result) const bool IPrimitive::getPropertyByName (const std::string &property_name, std::vector<std::string> *&result) const
{ {
// Get the property // Get the property
IProperty *prop; IProperty *prop;
@ -1400,7 +1395,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::vector<std::
} }
else else
{ {
nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str());
} }
} }
return false; return false;
@ -1408,7 +1403,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::vector<std::
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, const std::vector<std::string> *&result) const bool IPrimitive::getPropertyByName (const std::string &property_name, const std::vector<std::string> *&result) const
{ {
// Get the property // Get the property
IProperty *prop; IProperty *prop;
@ -1422,7 +1417,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector
} }
else else
{ {
nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str());
} }
} }
return false; return false;
@ -1430,7 +1425,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector
// *************************************************************************** // ***************************************************************************
bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const bool IPrimitive::getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const
{ {
// Get the property // Get the property
IProperty *prop; IProperty *prop;
@ -1444,7 +1439,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &re
} }
else else
{ {
nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name); nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name.c_str());
} }
} }
return false; return false;
@ -1472,7 +1467,7 @@ bool IPrimitive::removeProperty (uint index)
// *************************************************************************** // ***************************************************************************
bool IPrimitive::removePropertyByName (const char *property_name) bool IPrimitive::removePropertyByName (const std::string &property_name)
{ {
// Look for the property // Look for the property
std::map<std::string, IProperty*>::iterator ite = _Properties.find (property_name); std::map<std::string, IProperty*>::iterator ite = _Properties.find (property_name);
@ -1646,7 +1641,7 @@ bool IPrimitive::checkProperty(const std::string &property_name) const
// *************************************************************************** // ***************************************************************************
bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result) bool IPrimitive::addPropertyByName (const std::string &property_name, IProperty *result)
{ {
bool inserted = _Properties.insert (std::map<std::string, IProperty*>::value_type (property_name, result)).second; bool inserted = _Properties.insert (std::map<std::string, IProperty*>::value_type (property_name, result)).second;
if (inserted) if (inserted)
@ -1658,7 +1653,7 @@ bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result
// *************************************************************************** // ***************************************************************************
bool IPrimitive::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool IPrimitive::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
// Erase old properties // Erase old properties
_Properties.clear (); _Properties.clear ();
@ -1919,7 +1914,7 @@ void IPrimitive::initDefaultValues (CLigoConfig &config)
// *************************************************************************** // ***************************************************************************
void IPrimitive::write (xmlNodePtr xmlNode, const char *filename) const void IPrimitive::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
// Save the expanded flag // Save the expanded flag
// if (!Expanded) // if (!Expanded)
@ -2116,7 +2111,7 @@ void CPrimAlias::regenAlias()
// Read the primitive // Read the primitive
bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimAlias::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
// Read alias // Read alias
xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "ALIAS"); xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "ALIAS");
@ -2150,7 +2145,7 @@ bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, C
return IPrimitive::read (xmlNode, filename, version, config); return IPrimitive::read (xmlNode, filename, version, config);
} }
// Write the primitive // Write the primitive
void CPrimAlias::write (xmlNodePtr xmlNode, const char *filename) const void CPrimAlias::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
// Write alias // Write alias
xmlNodePtr ptNode = xmlNewChild(xmlNode, NULL, (const xmlChar*)"ALIAS", NULL); xmlNodePtr ptNode = xmlNewChild(xmlNode, NULL, (const xmlChar*)"ALIAS", NULL);
@ -2462,7 +2457,7 @@ CPrimitives& CPrimitives::operator= (const CPrimitives &other)
// *************************************************************************** // ***************************************************************************
bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config) bool CPrimitives::read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config)
{ {
nlassert (xmlNode); nlassert (xmlNode);
@ -2535,7 +2530,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &c
// *************************************************************************** // ***************************************************************************
void CPrimitives::write (xmlDocPtr doc, const char *filename) const void CPrimitives::write (xmlDocPtr doc, const std::string &filename) const
{ {
nlassert (doc); nlassert (doc);
@ -2548,7 +2543,7 @@ void CPrimitives::write (xmlDocPtr doc, const char *filename) const
// *************************************************************************** // ***************************************************************************
void CPrimitives::write (xmlNodePtr root, const char *filename) const void CPrimitives::write (xmlNodePtr root, const std::string &filename) const
{ {
nlassert (root); nlassert (root);

View file

@ -715,7 +715,7 @@ void CIXml::serialBuffer(uint8 *buf, uint len)
// *************************************************************************** // ***************************************************************************
bool CIXml::xmlPushBeginInternal (const char *nodeName) bool CIXml::xmlPushBeginInternal (const std::string &nodeName)
{ {
nlassert( isReading() ); nlassert( isReading() );
@ -744,12 +744,12 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName)
nlassert (_CurrentNode->name); nlassert (_CurrentNode->name);
// Node element with the good name ? // Node element with the good name ?
if ( (_CurrentNode->type != XML_ELEMENT_NODE) || ( (const char*)_CurrentNode->name != string(nodeName)) ) if ( (_CurrentNode->type != XML_ELEMENT_NODE) || ( (const char*)_CurrentNode->name != nodeName) )
{ {
// Make an error message // Make an error message
char tmp[512]; char tmp[512];
smprintf (tmp, 512, "NeL XML Syntax error : root node has the wrong name : \"%s\" should have \"%s\"", smprintf (tmp, 512, "NeL XML Syntax error : root node has the wrong name : \"%s\" should have \"%s\"",
_CurrentNode->name, nodeName); _CurrentNode->name, nodeName.c_str());
throw EXmlParsingError (tmp); throw EXmlParsingError (tmp);
} }
} }
@ -769,7 +769,7 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName)
nlassert (_CurrentNode->name); nlassert (_CurrentNode->name);
// Node with the good name // Node with the good name
if ( (_CurrentNode->type == XML_ELEMENT_NODE) && ( (const char*)_CurrentNode->name == string(nodeName)) ) if ( (_CurrentNode->type == XML_ELEMENT_NODE) && ( (const char*)_CurrentNode->name == nodeName) )
{ {
// Save current element // Save current element
_CurrentElement = _CurrentNode; _CurrentElement = _CurrentNode;
@ -789,7 +789,7 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName)
// Make an error message // Make an error message
char tmp[512]; char tmp[512];
smprintf (tmp, 512, "NeL XML Syntax error in block line %d \nCan't open the node named %s in node named %s", smprintf (tmp, 512, "NeL XML Syntax error in block line %d \nCan't open the node named %s in node named %s",
(int)_CurrentElement->line, nodeName, _CurrentElement->name); (int)_CurrentElement->line, nodeName.c_str(), _CurrentElement->name);
throw EXmlParsingError (tmp); throw EXmlParsingError (tmp);
} }
@ -902,7 +902,7 @@ bool CIXml::xmlPopInternal ()
// *************************************************************************** // ***************************************************************************
bool CIXml::xmlSetAttribInternal (const char *attribName) bool CIXml::xmlSetAttribInternal (const std::string &attribName)
{ {
nlassert( isReading() ); nlassert( isReading() );
@ -951,7 +951,7 @@ bool CIXml::xmlBreakLineInternal ()
// *************************************************************************** // ***************************************************************************
bool CIXml::xmlCommentInternal (const char * /* comment */) bool CIXml::xmlCommentInternal (const std::string &/* comment */)
{ {
// Ok // Ok
return true; return true;
@ -959,12 +959,12 @@ bool CIXml::xmlCommentInternal (const char * /* comment */)
// *************************************************************************** // ***************************************************************************
xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const char *childName) xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const std::string &childName)
{ {
xmlNodePtr child = parent->children; xmlNodePtr child = parent->children;
while (child) while (child)
{ {
if (strcmp ((const char*)child->name, childName) == 0) if (childName == (const char*)child->name)
return child; return child;
child = child->next; child = child->next;
} }
@ -973,12 +973,12 @@ xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const char *childName)
// *************************************************************************** // ***************************************************************************
xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, const char *childName) xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, const std::string &childName)
{ {
last = last->next; last = last->next;
while (last) while (last)
{ {
if (strcmp ((const char*)last->name, childName) == 0) if (childName == (const char*)last->name)
return last; return last;
last = last->next; last = last->next;
} }
@ -1015,7 +1015,7 @@ xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, sint /* xmlElementType */ t
// *************************************************************************** // ***************************************************************************
uint CIXml::countChildren (xmlNodePtr node, const char *childName) uint CIXml::countChildren (xmlNodePtr node, const std::string &childName)
{ {
uint count=0; uint count=0;
xmlNodePtr child = getFirstChildNode (node, childName); xmlNodePtr child = getFirstChildNode (node, childName);
@ -1053,10 +1053,10 @@ xmlNodePtr CIXml::getRootNode () const
// *************************************************************************** // ***************************************************************************
bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const char *property) bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const std::string &property)
{ {
// Get the value // Get the value
const char *value = (const char*)xmlGetProp (node, (xmlChar*)property); const char *value = (const char*)xmlGetProp (node, (xmlChar*)property.c_str());
if (value) if (value)
{ {
// Active value // Active value
@ -1073,7 +1073,7 @@ bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const char
// *************************************************************************** // ***************************************************************************
int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValue) int CIXml::getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue)
{ {
CSString s; CSString s;
bool b; bool b;
@ -1095,7 +1095,7 @@ int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValu
// *************************************************************************** // ***************************************************************************
double CIXml::getFloatProperty(xmlNodePtr node, const char *property, float defaultValue) double CIXml::getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue)
{ {
CSString s; CSString s;
bool b; bool b;
@ -1109,7 +1109,7 @@ double CIXml::getFloatProperty(xmlNodePtr node, const char *property, float defa
// *************************************************************************** // ***************************************************************************
std::string CIXml::getStringProperty(xmlNodePtr node, const char *property, const std::string& defaultValue) std::string CIXml::getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue)
{ {
std::string s; std::string s;
bool b; bool b;

View file

@ -152,7 +152,7 @@ void xmlGenericErrorFuncWrite (void *ctx, const char *msg, ...)
// *************************************************************************** // ***************************************************************************
bool COXml::init (IStream *stream, const char *version) bool COXml::init (IStream *stream, const std::string &version)
{ {
resetPtrTable(); resetPtrTable();
@ -201,7 +201,7 @@ COXml::~COXml ()
// *************************************************************************** // ***************************************************************************
void COXml::serialSeparatedBufferOut( const char *value ) void COXml::serialSeparatedBufferOut( const std::string &value )
{ {
nlassert( ! isReading() ); nlassert( ! isReading() );
@ -218,7 +218,7 @@ void COXml::serialSeparatedBufferOut( const char *value )
if (_AttribPresent) if (_AttribPresent)
{ {
// Set the attribute // Set the attribute
xmlSetProp (_CurrentNode, (const xmlChar*)_AttribName.c_str(), (const xmlChar*)value); xmlSetProp (_CurrentNode, (const xmlChar*)_AttribName.c_str(), (const xmlChar*)value.c_str());
// The attribute has been used // The attribute has been used
_AttribPresent = false; _AttribPresent = false;
@ -349,7 +349,8 @@ void COXml::serialBit(bool &bit)
#ifndef NL_OS_CYGWIN #ifndef NL_OS_CYGWIN
void COXml::serial(char &b) void COXml::serial(char &b)
{ {
char tmp[2] = {b , 0}; std::string tmp;
tmp += b;
serialSeparatedBufferOut( tmp ); serialSeparatedBufferOut( tmp );
} }
#endif // NL_OS_CYGWIN #endif // NL_OS_CYGWIN
@ -364,7 +365,7 @@ void COXml::serial(std::string &b)
if (_PushBegin) if (_PushBegin)
{ {
// Only serial the string // Only serial the string
serialSeparatedBufferOut( b.c_str() ); serialSeparatedBufferOut( b );
} }
else else
{ {
@ -372,7 +373,7 @@ void COXml::serial(std::string &b)
xmlPush ("S"); xmlPush ("S");
// Serial the string // Serial the string
serialSeparatedBufferOut( b.c_str() ); serialSeparatedBufferOut( b );
// Close the node // Close the node
xmlPop (); xmlPop ();
@ -415,7 +416,7 @@ void COXml::serialBuffer(uint8 *buf, uint len)
// *************************************************************************** // ***************************************************************************
bool COXml::xmlPushBeginInternal (const char *nodeName) bool COXml::xmlPushBeginInternal (const std::string &nodeName)
{ {
nlassert( ! isReading() ); nlassert( ! isReading() );
@ -439,7 +440,7 @@ bool COXml::xmlPushBeginInternal (const char *nodeName)
} }
// Create the first node // Create the first node
_CurrentNode=xmlNewDocNode (_Document, NULL, (const xmlChar*)nodeName, NULL); _CurrentNode=xmlNewDocNode (_Document, NULL, (const xmlChar*)nodeName.c_str(), NULL);
xmlDocSetRootElement (_Document, _CurrentNode); xmlDocSetRootElement (_Document, _CurrentNode);
// Return NULL if error // Return NULL if error
@ -451,7 +452,7 @@ bool COXml::xmlPushBeginInternal (const char *nodeName)
flushContentString (); flushContentString ();
// Create a new node // Create a new node
_CurrentNode=xmlNewChild (_CurrentNode, NULL, (const xmlChar*)nodeName, NULL); _CurrentNode=xmlNewChild (_CurrentNode, NULL, (const xmlChar*)nodeName.c_str(), NULL);
// Return NULL if error // Return NULL if error
nlassert (_CurrentNode); nlassert (_CurrentNode);
@ -543,7 +544,7 @@ bool COXml::xmlPopInternal ()
// *************************************************************************** // ***************************************************************************
bool COXml::xmlSetAttribInternal (const char *attribName) bool COXml::xmlSetAttribInternal (const std::string &attribName)
{ {
nlassert( ! isReading() ); nlassert( ! isReading() );
@ -608,7 +609,7 @@ bool COXml::xmlBreakLineInternal ()
// *************************************************************************** // ***************************************************************************
bool COXml::xmlCommentInternal (const char *comment) bool COXml::xmlCommentInternal (const std::string &comment)
{ {
nlassert( ! isReading() ); nlassert( ! isReading() );
@ -619,7 +620,7 @@ bool COXml::xmlCommentInternal (const char *comment)
if ( _CurrentNode != NULL) if ( _CurrentNode != NULL)
{ {
// Add a comment node // Add a comment node
xmlNodePtr commentPtr = xmlNewComment ((const xmlChar *)comment); xmlNodePtr commentPtr = xmlNewComment ((const xmlChar *)comment.c_str());
// Add the node // Add the node
xmlAddChild (_CurrentNode, commentPtr); xmlAddChild (_CurrentNode, commentPtr);
@ -665,15 +666,9 @@ void COXml::flush ()
// *************************************************************************** // ***************************************************************************
bool COXml::isStringValidForProperties (const char *str) bool COXml::isStringValidForProperties (const std::string &str)
{ {
while (*str) return str.find('\n') == std::string::npos;
{
if (*str == '\n')
return false;
str++;
}
return true;
} }
// *************************************************************************** // ***************************************************************************

View file

@ -645,7 +645,7 @@ class CActionSetPrimitivePropertyString : public IAction
public: public:
// Constructor // Constructor
CActionSetPrimitivePropertyString (const CDatabaseLocatorPointer &locator, const char *propertyName, const char *newValue, bool _default); CActionSetPrimitivePropertyString (const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::string &newValue, bool _default);
private: private:
@ -668,7 +668,7 @@ class CActionSetPrimitivePropertyStringArray : public IAction
public: public:
// Constructor // Constructor
CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const char *propertyName, const std::vector<std::string> &newValue, bool _default); CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::vector<std::string> &newValue, bool _default);
private: private:

View file

@ -742,14 +742,14 @@ IPrimitive *CPrimNodeEditor::copy () const
return new CPrimNodeEditor (*this); return new CPrimNodeEditor (*this);
} }
bool CPrimNodeEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimNodeEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
bool ret = CPrimNode::read(xmlNode, filename, version, config); bool ret = CPrimNode::read(xmlNode, filename, version, config);
IPrimitiveEditor::postReadCallback(this); IPrimitiveEditor::postReadCallback(this);
return ret; return ret;
} }
void CPrimNodeEditor::write (xmlNodePtr xmlNode, const char *filename) const void CPrimNodeEditor::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
IPrimitiveEditor::preWriteCallback(this); IPrimitiveEditor::preWriteCallback(this);
CPrimNode::write(xmlNode, filename); CPrimNode::write(xmlNode, filename);
@ -770,14 +770,14 @@ IPrimitive *CPrimPointEditor::copy () const
return new CPrimPointEditor (*this); return new CPrimPointEditor (*this);
} }
bool CPrimPointEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimPointEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
bool ret = CPrimPoint::read(xmlNode, filename, version, config); bool ret = CPrimPoint::read(xmlNode, filename, version, config);
IPrimitiveEditor::postReadCallback(this); IPrimitiveEditor::postReadCallback(this);
return ret; return ret;
} }
void CPrimPointEditor::write (xmlNodePtr xmlNode, const char *filename) const void CPrimPointEditor::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
IPrimitiveEditor::preWriteCallback(this); IPrimitiveEditor::preWriteCallback(this);
CPrimPoint::write(xmlNode, filename); CPrimPoint::write(xmlNode, filename);
@ -797,14 +797,14 @@ IPrimitive *CPrimPathEditor::copy () const
return new CPrimPathEditor (*this); return new CPrimPathEditor (*this);
} }
bool CPrimPathEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimPathEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
bool ret = CPrimPath::read(xmlNode, filename, version, config); bool ret = CPrimPath::read(xmlNode, filename, version, config);
IPrimitiveEditor::postReadCallback(this); IPrimitiveEditor::postReadCallback(this);
return ret; return ret;
} }
void CPrimPathEditor::write (xmlNodePtr xmlNode, const char *filename) const void CPrimPathEditor::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
IPrimitiveEditor::preWriteCallback(this); IPrimitiveEditor::preWriteCallback(this);
CPrimPath::write(xmlNode, filename); CPrimPath::write(xmlNode, filename);
@ -825,14 +825,14 @@ IPrimitive *CPrimZoneEditor::copy () const
return new CPrimZoneEditor (*this); return new CPrimZoneEditor (*this);
} }
bool CPrimZoneEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimZoneEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
bool ret = CPrimZone::read(xmlNode, filename, version, config); bool ret = CPrimZone::read(xmlNode, filename, version, config);
IPrimitiveEditor::postReadCallback(this); IPrimitiveEditor::postReadCallback(this);
return ret; return ret;
} }
void CPrimZoneEditor::write (xmlNodePtr xmlNode, const char *filename) const void CPrimZoneEditor::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
IPrimitiveEditor::preWriteCallback(this); IPrimitiveEditor::preWriteCallback(this);
CPrimZone::write(xmlNode, filename); CPrimZone::write(xmlNode, filename);
@ -857,14 +857,14 @@ NLLIGO::IPrimitive *CPrimAliasEditor::copy () const
return new CPrimAliasEditor(*this); return new CPrimAliasEditor(*this);
} }
bool CPrimAliasEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) bool CPrimAliasEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config)
{ {
bool ret = CPrimAlias::read(xmlNode, filename, version, config); bool ret = CPrimAlias::read(xmlNode, filename, version, config);
IPrimitiveEditor::postReadCallback(this); IPrimitiveEditor::postReadCallback(this);
return ret; return ret;
} }
void CPrimAliasEditor::write (xmlNodePtr xmlNode, const char *filename) const void CPrimAliasEditor::write (xmlNodePtr xmlNode, const std::string &filename) const
{ {
IPrimitiveEditor::preWriteCallback(this); IPrimitiveEditor::preWriteCallback(this);
CPrimAlias::write(xmlNode, filename); CPrimAlias::write(xmlNode, filename);

View file

@ -248,9 +248,9 @@ public:
// From IPrimitive // From IPrimitive
virtual NLLIGO::IPrimitive *copy () const; virtual NLLIGO::IPrimitive *copy () const;
// Read the primitive, to post call the CPrimitiveEditor load method // Read the primitive, to post call the CPrimitiveEditor load method
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config);
// Write the primitive, to pre call the CPrimitiveEditor load method // Write the primitive, to pre call the CPrimitiveEditor load method
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading
virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const;
@ -293,9 +293,9 @@ public:
// From IClassable // From IClassable
virtual NLLIGO::IPrimitive *copy () const; virtual NLLIGO::IPrimitive *copy () const;
// Read the primitive, to post call the CPrimitiveEditor load method // Read the primitive, to post call the CPrimitiveEditor load method
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config);
// Write the primitive, to pre call the CPrimitiveEditor load method // Write the primitive, to pre call the CPrimitiveEditor load method
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading
virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const;
@ -338,9 +338,9 @@ public:
// From IPrimitive // From IPrimitive
virtual NLLIGO::IPrimitive *copy () const; virtual NLLIGO::IPrimitive *copy () const;
// Read the primitive, to post call the CPrimitiveEditor load method // Read the primitive, to post call the CPrimitiveEditor load method
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config);
// Write the primitive, to pre call the CPrimitiveEditor load method // Write the primitive, to pre call the CPrimitiveEditor load method
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading
virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const;
@ -385,9 +385,9 @@ public:
// From IPrimitive // From IPrimitive
virtual NLLIGO::IPrimitive *copy () const; virtual NLLIGO::IPrimitive *copy () const;
// Read the primitive, to post call the CPrimitiveEditor load method // Read the primitive, to post call the CPrimitiveEditor load method
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config);
// Write the primitive, to pre call the CPrimitiveEditor load method // Write the primitive, to pre call the CPrimitiveEditor load method
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading
virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const;
@ -430,9 +430,9 @@ public:
// From IPrimitive // From IPrimitive
virtual NLLIGO::IPrimitive *copy () const; virtual NLLIGO::IPrimitive *copy () const;
// Read the primitive, to post call the CPrimitiveEditor load method // Read the primitive, to post call the CPrimitiveEditor load method
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config);
// Write the primitive, to pre call the CPrimitiveEditor load method // Write the primitive, to pre call the CPrimitiveEditor load method
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading
virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const;