next up previous contents
Next: 6. Template Queries Up: Usage Previous: 4. Tutorial by Example   Contents

Subsections

5. Class Reference

This chapter documents all of the classes that are meant to be used. If it is not documented here don't use it because it is a internal method or class meant to only be used by other related classes.


5.1 BadConversion

struct BadConversion

Related to: mysql_ColData (5.29)

Exception structure thrown when a bad conversion takes place

5.1.1 Synopses

Public members:


5.2 BadNullConversion

class BadNullConversion

Related to: Null (5.12)

Thrown when a Null value is trying to be converted into a type it can't convert to.

5.2.1 Synopses


5.3 Connection

class Connection

The main database handle

5.3.1 Synopses

Public members:

Related Types


5.3.2 storein(TYPE &con, const string &s)

void storein (TYPE &con, const string &s)

Stores the results in TYPE.

Stores the result in TYPE. TYPE must be some sort of STL container.


5.4 Date

struct Date

A special type for holding mysql Dates.

Date, a comparable data structures for holding mysql Dates. It also responds to the stream extraction and insertion operator.

5.4.1 Synopses

Public members:


5.5 DateTime

struct DateTime

A combinate of Date and Time for holding mysql DateTime's

5.5.1 Synopses


5.6 FieldNames

class FieldNames

Parents: public vector<string>

A vector of the field names.

5.6.1 Synopses

Public members:


5.7 FieldTypes

class FieldTypes

Parents: public vector<mysql_type_info>

A vector of the field types.

5.7.1 Synopses

Public members:


5.8 Fields

class Fields

Parents: public const_subscript_container<Fields, Field>

A vector like container with the raw mysql field info.

5.8.1 Synopses

Public members:


5.9 MutableRes

class MutableRes

Parents: public vector<MutableRow<MutableRes> >

This class handles the result set.

It is also a Random Access Container that is not LessThanComparable but is Assignable. Being a Random Access Container it can return a Random Access Iterator or a reverse Random Access Iterator yet.

5.9.1 Synopses

Public members:


5.9.2 field_names() const

inline const FieldNames& field_names () const

Returns a const reference to the underlying FieldNames class.

short names for the above methods


5.10 MutableRow

template class MutableRow<class Res = ResUse>

Parents: public MutableRow_base<Res>

5.10.1 Synopses

Related Classes


5.11 MutableRow_base

template class MutableRow_base<class Res>

Parents: public vector<MutableColData>, public RowTemplate<MutableRow_base<Res>, Res>

Related to: MutableRow (5.10)

This class handles the actual rows with the added benefit of being able to modify the data.

5.11.1 Synopses

Public members:


5.11.2 operator [](const string &i)

MutableColData& operator [] (const string &i)

Returns the value of the field with the field name of i.

This method is not nearly as efficient as using the index number. Use sparingly.


5.11.3 operator [](const string &i) const

const MutableColData& operator [] (const string &i) const

Returns the value of the field with the field name of i.

This method is not nearly as efficient as using the index number. Use sparingly.


5.12 Null

template class Null<class Type, class Behavior = NullisNull>

Container class for holding null types.

5.12.1 Synopses

Public members:

Related Types

Related Classes


5.12.2 Null(const null_type &n)

Null (const null_type &n)

Gives Null the null value

Note: the global const null (not NULL) is of value null_type thus you can say something like Null<Type> x = null.


5.13 NullisBlank

struct NullisBlank

Related to: Null (5.12)

Type to use for the behavior parameter for Null<>

5.13.1 Synopses


5.14 NullisNull

struct NullisNull

Related to: Null (5.12)

Type to use for the behavior parameter for Null<>

5.14.1 Synopses


5.15 NullisZero

struct NullisZero

Related to: Null (5.12)

Type to use for the behavior parameter for Null<>

5.15.1 Synopses


5.16 Query

class Query

Parents: public SQLQuery

A Query class suitable for executing queries.

This is the class is subclassed from SQLQuery. This class unlike SQLQuery is loosely attached to a Mysql object so that it can execute queries.

5.16.1 Synopses

Public members:

Related Classes


5.16.2 success()

bool success ()

Displays the string currently in the buffer.

Same thing as string().


5.16.3 execute(...)

MysqlResNSel execute (...)

Executes the query in the string buffer.

Executes the query in the string buffer and returns a structure that contains the information of the success of the query. Use this for queries that don't return a result set such as INSERT, UPDATE, etc.

The parameters can be anything in a valid SQLQuery::str.


5.16.4 store(...)

MysqlRes store (...)

Executes the query in the string buffer.

Executes a query in the string buffer and returns the result.

The parameters can be anything in a valid SQLQuery::str.


5.16.5 use(...)

MysqlResUse use (...)

Executes the query in the string buffer.

