- Main Page
- Classes
- Files

- File List
- File Members

# field_names.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004 /***********************************************************************
    00005  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
    00006  (c) 2004-2008 by Educational Technology Resources, Inc.  Others may
    00007  also hold copyrights on code in this file.  See the CREDITS file in
    00008  the top directory of the distribution for details.
    00009
    00010  This file is part of MySQL++.
    00011
    00012  MySQL++ is free software; you can redistribute it and/or modify it
    00013  under the terms of the GNU Lesser General Public License as published
    00014  by the Free Software Foundation; either version 2.1 of the License, or
    00015  (at your option) any later version.
    00016
    00017  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00018  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00019  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00020  License for more details.
    00021
    00022  You should have received a copy of the GNU Lesser General Public
    00023  License along with MySQL++; if not, write to the Free Software
    00024  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00025  USA
    00026 ***********************************************************************/
    00027
    00028 #ifndef MYSQLPP_FIELD_NAMES_H
    00029 #define MYSQLPP_FIELD_NAMES_H
    00030
    00031 #include <string>
    00032 #include <vector>
    00033
    00034 #include <ctype.h>
    00035
    00036 namespace mysqlpp {
    00037
    00038 #if !defined(DOXYGEN_IGNORE)
    00039 // Make Doxygen ignore this
    00040 class MYSQLPP_EXPORT ResultBase;
    00041 #endif
    00042
    00044 class FieldNames : public std::vector<std::string>
    00045 {
    00046 public:
    00048         FieldNames() { }
    00049
    00051         FieldNames(const FieldNames& other) :
    00052         std::vector<std::string>()
    00053         {
    00054                 assign(other.begin(), other.end());
    00055         }
    00056
    00058         FieldNames(const ResultBase* res) :
    00059         std::vector<std::string>()
    00060         {
    00061                 init(res);
    00062         }
    00063
    00066         FieldNames(int i) :
    00067         std::vector<std::string>(i)
    00068         {
    00069         }
    00070
    00072         FieldNames& operator =(const ResultBase* res)
    00073         {
    00074                 init(res);
    00075                 return *this;
    00076         }
    00077
    00079         FieldNames& operator =(int i)
    00080         {
    00081                 insert(begin(), i, "");
    00082                 return *this;
    00083         }
    00084
    00086         std::string& operator [](int i)
    00087         {
    00088                 return at(i);
    00089         }
    00090
    00093         const std::string& operator [](int i) const
    00094         {
    00095                 return at(i);
    00096         }
    00097
    00099         unsigned int operator [](const std::string& s) const;
    00100
    00101 private:
    00102         void init(const ResultBase* res);
    00103         void str_to_lwr(std::string& s) const
    00104         {
    00105                 std::string::iterator it;
    00106                 for (it = s.begin(); it != s.end(); ++it) {
    00107                         *it = tolower(*it);
    00108                 }
    00109         }
    00110 };
    00111
    00112 } // end namespace mysqlpp
    00113
    00114 #endif