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: 1824
Committed: Thu Dec 2 03:12:25 2004 UTC (19 years, 7 months ago) by tim
File size: 1826 byte(s)
Log Message:
replace misuse of using namespace std in header files

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
18 /**
19 * Converts a string to UPPER CASE
20 * @param S
21 */
22 std::string UpperCase(const std::string& S);
23
24 /**
25 * Converts a string to lower case
26 * @param S
27 */
28 std::string LowerCase(const std::string& S);
29
30 /**
31 * Removes left and right spaces from a string
32 *
33 * @param str String to trim
34 *
35 * @return char* to the trimed string
36 */
37 char* trimSpaces(char *str);
38
39 /**
40 * Finds the location of the string "begin <startText>" in an input stream.
41 * @param theStream
42 * @param startText
43 *
44 * @return the line number of the block within the theStream
45 */
46 int findBegin(std::istream &theStream, char* startText );
47
48 /**
49 * Counts the number of tokens on line which are delimited by the characters
50 * listed in delimiters
51 * @param line
52 * @param delimiters
53 */
54 int countTokens(char *line, char *delimiters);
55
56 /**
57 * discovers whether or not the line contains the "end" token
58 *
59 * @param line The line to test
60 *
61 * @return int (==1 if the line has "end", ==0 if not).
62 */
63 int isEndLine(char *line);
64
65
66 /**
67 * Convert a variable to a string
68 * @param T data type
69 * @param v data to be converted
70 * @return a string
71 */
72 template<typename T>
73 std::string toString(const T& v) {
74 std::ostringstream oss;
75 T result;
76
77 oss << v;
78 return oss.str();
79 }
80
81 /**@todo need implementation */
82 std::string getPrefix(const std::string& str);
83
84 /**@todo need implementation */
85 std::string getSuffix(const std::string& str);
86
87 }
88
89 #endif