Main Page   Namespace List   File List   File Members  

libstring.h

Go to the documentation of this file.
00001 // Copyright (C) 2001 Kevin Duffy <kevin@buhbird.com>
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License, or (at your option) any later version.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 // Copyright (C) 2001 Kevin Duffy <kevin@buhbird.com>
00017 #ifndef STRINGLIB_H
00018 #define STRINGLIB_H
00019 
00020 #include <string>
00021 #include <stl_pair.h>
00022 using namespace std;
00023 
00025 bool CompareNoCase(const string& string1, const string& string2);
00026 
00028 string ToUpper(string::iterator start, string::iterator stop);
00029 string ToLower(string::iterator start, string::iterator stop);
00030 
00032 int   ParseInt  (const string& string1);
00033 float ParseFloat(const string& string1);
00034 
00036 int   stoi(const string& rhs);
00037 float stof(const string& rhs);
00038 
00040 string ReadFile(string& strIn, const string& filename);
00041 string ReadFile(string& strIn, istream& is);
00042 
00044 string itos(const int n);
00045 string ftos(const double n, const int precision = 4);
00046 
00048 string EatWhite(string::iterator start, string::iterator stop);
00049 
00051 string Trim (string::iterator start, string::iterator stop);
00052 string RTrim(string::iterator start, string::iterator stop);
00053 string LTrim(string::iterator start, string::iterator stop);
00054 
00056 pair<string, string> 
00057 Split(const string& strIn, const string& delim);
00058 
00060 string Space(size_t n = 1);
00061 
00063 bool IsAllSpace(string::iterator start, string::iterator stop);
00064 
00066 template <class List>
00067 List GetListItems(const string& strList,
00068                   const string& delimiter = string(", "))
00069 {
00070    List tempList;
00071    char* charList = const_cast<char*>(strList.c_str()),
00072        * temp;
00073    const char* delim = delimiter.c_str();
00074 
00075    // get first token
00076    temp = strtok(charList, delim);
00077    if (!temp)
00078       return tempList;
00079 
00080    tempList.push_back(temp);
00081    while ((temp = strtok(NULL, delim)) != 0)
00082       tempList.push_back(temp);
00083 
00084    return tempList;
00085 } 
00086 #endif

Generated at Thu Apr 5 22:00:05 2001 for libstring by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001