bugfix: add correct handling for metric line end for example file.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/502/head
Kim Kulling 2014-11-02 20:30:45 +01:00
parent 1a5695ff48
commit dbf9536213
3 changed files with 23 additions and 9 deletions

1
.gitignore vendored
View File

@ -47,3 +47,4 @@ test/gtest/src/gtest-stamp/gtest-build.cmake
test/gtest/src/gtest-stamp/Debug/gtest-patch test/gtest/src/gtest-stamp/Debug/gtest-patch
*.cache *.cache
test/gtest/src/gtest-stamp/Debug/gtest-build test/gtest/src/gtest-stamp/Debug/gtest-build
*.lib

View File

@ -189,6 +189,17 @@ bool OpenGEXParser::skipComments() {
return skipped; return skipped;
} }
//------------------------------------------------------------------------------------------------
void OpenGEXParser::readUntilEndOfLine() {
while( !IsLineEnd( m_buffer[ m_index ] ) ) {
++m_index;
}
++m_index;
if( IsLineEnd( m_buffer[ m_index ] ) ) {
++m_index;
}
}
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
bool OpenGEXParser::parseNextNode() { bool OpenGEXParser::parseNextNode() {
std::string token( getNextToken() ); std::string token( getNextToken() );
@ -203,7 +214,10 @@ bool OpenGEXParser::parseNextNode() {
return false; return false;
} }
readUntilEndOfLine();
m_nodeTypeStack.pop_back(); m_nodeTypeStack.pop_back();
} }
return true; return true;
@ -329,21 +343,19 @@ bool OpenGEXParser::getMetricAttributeKey( std::string &attribName ) {
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
bool OpenGEXParser::onMetricNode( const std::string &attribName ) { bool OpenGEXParser::onMetricNode( const std::string &attribName ) {
float value( 0.0f );
bool success( true ); bool success( true );
if( "distance" == attribName ) { if( "distance" == attribName ) {
float distance( 0.0f ); if( getFloatData( 1, &value ) ) {
if( getFloatData( 1, &distance ) ) { m_model.m_metrics.m_distance = value;
m_model.m_metrics.m_distance = distance;
} }
} else if( "angle" == attribName ) { } else if( "angle" == attribName ) {
float angle( 0.0f ); if( getFloatData( 1, &value ) ) {
if( getFloatData( 1, &angle ) ) { m_model.m_metrics.m_angle = value;
m_model.m_metrics.m_angle = angle;
} }
} else if( "time" == attribName ) { } else if( "time" == attribName ) {
float time( 0.0f ); if( getFloatData( 1, &value ) ) {
if( getFloatData( 1, &time ) ) { m_model.m_metrics.m_time = value;
m_model.m_metrics.m_time = time;
} }
} else if( "up" == attribName ) { } else if( "up" == attribName ) {
std::string up; std::string up;

View File

@ -87,6 +87,7 @@ public:
protected: protected:
std::string getNextToken(); std::string getNextToken();
bool skipComments(); bool skipComments();
void readUntilEndOfLine();
bool parseNextNode(); bool parseNextNode();
bool getNodeHeader( std::string &name ); bool getNodeHeader( std::string &name );
bool getBracketOpen(); bool getBracketOpen();