Go to the documentation of this file.
29 #if !defined(MYSQLPP_RESULT_H)
30 #define MYSQLPP_RESULT_H
48 class MYSQLPP_EXPORT SimpleResult
55 typedef bool SimpleResult::*private_bool_type;
67 SimpleResult(
bool copacetic, ulonglong insert_id,
68 ulonglong rows,
const std::string& info) :
69 copacetic_(copacetic),
70 insert_id_(insert_id),
82 operator private_bool_type()
const
84 return copacetic_ ? &SimpleResult::copacetic_ : 0;
88 ulonglong insert_id()
const {
return insert_id_; }
91 ulonglong rows()
const {
return rows_; }
95 const char* info()
const {
return info_.c_str(); }
117 const Field& fetch_field()
const
118 {
return fields_.at(current_field_++); }
121 const Field& fetch_field(Fields::size_type i)
const
122 {
return fields_.at(i); }
125 const Field& field(
unsigned int i)
const {
return fields_.at(i); }
128 const Fields& fields()
const {
return fields_; }
131 const std::string& field_name(
int i)
const
132 {
return names_->at(i); }
141 int field_num(
const std::string&)
const;
144 const FieldTypes::value_type& field_type(
int i)
const
145 {
return types_->at(i); }
149 const RefCountedPointer<FieldTypes>& field_types()
const
153 size_t num_fields()
const {
return fields_.size(); }
156 const char* table()
const
157 {
return fields_.empty() ?
"" : fields_[0].table(); }
196 mutable Fields::size_type current_field_;
211 public std::vector<Row>
221 typedef std::vector<Row> list_type;
247 list_type::size_type num_rows()
const {
return size(); }
251 StoreQueryResult& operator =(
const StoreQueryResult& rhs)
252 {
return this != &rhs ? copy(rhs) : *this; }
260 operator private_bool_type()
const
262 return copacetic_ ? &StoreQueryResult::copacetic_ : 0;
268 StoreQueryResult& copy(
const StoreQueryResult& other);
287 mysql_free_result(doomed);
321 UseQueryResult& operator =(
const UseQueryResult& rhs)
322 {
return this != &rhs ? copy(rhs) : *this; }
325 const Field& fetch_field()
const
326 {
return fields_.at(current_field_++); }
329 const Field& fetch_field(Fields::size_type i)
const
330 {
return fields_.at(i); }
337 const unsigned long* fetch_lengths()
const;
346 Row fetch_row()
const;
354 MYSQL_ROW fetch_raw_row()
const;
360 void field_seek(Fields::size_type field)
const
361 { current_field_ = field; }
385 operator MYSQL_RES*()
const {
return result_.raw(); }
389 UseQueryResult& copy(
const UseQueryResult& other);
401 mutable RefCountedPointer<MYSQL_RES> result_;
425 #endif // !defined(MYSQLPP_RESULT_H)
Declares a class to hold a list of SQL field type info.
Declares the MySQL++-specific exception classes.
MYSQL_ROW fetch_row(MYSQL_RES *res) const
Returns the next raw C API row structure from the given result set.
Definition: dbdriver.h:342
Declares the RefCountedPointer template.
Manages rows from a result set.
Definition: row.h:85
ResultBase()
Create empty object.
Definition: result.h:183
StoreQueryResult set type for "use" queries.
Definition: result.h:320
MYSQL_ROW fetch_raw_row() const
Wraps mysql_fetch_row() in MySQL C API.
Definition: result.cpp:228
Base class for StoreQueryResult and UseQueryResult.
Definition: result.h:132
Row fetch_row() const
Returns the next row in a "use" query's result set.
Definition: result.cpp:191
T * raw()
Return the raw pointer in T* context.
Definition: refcounted.h:254
StoreQueryResult set type for "store" queries.
Definition: result.h:231
Provides a thin abstraction layer over the underlying database client library.
Definition: dbdriver.h:79
void free_result(MYSQL_RES *res) const
Releases memory used by a result set.
Definition: dbdriver.h:391
UseQueryResult()
Default constructor.
Definition: result.h:324
Creates an object that acts as a reference-counted pointer to another object.
Definition: refcounted.h:104
const unsigned long * fetch_lengths(MYSQL_RES *res) const
Returns the lengths of the fields in the current row from a "use" query.
Definition: dbdriver.h:352
Declares a class to hold a list of field names.
Declares the DBDriver class.
Functor to call delete on the pointer you pass to it.
Definition: refcounted.h:69
const unsigned long * fetch_lengths() const
Returns the lengths of the fields in the current row of the result set.
Definition: result.cpp:184
std::vector< Field > Fields
The list-of-Fields type.
Definition: field.h:174
Declares the classes for holding row data from a result set.
Declares interface that allows exceptions to be optional.
Declares the Field and Fields classes.
Declares classes for holding information about SQL query results.
This file includes top-level definitions for use both internal to the library, and outside it....
Class to hold information about a SQL field.
Definition: field.h:67
DBDriver * driver_
Access to DB driver; fully initted if nonzero.
Definition: result.h:202
Interface allowing a class to have optional exceptions.
Definition: noexceptions.h:92
void swap(StoreQueryResult &x, StoreQueryResult &y)
Swaps two StoreQueryResult objects.
Definition: result.h:429
Exception thrown when something goes wrong in processing a "use" query.
Definition: exceptions.h:276
Exception thrown when a requested named field doesn't exist.
Definition: exceptions.h:183
ResultBase & copy(const ResultBase &other)
Copy another ResultBase object's contents into this one.
Definition: result.cpp:82
void operator()(T *doomed) const
Functor implementation.
Definition: refcounted.h:94
bool throw_exceptions() const
Returns true if exceptions are enabled.
Definition: noexceptions.h:134