[opengtl-commits] [637] parse negative values in metadata

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 637
Author:   cyrille
Date:     2009-03-16 17:21:45 +0100 (Mon, 16 Mar 2009)

Log Message:
-----------
parse negative values in metadata

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
    trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp	2009-03-16 15:41:36 UTC (rev 636)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp	2009-03-16 16:21:45 UTC (rev 637)
@@ -54,6 +54,7 @@
   } else if( lastChar == '"' ) {
     return getString(lastChar);
   } else {
+    CHAR_IS_TOKEN('-', MINUS );
     CHAR_IS_TOKEN(';', SEMI );
     CHAR_IS_TOKEN(':', COLON );
     CHAR_IS_TOKEN('<', INFERIOR );

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2009-03-16 15:41:36 UTC (rev 636)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2009-03-16 16:21:45 UTC (rev 637)
@@ -229,12 +229,28 @@
 {
   GTL_DEBUG( "parseValueEntry" );
   GTLCore::Value val;
+  bool neg = false;
+  if( currentToken().type == GTLCore::Token::MINUS )
+  {
+    neg = true;
+    getNextToken();
+  }
   if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
   {
-    val.setFloat( currentToken().f );
+    if(neg)
+    {
+      val.setFloat( -currentToken().f );
+    } else {
+      val.setFloat( currentToken().f );
+    }
   } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
   {
-    val.setInt32( currentToken().i );
+    if(neg)
+    {
+      val.setInt32( -currentToken().i );
+    } else {
+      val.setInt32( currentToken().i );
+    }
   } else if( currentToken().type == GTLCore::Token::STARTBRACE )
   {
     val = parseCoumpoundValue();

Modified: trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2009-03-16 15:41:36 UTC (rev 636)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2009-03-16 16:21:45 UTC (rev 637)
@@ -58,7 +58,7 @@
   parameters: < \
     param1: < \
       type: int; \
-      minValue: 0; \
+      minValue:-10; \
       maxValue: 100; \
       defaultValue: 50; \
       description: \"This is the first parameter\"; \
@@ -98,8 +98,8 @@
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( param1->entry( "type" ), "int");
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( param1->entry( "description" ), "This is the first parameter");
       GTLTEST_CHECK_EQUAL( param1->description(), "This is the first parameter");
-      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "minValue" ), 0);
-      GTLTEST_CHECK_EQUAL( param1->minimumValue(), 0);
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "minValue" ), -10);
+      GTLTEST_CHECK_EQUAL( param1->minimumValue(), -10);
       TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "defaultValue" ), 50);
       GTLTEST_CHECK_EQUAL( param1->defaultValue(), 50);
       TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "maxValue" ), 100);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/