]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/Constants.cpp
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / DataBoard / Constants.cpp
diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/Constants.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/Constants.cpp
new file mode 100644 (file)
index 0000000..bcff2bc
--- /dev/null
@@ -0,0 +1,68 @@
+#include "Constants.h"\r
+\r
+#include <iostream>\r
+\r
+namespace Databoard {\r
+\r
+       void printout(pANTLR3_BASE_TREE type)\r
+       {\r
+               std::cout << type->getText(type)->chars << " : " << type->getType(type) << std::endl;\r
+       }\r
+\r
+       std::string removeQuotes(std::string str)\r
+       {\r
+               if(str.length() > 0)\r
+               {\r
+                       if(str.at(0) == '"')\r
+                       {\r
+                               str = str.substr(1, str.length()-1);\r
+                       }\r
+               }\r
+\r
+               if(str.length() > 0)\r
+               {\r
+                       if(str.at(str.length()-1) == '"')\r
+                       {\r
+                               str = str.substr(0, str.length()-1);\r
+                       }\r
+               }\r
+\r
+               return str;\r
+       }\r
+\r
+       bool strEquals(const char* a, const char* b)\r
+       {\r
+               while(*a != '\0' && *b != '\0')\r
+               {\r
+                       char c1 = *a;\r
+                       char c2 = *b;\r
+\r
+                       if(c1 >= 'a' && c1 <= 'z')\r
+                       {\r
+                               c1 += 'A'-'a';\r
+                       }\r
+\r
+                       if(c2 >= 'a' && c2 <= 'z')\r
+                       {\r
+                               c2 += 'A'-'a';\r
+                       }\r
+\r
+                       if(c1 != c2)\r
+                       {\r
+                               return false;\r
+                       }\r
+\r
+                       ++a;\r
+                       ++b;\r
+               }\r
+\r
+               if((*a == *b) && (*a == 0))\r
+               {\r
+                       return true;\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
+       }\r
+}\r