MySQL++ Reference Manual

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

# string_util.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005 /***********************************************************************
    00006  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
    00007  MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
    00008  Others may also hold copyrights on code in this file.  See the CREDITS
    00009  file in the top directory of the distribution for details.
    00010
    00011  This file is part of MySQL++.
    00012
    00013  MySQL++ is free software; you can redistribute it and/or modify it
    00014  under the terms of the GNU Lesser General Public License as published
    00015  by the Free Software Foundation; either version 2.1 of the License, or
    00016  (at your option) any later version.
    00017
    00018  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00019  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00020  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00021  License for more details.
    00022
    00023  You should have received a copy of the GNU Lesser General Public
    00024  License along with MySQL++; if not, write to the Free Software
    00025  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00026  USA
    00027 ***********************************************************************/
    00028
    00029 #ifndef MYSQLPP_STRING_UTIL_H
    00030 #define MYSQLPP_STRING_UTIL_H
    00031
    00032 #include "defs.h"
    00033
    00034 #include <ctype.h>
    00035
    00036 #include <string>
    00037
    00038 namespace mysqlpp {
    00039
    00041 MYSQLPP_EXPORT extern void strip(std::string& s);
    00042
    00044 MYSQLPP_EXPORT extern void escape_string(std::string& s);
    00045
    00047 MYSQLPP_EXPORT inline void str_to_upr(std::string& s)
    00048 {
    00049         for (unsigned int cnt=0; cnt < s.length(); cnt++) {
    00050                 char c = s[cnt]; s[cnt]=toupper(c);
    00051         }
    00052 }
    00053
    00055 MYSQLPP_EXPORT inline void str_to_lwr (std::string& s)
    00056 {
    00057         for (unsigned int cnt=0; cnt < s.length(); cnt++) {
    00058                 char c = s[cnt]; s[cnt]=tolower(c);
    00059         }
    00060 }
    00061
    00063 MYSQLPP_EXPORT inline void strip_all_blanks (std::string& s)
    00064 {
    00065         for (unsigned int counter=0;counter < s.size();counter++)
    00066                 if (s[counter] == ' ') { s.erase(counter,1); counter--;}
    00067 }
    00068
    00070 MYSQLPP_EXPORT inline void strip_all_non_num (std::string& s)
    00071 {
    00072         for (unsigned int counter=0;counter < s.size();counter++)
    00073                 if (!isdigit(s[counter])) { s.erase(counter,1); counter--;}
    00074 }
    00075
    00076 } // end namespace mysqlpp
    00077
    00078 #endif
    00079