]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/Constants.cpp
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / DataBoard / Constants.cpp
1 #include "Constants.h"
2
3 #include <iostream>
4
5 namespace Databoard {
6
7         void printout(pANTLR3_BASE_TREE type)
8         {
9                 std::cout << type->getText(type)->chars << " : " << type->getType(type) << std::endl;
10         }
11
12         std::string removeQuotes(std::string str)
13         {
14                 if(str.length() > 0)
15                 {
16                         if(str.at(0) == '"')
17                         {
18                                 str = str.substr(1, str.length()-1);
19                         }
20                 }
21
22                 if(str.length() > 0)
23                 {
24                         if(str.at(str.length()-1) == '"')
25                         {
26                                 str = str.substr(0, str.length()-1);
27                         }
28                 }
29
30                 return str;
31         }
32
33         bool strEquals(const char* a, const char* b)
34         {
35                 while(*a != '\0' && *b != '\0')
36                 {
37                         char c1 = *a;
38                         char c2 = *b;
39
40                         if(c1 >= 'a' && c1 <= 'z')
41                         {
42                                 c1 += 'A'-'a';
43                         }
44
45                         if(c2 >= 'a' && c2 <= 'z')
46                         {
47                                 c2 += 'A'-'a';
48                         }
49
50                         if(c1 != c2)
51                         {
52                                 return false;
53                         }
54
55                         ++a;
56                         ++b;
57                 }
58
59                 if((*a == *b) && (*a == 0))
60                 {
61                         return true;
62                 }
63                 else
64                 {
65                         return false;
66                 }
67         }
68 }