MySQL++ Reference Manual

MySQL++: field_names.h Source File

MySQL++ 3.3.0

field_names.h
Go to the documentation of this file.
1
4 /***********************************************************************
5 Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
6 (c) 2004-2008 by Educational Technology Resources, Inc. Others may
7 also hold copyrights on code in this file. See the CREDITS.txt file
8 in the top directory of the distribution for details.
9
10 This file is part of MySQL++.
11
12 MySQL++ is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published
14 by the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with MySQL++; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 USA
26 ***********************************************************************/
27
28 #ifndef MYSQLPP_FIELD_NAMES_H
29 #define MYSQLPP_FIELD_NAMES_H
30
31 #include <string>
32 #include <vector>
33
34 namespace mysqlpp {
35
36 #if !defined(DOXYGEN_IGNORE)
37 // Make Doxygen ignore this
38 class MYSQLPP_EXPORT ResultBase;
39 #endif
40
42 class FieldNames : public std::vector<std::string>
43 {
44 public:
46 FieldNames() { }
47
49 FieldNames(const FieldNames& other) :
50 std::vector<std::string>()
51 {
52 assign(other.begin(), other.end());
53 }
54
56 FieldNames(const ResultBase* res) :
57 std::vector<std::string>()
58 {
59 init(res);
60 }
61
64 FieldNames(int i) :
65 std::vector<std::string>(i)
66 {
67 }
68
70 FieldNames& operator =(const ResultBase* res)
71 {
72 init(res);
73 return *this;
74 }
75
77 FieldNames& operator =(int i)
78 {
79 insert(begin(), i, "");
80 return *this;
81 }
82
84 std::string& operator [](int i)
85 {
86 return at(i);
87 }
88
91 const std::string& operator [](int i) const
92 {
93 return at(i);
94 }
95
97 std::string& operator [](size_type i)
98 {
99 return at(i);
100 }
101
104 const std::string& operator [](size_type i) const
105 {
106 return at(i);
107 }
108
110 unsigned int operator [](const std::string& s) const;
111
112 private:
113 void init(const ResultBase* res);
114 };
115
116 } // end namespace mysqlpp
117
118 #endif
mysqlpp::FieldNames
Holds a list of SQL field names.
Definition: field_names.h:43
mysqlpp::FieldNames::FieldNames
FieldNames(const FieldNames &other)
Copy constructor.
Definition: field_names.h:49
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
mysqlpp::FieldNames::FieldNames
FieldNames(const ResultBase *res)
Create field name list from a result set.
Definition: field_names.h:56
mysqlpp::FieldNames::operator=
FieldNames & operator=(const ResultBase *res)
Initializes the field list from a result set.
Definition: field_names.h:70
mysqlpp::FieldNames::FieldNames
FieldNames()
Default constructor.
Definition: field_names.h:46
mysqlpp::FieldNames::operator[]
std::string & operator[](int i)
Get the name of a field given its index.
Definition: field_names.h:84
mysqlpp::ResultBase
Base class for StoreQueryResult and UseQueryResult.
Definition: result.h:111