ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/utils/StringUtils.hpp
Revision: 1807
Committed: Tue Nov 30 22:43:51 2004 UTC (19 years, 8 months ago) by tim
File size: 1825 byte(s)
Log Message:
brains get built

File Contents

# Content
1 /**
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 #include <string>
11 #include <iostream>
12 #include <fstream>
13 #include <sstream>
14
15 namespace oopse {
16
17 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 * 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 * 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 int findBegin(istream &theStream, char* startText );
49
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
67
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
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
89 }
90
91 #endif