00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef BES_STRING_H
00022 #define BES_STRING_H
00023
00024 #include <algorithm>
00025 #include <string>
00026 #include <cctype>
00027 #include <strings.h>
00028
00029 namespace bes {
00030 namespace String {
00031
00032
00033
00034
00035 inline void lowerCh(char& c) { c = tolower(c); }
00036 inline void upperCh(char& c) { c = toupper(c); }
00037
00038 inline void transformToLower(std::string& str) {
00039 std::for_each(str.begin(), str.end(), lowerCh);
00040 }
00041 inline void transformToUpper(std::string& str) {
00042 std::for_each(str.begin(), str.end(), upperCh);
00043 }
00044
00045 std::string toLower(const std::string& str);
00046 std::string toUpper(const std::string& str);
00047
00048
00049
00050
00051
00052
00053
00054
00055 int compare_nocase(const std::string& s, const std::string& s2);
00056 inline int compare_nocase(const std::string& s, const char* s2) {
00057 return strcasecmp(s.c_str(), s2);
00058 }
00059
00060
00061
00062 int find_nocase(const std::string& s, const std::string& s2);
00063 inline int find_nocase(const std::string& s, const char* s2) {
00064 return find_nocase(s,std::string(s2));
00065 }
00066
00067
00068
00069 unsigned int rwHash(const std::string& str);
00070
00071 }
00072 }
00073
00074 #endif
00075
00076