field_names.h
Go to the documentation of this file.
/***********************************************************************
Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
(c) 2004-2008 by Educational Technology Resources, Inc. Others may
also hold copyrights on code in this file. See the CREDITS.txt file
in the top directory of the distribution for details.
This file is part of MySQL++.
MySQL++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MySQL++; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
***********************************************************************/
#ifndef MYSQLPP_FIELD_NAMES_H
#define MYSQLPP_FIELD_NAMES_H
#include <string>
#include <vector>
namespace mysqlpp {
#if !defined(DOXYGEN_IGNORE)
// Make Doxygen ignore this
class MYSQLPP_EXPORT ResultBase;
#endif
class FieldNames : public std::vector<std::string>
{
public:
FieldNames() { }
FieldNames(const FieldNames& other) :
std::vector<std::string>()
{
assign(other.begin(), other.end());
}
FieldNames(const ResultBase* res) :
std::vector<std::string>()
{
init(res);
}
FieldNames(int i) :
std::vector<std::string>(i)
{
}
FieldNames& operator =(const ResultBase* res)
{
init(res);
return *this;
}
FieldNames& operator =(int i)
{
insert(begin(), i, "");
return *this;
}
std::string& operator [](int i)
{
return at(i);
}
const std::string& operator [](int i) const
{
return at(i);
}
std::string& operator [](size_type i)
{
return at(i);
}
const std::string& operator [](size_type i) const
{
return at(i);
}
unsigned int operator [](const std::string& s) const;
private:
void init(const ResultBase* res);
};
} // end namespace mysqlpp
#endif
mysqlpp::FieldNames::operator[]
std::string & operator[](int i)
Get the name of a field given its index.
Definition: field_names.h:84
mysqlpp::FieldNames::FieldNames
FieldNames(const ResultBase *res)
Create field name list from a result set.
Definition: field_names.h:56
mysqlpp::FieldNames::FieldNames
FieldNames(const FieldNames &other)
Copy constructor.
Definition: field_names.h:49
mysqlpp::FieldNames::FieldNames
FieldNames()
Default constructor.
Definition: field_names.h:46
mysqlpp::FieldNames::operator=
FieldNames & operator=(const ResultBase *res)
Initializes the field list from a result set.
Definition: field_names.h:70
mysqlpp::ResultBase
Base class for StoreQueryResult and UseQueryResult.
Definition: result.h:110
mysqlpp::FieldNames
Holds a list of SQL field names.
Definition: field_names.h:42
mysqlpp::FieldNames::FieldNames
FieldNames(int i)
Create empty field name list, reserving space for a fixed number of field names.
Definition: field_names.h:64