diff --git a/ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.cpp b/ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.cpp index 426592ed17..0984889be9 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.cpp @@ -41,8 +41,6 @@ void RicfFieldReader::readFieldData(QString& fieldValue, QTextStream& i if ( currentChar == QChar('"') ) // End Quote { // Reached end of string - // Read and eat , or ) ? - break; } else diff --git a/ApplicationCode/CommandFileInterface/Core/RicfObjectCapability.cpp b/ApplicationCode/CommandFileInterface/Core/RicfObjectCapability.cpp index 8977542b84..78f9ba57ba 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfObjectCapability.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RicfObjectCapability.cpp @@ -59,7 +59,21 @@ void RicfObjectCapability::readFields(QTextStream& inputStream, caf::PdmObjectFa { QChar currentChar; inputStream >> currentChar; - if ( currentChar.isSpace() || currentChar == QChar('=') ) + if ( currentChar.isSpace() ) + { + // Must skip to, and read "=" + + inputStream.skipWhiteSpace(); + inputStream >> currentChar; + + if ( currentChar != QChar('=') ) + { + // Error message: Missing "=" after argument name + } + break; + } + + if ( currentChar == QChar('=') ) { break; } diff --git a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp index 7c0cc2ffa8..1b9f186a00 100644 --- a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp +++ b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp @@ -27,37 +27,63 @@ public: CAF_PDM_SOURCE_INIT(TestCommand1, "TestCommand1"); +class TC2: public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; +public: + TC2() + { + RICF_InitField(&m_textArgument, "ta", QString(), "TextArgument", "", "", ""); + RICF_InitField(&m_doubleArgument, "da", 0.0, "DoubleArgument", "", "", ""); + RICF_InitField(&m_intArgument, "ia", 0,"IntArgument", "", "", ""); + } + + virtual void execute() override { std::cout << "TC2::execute(" << "\"" << m_textArgument().toStdString() << "\", " + << m_doubleArgument() << ", " + << m_intArgument << ");" << std::endl; } + + caf::PdmField m_textArgument; + caf::PdmField m_doubleArgument; + caf::PdmField m_intArgument; +}; + +CAF_PDM_SOURCE_INIT(TC2, "TC2"); + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(RicfCommands, Test1) { - TestCommand1* tc = new TestCommand1; - tc->m_textArgument = "textValue"; - tc->execute(); - delete tc; - QString commandString("TestCommand1(IntArgument=3, TextArgument=\"Dette er en tekst, \\\"og\\\" jeg er: (happy)\", DoubleArgument=5.0e3) \n" "TestCommand1 ( IntArgument = 4 , \n TextArgument = \"Dette er en tekst, \\\"og\\\" jeg er: (happy)\", \n DoubleArgument = 5.0e-3 ) \n" - " TestCommand1(TextArgument=\"Litt kortere tekst.\") \n"); - std::cout << commandString.toStdString() << std::endl; + " TestCommand1(TextArgument=\"Litt kortere tekst.\") \n" + "TC2 ( ta = \"Hepp\", ia = 3, da= 0.123)"); + + //std::cout << commandString.toStdString() << std::endl; + QTextStream inputStream(&commandString); auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance()); - EXPECT_EQ(3, objects.size()); + EXPECT_EQ(4, objects.size()); auto tc2 = dynamic_cast(objects[0]); EXPECT_EQ(39, tc2->m_textArgument().size()); EXPECT_EQ(5.0e3, tc2->m_doubleArgument()); - + tc2 = dynamic_cast(objects[1]); - EXPECT_EQ(37, tc2->m_textArgument().size()); + EXPECT_EQ(39, tc2->m_textArgument().size()); EXPECT_EQ(5e-3, tc2->m_doubleArgument()); - + tc2 = dynamic_cast(objects[2]); EXPECT_EQ(19, tc2->m_textArgument().size()); EXPECT_EQ(0.0, tc2->m_doubleArgument()); + auto tc3 = dynamic_cast(objects[3]); + EXPECT_EQ(4, tc3->m_textArgument().size()); + EXPECT_EQ(0.123, tc3->m_doubleArgument()); + EXPECT_EQ(3, tc3->m_intArgument()); + for (auto obj: objects) { obj->execute();