Executes the query in the string buffer and returns the results. This method used the mysql_use_result(MYSQL_RES) function and thus should be used sparingly. Also the Result set is a lot more limited and DOES NOT have an iterator.

The parameters can be anything in a valid SQLQuery::str.


5.17 ResNSel

struct ResNSel

Related to: Result (5.19)

This structure holds the information on the success of queries thatdon't return any results.

5.17.1 Synopses

Public members:


5.18 ResUse

class ResUse

5.18.1 Synopses

Public members:


5.19 Result

class Result

Parents: public ResUse, public const_subscript_container<Result,Row,const Row>

This class handles the result set.

It is also a Random Access Container that is not LessThanComparable and not Assignable. Being a Random Access Container it can return a Random Access Iterator or a reverse Random Access Iterator yet.

See MutableRes for a result set that can be modified.

5.19.1 Synopses

Public members:

Related Functions

Related Classes


5.19.2 Result(const Result &other)

Result (const Result &other)

raw mysql c api functions


5.20 Row

class Row

Parents: public const_subscript_container<Row,ColData,const ColData>, public RowTemplate<Row, ResUse>

This class handles the actual rows in an intelligent manner.

MYSQL_ROW data;

5.20.1 Synopses

Public members:


5.20.2 operator [](const char *) const

inline const ColData operator [] (const char *) const

Returns the value of the field with the field name of i.

This method is not nearly as efficient as using the index number. Use sparingly.


5.20.3 operator [](const string &i) const

inline const ColData operator [] (const string &i) const

Returns the value of the field with the field name of i.

This method is not nearly as effecent as using the index number. Use sparingly.


5.21 SQLQuery

class SQLQuery

Parents: public strstream

Related to: Query (5.16)

The "pure" query class

This is the "pure" query class. It is used to form queries to send to the Connection object. The Query class can be used if you wish to also be able to execute the queries without having to send them to the Connection object.

This class is subclassed from strstream. This means that you can write to it like a stream to avoid having to piece parts together by creating you own strstream or by using sprintf. Although you can read from query because it is a stream this is not recommended. I can not guarantee the predictability of the class if you do and will offer no help if you run into problems when you do this. However, fell free to use any of the stream methods to write to it. Just make sure that the write buffer points to the end of your query before you try to use any of the SQLQuery specific methods except for error() and success().

5.21.1 Synopses

Public members:

Related Classes


5.21.2 str(query_reset r = DONT_RESET)

string str (query_reset r = DONT_RESET)

Returns the full query string.

Returns the full query string, replacing it with the default template parameters if necessary. query_reset can either be DONT_RESET or RESET_QUERY. If it is set the RESET_QUERY then reset() is called after it has finished returning the query. If there is not enough parameters then it will return a empty string and success() would be false.


5.21.3 str(const SQLString &parm0, ...,const SQLString &parm11)

string str (const SQLString &parm0, ...,const SQLString &parm11)

Like str(query_reset) but sets the parameters.

Like str(query_reset) but sets query parameters 0 to (up to) 11. To parm0, parm1 etc. This is archived by overloaded methods and templates and not the ...

It will combine this with def. If any of the required parameters are null it will produce an error and return an empty string.


5.21.4 str(const SQLQueryParms & p, query_reset r = DONT_RESET)

string str (const SQLQueryParms & p, query_reset r = DONT_RESET)

Like str(query_reset) but sets the parameter.

Like query(query_reset res) but sets the parameters based on combining p and def.

If any of the required parameters are null it will produce an error and return an empty string.


5.21.5 reset()

void reset ()

Resets the query.

This means erasing the string and the default template parameters.


5.22 SQLQueryNEParms

struct SQLQueryNEParms

Related to: SQLQuery (5.21)

Exception thrown when not enough parameters are provided

Thrown when not enough parameters are provided for a template query.

5.22.1 Synopses

Public members:


5.23 SQLQueryParms

class SQLQueryParms

Parents: public vector<SQLString>

Related to: SQLQuery (5.21)

This class holds the parameter values for filling template queries.

It is a subclass of a vector of SQLStrings.

5.23.1 Synopses

Public members:


5.23.2 set(ss a, [ss b] ,... , [ss l])

void set (ss a, [ss b] ,... , [ss l])

Set the elements.

Sets element 0 to a, element 1 to b, etc. May specify up to a dozen elements


5.24 SQLString

class SQLString

Parents: public string

A special string that will convert from anything.

A class subclassed from string that has the additional ability to convert from any valid mysql type.

5.24.1 Synopses


5.25 Set

template class Set<class Container = set<string> >

Parents: public Container

A Special Set for holding mysql sets.

5.25.1 Synopses

Public members:

Related Functions


5.26 Time

struct Time

A special type for holding mysql Dates.

Time, a comparable data structures for holding mysql Times. It also responds to the stream extraction and insertion operator.

5.26.1 Synopses

Public members:


5.27 const_string

