Salome HOME
- Changed tests to use Python (for portability)
[tools/libbatch.git] / src / Core / Test / SimpleParser.cxx
index 7769aaaf92d6f008ed59883ab42adc3c73b749aa..e40a56bf8c96035c1e18e1ff4d0a1300a33fa0c8 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -128,6 +128,21 @@ const string & SimpleParser::getValue(const string & key) const throw(ParserExce
   return iter->second;
 }
 
+const string & SimpleParser::getTestValue(const string & bmType, const string & protocolStr,
+                                          const string & key) const throw(ParserException)
+{
+  string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
+  try {
+    return getValue(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + bmType + "_" + key;
+  try {
+    return getValue(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + key;
+  return getValue(fullkey);
+}
+
 int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
 {
   const string & valueStr = getValue(key);
@@ -140,6 +155,21 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
   return res;
 }
 
+int SimpleParser::getTestValueAsInt(const string & bmType, const string & protocolStr,
+                                    const string & key) const throw(ParserException)
+{
+  string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
+  try {
+    return getValueAsInt(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + bmType + "_" + key;
+  try {
+    return getValueAsInt(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + key;
+  return getValueAsInt(fullkey);
+}
+
 ostream & operator <<(ostream & os, const SimpleParser & parser) throw()
 {
   if (parser._configmap.empty()) {