Hosting courtesy of Sourceforge

SourceForge Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

StringUtil.cpp

Go to the documentation of this file.
00001 //
00002 //      Copyright (C) 2002 Robert Renaud
00003 //
00004 //      This program is free software; you can redistribute it and/or
00005 //      modify it under the terms of the GNU General Public License
00006 //      as published by the Free Software Foundation; either version 2
00007 //      of the License, or (at your option) any later version.
00008 //
00009 //      This program is distributed in the hope that it will be useful,
00010 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 //
00013 //      See the GNU General Public License for more details.
00014 //
00015 //      You should have received a copy of the GNU General Public License
00016 //      along with this program; if not, write to the Free Software
00017 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 
00020 #include "StringUtil.h"
00021 
00022 string Util::getNextIdentifier(istream &input, set<char> &terminatingSet) {
00023         char currentChar;
00024         string identifier;
00025         while (!input.eof()) {
00026                 currentChar = input.get();
00027                  // found a terminating char
00028                 if (terminatingSet.find(currentChar) != terminatingSet.end()) { 
00029                    // put the char back in input so the caller can see what caused exit                                         
00030                         input.putback(currentChar); 
00031                         return identifier;
00032                 } else {  // if no termination chars were inputted
00033                         identifier += currentChar;
00034                 }
00035         }
00036         return identifier;
00037 } 
00038 
00039 void Util::makeLowercase(string& str) {
00040         for (size_t i = 0; i < str.size(); i++) {
00041                 str[i] = tolower(str[i]);
00042         }
00043 }
00044 
00045 void Util::eraseSpaces(string& str) {
00046         for (size_t i = 0; i < str.size(); i++) {
00047                 if (' ' == str[i]) str.erase(i, 1);
00048         }
00049 }
00050 

Generated on Tue May 21 07:26:51 2002 for BomberLAN by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001