| 1 |
|
#include "utils/StringUtils.hpp" |
| 2 |
|
|
| 3 |
< |
using namespace std; |
| 4 |
< |
using namespace oopse; |
| 5 |
< |
|
| 6 |
< |
string UpperCase(const string& S) { |
| 7 |
< |
string uc = S; |
| 3 |
> |
namespace oopse { |
| 4 |
> |
std::string UpperCase(const std::string& S) { |
| 5 |
> |
std::string uc = S; |
| 6 |
|
unsigned int n = uc.size(); |
| 7 |
|
for (unsigned int j = 0; j < n; j++) { |
| 8 |
|
char sj = uc[j]; |
| 11 |
|
return uc; |
| 12 |
|
} |
| 13 |
|
|
| 14 |
< |
string LowerCase(const string& S) { |
| 15 |
< |
string lc = S; |
| 14 |
> |
std::string LowerCase(const std::string& S) { |
| 15 |
> |
std::string lc = S; |
| 16 |
|
unsigned int n = lc.size(); |
| 17 |
|
for (unsigned int j = 0; j < n; j++) { |
| 18 |
|
char sj = lc[j]; |
| 49 |
|
return (str); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
< |
int findBegin(istream &theStream, char* startText ){ |
| 52 |
> |
int findBegin(std::istream &theStream, char* startText ){ |
| 53 |
|
const int MAXLEN = 1024; |
| 54 |
|
char readLine[MAXLEN]; |
| 55 |
|
int foundText = 0; |
| 58 |
|
char* eof_test; |
| 59 |
|
|
| 60 |
|
// rewind the stream |
| 61 |
< |
theStream.seekg (0, ios::beg); |
| 61 |
> |
theStream.seekg (0, std::ios::beg); |
| 62 |
|
lineNum = 0; |
| 63 |
|
|
| 64 |
|
if (!theStream.eof()) { |
| 79 |
|
|
| 80 |
|
the_token = strtok( readLine, " ,;\t" ); |
| 81 |
|
if ( the_token != NULL) |
| 82 |
< |
if (!strcmp("begin", the_token)) { |
| 82 |
> |
if (!strcasecmp("begin", the_token)) { |
| 83 |
|
the_token = strtok( NULL, " ,;\t" ); |
| 84 |
|
if ( the_token != NULL){ |
| 85 |
< |
foundText = !strcmp( startText, the_token ); |
| 85 |
> |
foundText = !strcasecmp( startText, the_token ); |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
| 128 |
|
|
| 129 |
|
foo = strtok(working_line, " ,;\t"); |
| 130 |
|
|
| 131 |
< |
if (!strcasecmp(foo, "end")) return 1; |
| 131 |
> |
if (foo != NULL) { |
| 132 |
> |
|
| 133 |
> |
if (!strcasecmp(foo, "end")) return 1; |
| 134 |
> |
|
| 135 |
> |
} |
| 136 |
|
|
| 137 |
|
return 0; |
| 138 |
|
} |
| 139 |
+ |
|
| 140 |
+ |
|
| 141 |
+ |
std::string getPrefix(const std::string& str) { |
| 142 |
+ |
return str.substr(0, str.rfind('.')); |
| 143 |
+ |
} |
| 144 |
+ |
|
| 145 |
+ |
std::string getSuffix(const std::string& str) { |
| 146 |
+ |
return str.substr(0, str.find('.')); |
| 147 |
+ |
} |
| 148 |
+ |
|
| 149 |
+ |
} |