Added support for trimming the contents of parsed Xml graph

This commit is contained in:
Robert Osfield
2009-08-19 15:36:23 +00:00
parent f3c20310d6
commit 850ea3de9f
3 changed files with 49 additions and 21 deletions

View File

@@ -45,6 +45,20 @@ XmlNode* osgDB::readXmlFile(const std::string& filename,const Options* options)
}
}
std::string osgDB::trimEnclosingSpaces(const std::string& str)
{
if (str.empty()) return str;
std::string::size_type start = str.find_first_not_of(' ');
if (start==std::string::npos) return std::string();
std::string::size_type end = str.find_last_not_of(' ');
if (end==std::string::npos) return std::string();
return std::string(str, start, (end-start)+1);
}
XmlNode* osgDB::readXmlStream(std::istream& fin)
{
XmlNode::Input input;
@@ -120,7 +134,7 @@ void XmlNode::Input::readAllDataIntoBuffer()
void XmlNode::Input::skipWhiteSpace()
{
while(_currentPos<_buffer.size() && _buffer[_currentPos]==' ' || _buffer[_currentPos]=='\t' )
while(_currentPos<_buffer.size() && (_buffer[_currentPos]==' ' || _buffer[_currentPos]=='\t'))
{
// osg::notify(osg::NOTICE)<<"_currentPos="<<_currentPos<<"_buffer.size()="<<_buffer.size()<<" v="<<_buffer[_currentPos]<<std::endl;
++_currentPos;