1 |
gezelter |
1590 |
/** |
2 |
|
|
* @file StringUtils.hpp |
3 |
|
|
* @author Dan Gezelter |
4 |
|
|
* @date 10/18/2004 |
5 |
|
|
* @version 1.0 |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef UTILS_STRINGUTILS_HPP |
9 |
|
|
#define UTILS_STRINGUTILS_HPP |
10 |
gezelter |
1490 |
#include <string> |
11 |
gezelter |
1590 |
#include <iostream> |
12 |
|
|
#include <fstream> |
13 |
tim |
1805 |
#include <sstream> |
14 |
gezelter |
1490 |
|
15 |
gezelter |
1590 |
namespace oopse { |
16 |
gezelter |
1490 |
|
17 |
gezelter |
1590 |
using namespace std; |
18 |
|
|
|
19 |
|
|
|
20 |
|
|
/** |
21 |
|
|
* Converts a string to UPPER CASE |
22 |
|
|
* @param S |
23 |
|
|
*/ |
24 |
|
|
string UpperCase(const string& S); |
25 |
|
|
|
26 |
|
|
/** |
27 |
|
|
* Converts a string to lower case |
28 |
|
|
* @param S |
29 |
|
|
*/ |
30 |
|
|
string LowerCase(const string& S); |
31 |
|
|
|
32 |
|
|
/** |
33 |
chrisfen |
1598 |
* Removes left and right spaces from a string |
34 |
|
|
* |
35 |
|
|
* @param str String to trim |
36 |
|
|
* |
37 |
|
|
* @return char* to the trimed string |
38 |
|
|
*/ |
39 |
|
|
char* trimSpaces(char *str); |
40 |
|
|
|
41 |
|
|
/** |
42 |
gezelter |
1590 |
* Finds the location of the string "begin <startText>" in an input stream. |
43 |
|
|
* @param theStream |
44 |
|
|
* @param startText |
45 |
|
|
* |
46 |
|
|
* @return the line number of the block within the theStream |
47 |
|
|
*/ |
48 |
chrisfen |
1598 |
int findBegin(istream &theStream, char* startText ); |
49 |
gezelter |
1590 |
|
50 |
|
|
/** |
51 |
|
|
* Counts the number of tokens on line which are delimited by the characters |
52 |
|
|
* listed in delimiters |
53 |
|
|
* @param line |
54 |
|
|
* @param delimiters |
55 |
|
|
*/ |
56 |
|
|
int countTokens(char *line, char *delimiters); |
57 |
|
|
|
58 |
|
|
/** |
59 |
|
|
* discovers whether or not the line contains the "end" token |
60 |
|
|
* |
61 |
|
|
* @param line The line to test |
62 |
|
|
* |
63 |
|
|
* @return int (==1 if the line has "end", ==0 if not). |
64 |
|
|
*/ |
65 |
|
|
int isEndLine(char *line); |
66 |
tim |
1792 |
|
67 |
tim |
1805 |
|
68 |
|
|
/** |
69 |
|
|
* Convert a variable to a string |
70 |
|
|
* @param T data type |
71 |
|
|
* @param v data to be converted |
72 |
|
|
* @return a string |
73 |
|
|
*/ |
74 |
|
|
template<typename T> |
75 |
|
|
std::string toString(const T& v) { |
76 |
|
|
std::ostringstream oss; |
77 |
|
|
T result; |
78 |
|
|
|
79 |
|
|
oss << v; |
80 |
|
|
return oss.str(); |
81 |
|
|
} |
82 |
tim |
1807 |
|
83 |
|
|
/**@todo need implementation */ |
84 |
|
|
std::string getPrefix(const std::string& str); |
85 |
|
|
|
86 |
|
|
/**@todo need implementation */ |
87 |
|
|
std::string getSuffix(const std::string& str); |
88 |
tim |
1805 |
|
89 |
gezelter |
1590 |
} |
90 |
|
|
|
91 |
gezelter |
1490 |
#endif |