ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/utils/StringUtils.hpp
Revision: 1824
Committed: Thu Dec 2 03:12:25 2004 UTC (19 years, 9 months ago) by tim
File size: 1826 byte(s)
Log Message:
replace misuse of using namespace std in header files

File Contents

# User Rev Content
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    
17    
18     /**
19     * Converts a string to UPPER CASE
20     * @param S
21     */
22 tim 1824 std::string UpperCase(const std::string& S);
23 gezelter 1590
24     /**
25     * Converts a string to lower case
26     * @param S
27     */
28 tim 1824 std::string LowerCase(const std::string& S);
29 gezelter 1590
30     /**
31 chrisfen 1598 * 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 gezelter 1590 * 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 tim 1824 int findBegin(std::istream &theStream, char* startText );
47 gezelter 1590
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 tim 1792
65 tim 1805
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 tim 1807
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 tim 1805
87 gezelter 1590 }
88    
89 gezelter 1490 #endif