class const_string

A special string that is created from a existing const char *

It contains a small subset of the standard string class. When an object is created only a link to the const char * is created. The data is NOT copied. thus the const char * needs to stick around for the life of the class.

5.27.1 Synopses

Public members:

Related Functions


5.28 const_subscript_container

template class const_subscript_container<class OnType, class ValueType, class ReturnType = const ValueType&, class SizeType = unsigned int, class DiffType = int>

A container adapter to make a container into a Random Access Container.

The requirements are that the container has the member functions operator[] (SizeType) and size() defined.

5.28.1 Synopses

Public members:


5.29 mysql_ColData

template class mysql_ColData<class Str>

Parents: public Str

Base class for auto-converting column data. Do not use directly.

A smart string. It will automatically convert it self to any of the basic C types.

When used with binary operators it will automatically convert it self to the type used on the other side of the operator if it is a basic type.

However, be careful when using it with binary operators as.

MysqlStr("12.86") + 2

will return 14 because 2 is an integer. What you wanted to say was

MysqlStr("12.86") + 2.0

If this type of thing scares you define the micro NO_BINARY_OPERS to turn of this behavior.

This class also has some basic information about the type of data stored in it.

<bf>Do not use this class directly.</bf> Use the typedef ColData or MutableColData instead.

5.29.1 Synopses

Public members:

Related Types

Related Classes


5.29.2 operator TYPE()

operator TYPE ()

Converts the column data to TYPE.

If all the charters are not read during the conversion to TYPE it will through BadConversion.

TYPE is defined for all the build in types.

(Note, This is not an actual template)


5.30 mysql_type_info

class mysql_type_info

Class that holds basic type information for ColData.

5.30.1 Synopses

Public members:


5.30.2 name() const

inline const char* name () const

Returns a implication defined name of the c++ type.

Returns the name that would be returned by typeid().name() for the C++ type associated with the sql type.


5.30.3 base_type() const

inline const mysql_type_info base_type () const

Returns the type_info for the C++ type inside of the Null type.

If the type is not null then this is the same as c_type()


5.30.4 id() const

int id () const

Returns the id of the sql_type.

Note: Do not ever use this id directly as it may change between versions.


5.31 subscript_iterator

template class subscript_iterator<class OnType, class ReturnType, class SizeType, class DiffType>

Parents: public random_access_iterator<ReturnType, SizeType>

5.31.1 Synopses

5.32 Misc Non Members

Functions:

5.32.1 mysql_cmp

template <class BinaryPred, class CmpType> MysqlCmp <BinaryPred, CmpType> mysql_cmp (uint i, const BinaryPred &func, const CmpType &cmp2)

A special function for using in find_if function where i is the field index number.

This is a more generic form of mysql_cmp_cstr will work with any CmpType that MysqlString can convert to. However, this is not neary as effecent. Only use when obsoletely nessary.

5.32.2 mysql_cmp_cstr

template <class BinaryPred> MysqlCmpCStr <BinaryPred> mysql_cmp_cstr (uint i, const BinaryPred &func, const char *cmp2)

A special function for using in find_if fucntion where i is the field indexnumber.

func should be one of cstr_equal_to(), cstr_not_equal_to(), cstr_less(), cstr_less_equal(), cstr_less_equal(), cstr_less_equal().


5.33 Manipulators

The following manipulators modify only the next item to the right of it in an << chain. They can be used with any ostream (which includes SQLQuery and Query because they are also ostreams) or SQLQueryParms. When used with SQLQueryParms they will override any settings set by the Template Query for that particular item.

quote
Quote and escape the next item. Can be used with ostream or SQLQueryParms.
quote_only
Quote but don't escape the next item. Can be used with ostream or SQLQueryParms.
quote_only_double
Quote, but don't escape the next item, with `` instead of '.
escape
Escape the next item.
do_nothing
Does exactly what it says nothing. Used as a dummy manipulator when you are required to use some manipulator. When used with SQLQueryParms it will make sure that it does not get formatted in any way overriding any setting set by the template query.
ignore
Only valid when used with SQLQueryParms. Like do_nothing however this one will not override formatting set by the template query, thus it is ignored.
Since version 1.6, automatic quoting and escaping has been added to manipulators. This mechanism is applied to mysql_ColData only, iso epse to the class very frequentrly uitlized as a return object of Row[] index. Automatic quoting or escaping is used with << operator only, and on all stream derived classes and objects, including strstream, query objects, but excepting cout, cerr and clog. This has been designed so intentionally, as streaming out values to those objects does not require quoting or escaping. But this feature comes handy when you construct query's by streaming values to query object or to strstream class object.

This feature can be glibally turned of by setting value dont_quote_auto in your code to true.


next up previous contents
Next: 6. Template Queries Up: Usage Previous: 4. Tutorial by Example   Contents
2000-05-16