00001 #ifndef MYSQLPP_STRING_UTIL_H
00002 #define MYSQLPP_STRING_UTIL_H
00003
00007
00008 #include "defs.h"
00009
00010 #include <ctype.h>
00011
00012 #include <string>
00013
00014 namespace mysqlpp {
00015
00017 extern void strip(std::string& s);
00018
00020 extern void escape_string(std::string& s);
00021
00023 inline void str_to_upr(std::string& s)
00024 {
00025 for (unsigned int cnt=0; cnt < s.length(); cnt++) {
00026 char c = s[cnt]; s[cnt]=toupper(c);
00027 }
00028 }
00029
00031 inline void str_to_lwr (std::string& s)
00032 {
00033 for (unsigned int cnt=0; cnt < s.length(); cnt++) {
00034 char c = s[cnt]; s[cnt]=tolower(c);
00035 }
00036 }
00037
00039 inline void strip_all_blanks (std::string& s)
00040 {
00041 for (unsigned int counter=0;counter < s.size();counter++)
00042 if (s[counter] == ' ') { s.erase(counter,1); counter--;}
00043 }
00044
00046 inline void strip_all_non_num (std::string& s)
00047 {
00048 for (unsigned int counter=0;counter < s.size();counter++)
00049 if (!isdigit(s[counter])) { s.erase(counter,1); counter--;}
00050 }
00051
00052 }
00053
00054 #endif
00055