# 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.txt file
    00008  in 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 namespace mysqlpp {
    00035
    00036 #if !defined(DOXYGEN_IGNORE)
    00037 // Make Doxygen ignore this
    00038 class MYSQLPP_EXPORT ResultBase;
    00039 #endif
    00040
    00042 class FieldNames : public std::vector<std::string>
    00043 {
    00044 public:
    00046         FieldNames() { }
    00047
    00049         FieldNames(const FieldNames& other) :
    00050         std::vector<std::string>()
    00051         {
    00052                 assign(other.begin(), other.end());
    00053         }
    00054
    00056         FieldNames(const ResultBase* res) :
    00057         std::vector<std::string>()
    00058         {
    00059                 init(res);
    00060         }
    00061
    00064         FieldNames(int i) :
    00065         std::vector<std::string>(i)
    00066         {
    00067         }
    00068
    00070         FieldNames& operator =(const ResultBase* res)
    00071         {
    00072                 init(res);
    00073                 return *this;
    00074         }
    00075
    00077         FieldNames& operator =(int i)
    00078         {
    00079                 insert(begin(), i, "");
    00080                 return *this;
    00081         }
    00082
    00084         std::string& operator [](int i)
    00085         {
    00086                 return at(i);
    00087         }
    00088
    00091         const std::string& operator [](int i) const
    00092         {
    00093                 return at(i);
    00094         }
    00095
    00097         std::string& operator [](size_type i)
    00098         {
    00099                 return at(i);
    00100         }
    00101
    00104         const std::string& operator [](size_type i) const
    00105         {
    00106                 return at(i);
    00107         }
    00108
    00110         unsigned int operator [](const std::string& s) const;
    00111
    00112 private:
    00113         void init(const ResultBase* res);
    00114 };
    00115
    00116 } // end namespace mysqlpp
    00117
    00118 #endif