45 using std::istringstream;
61 while (i <
static_cast<int>(source.size()) && isspace(source[i])) {
64 result = source.substr(i);
66 i = result.size() - 1;
67 while (i >= 0 && isspace(result[i])) {
70 result = result.substr(0, i+1);
84 char* ch =
new char[source.size() + 1];
85 copy(source.begin(), source.end(), ch);
86 ch[source.size()] = 0;
102 const std::string& source,
104 bool caseSensitive) {
106 string::size_type pos = 0;
107 if (!caseSensitive) {
108 char upC = toupper(ch);
110 pos = upString.find(upC, 0);
112 pos = source.find(ch, 0);
115 return pos != string::npos;
127 const std::string& source,
128 const std::string& searchString) {
130 return source.size() >= searchString.size() &&
132 source.size() - searchString.size(), searchString.size()) ==
145 upString.reserve(source.length());
146 for (
unsigned int i = 0; i < source.length(); ++i) {
147 upString.push_back(toupper(source[i]));
163 lowString.reserve(source.length());
164 for (
unsigned int i = 0; i < source.length(); ++i) {
165 lowString.push_back(tolower(source[i]));
182 const std::string& source,
183 const std::string& delimiter) {
185 string line =
trim(source);
186 vector<TCEString> results;
187 while (line.length() > 0) {
188 string::size_type location = line.find(delimiter);
189 if (location == string::npos) {
190 results.push_back(line);
193 results.push_back(line.substr(0, location));
194 line.replace(0, location + 1,
"");
213 const std::string& source,
214 const std::string& delimiter,
215 std::vector<std::string>& results) {
217 string line =
trim(source);
218 while (line.length() > 0) {
219 string::size_type location = line.find(delimiter);
220 if (location == string::npos) {
221 results.push_back(line);
224 results.push_back(line.substr(0, location));
225 line.replace(0, location + 1,
"");
263 const std::string& original,
264 const unsigned int rowLength) {
266 if (rowLength == 0) {
270 unsigned int counter = 0;
271 string newString =
"";
273 while (counter < original.size()) {
274 newString += original.substr(counter, 1);
277 if (counter % rowLength == 0 && counter != original.size()) {
296 const std::string& source,
297 const std::string& occurrence,
298 const std::string& newString) {
300 std::string modifiedString(source);
301 std::string::size_type location = modifiedString.find(occurrence);
302 while (location != std::string::npos) {
303 modifiedString.replace(modifiedString.begin() + location,
304 modifiedString.begin() + location + occurrence.length(),
306 location = modifiedString.find(occurrence);
309 return modifiedString;
321 for (
int i = 0; i < level; i++) {