All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Protected Member Functions | Protected Attributes
database_interface::DBFieldData< T > Class Template Reference

A DBFieldBase that also contains data and perform implicit conversion to and from string. More...

#include <db_field.h>

Inheritance diagram for database_interface::DBFieldData< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const T & data () const
T & data ()
 DBFieldData (Type type, DBClass *owner, std::string name, std::string table_name, bool write_permission)
virtual bool fromBinary (const char *, size_t)
 Sets the value of this field from a binary chunk of data.
virtual bool fromString (const std::string &str)
 Sets the value of this field from a text string.
const T & get () const
T & get ()
virtual bool toBinary (const char *&, size_t &) const
 Gets a pointer to the value of this field as a binary chunk of data.
virtual bool toString (std::string &str) const
 Gets the value of this field as a text string.

Protected Member Functions

void copy (const DBFieldData< T > *other)
 DBFieldData (DBClass *owner, const DBFieldData *other)
 Copy constructor also copies the data itself.

Protected Attributes

data_

Detailed Description

template<class T>
class database_interface::DBFieldData< T >

A DBFieldBase that also contains data and perform implicit conversion to and from string.

Default conversion to and from string is through the stream operators >> and <<. Any data type that defines those operators can be used inside this class. Works well for most basic data types (int, double, etc).

Default behavior for conversion to / from binary is to always fail. This will be overidden only in the specialized DBField< std::vector<char> >

Definition at line 277 of file db_field.h.


Constructor & Destructor Documentation

template<class T>
database_interface::DBFieldData< T >::DBFieldData ( DBClass owner,
const DBFieldData< T > *  other 
) [inline, protected]

Copy constructor also copies the data itself.

Data is copied through a string or a binary chunk. This implies an additional copy (extra work and memory) but adds no constraints on the type T, which we already know can be converted either to string or to binary.

Definition at line 287 of file db_field.h.

template<class T>
database_interface::DBFieldData< T >::DBFieldData ( Type  type,
DBClass owner,
std::string  name,
std::string  table_name,
bool  write_permission 
) [inline]

Definition at line 318 of file db_field.h.


Member Function Documentation

template<class T>
void database_interface::DBFieldData< T >::copy ( const DBFieldData< T > *  other) [inline, protected]

Definition at line 290 of file db_field.h.

template<class T>
const T& database_interface::DBFieldData< T >::data ( ) const [inline]

Definition at line 325 of file db_field.h.

template<class T>
T& database_interface::DBFieldData< T >::data ( ) [inline]

Definition at line 327 of file db_field.h.

template<class T>
virtual bool database_interface::DBFieldData< T >::fromBinary ( const char *  binary,
size_t  length 
) [inline, virtual]

Sets the value of this field from a binary chunk of data.

Implements database_interface::DBFieldBase.

Reimplemented in database_interface::DBField< std::vector< char > >.

Definition at line 339 of file db_field.h.

template<class T>
virtual bool database_interface::DBFieldData< T >::fromString ( const std::string &  str) [inline, virtual]

Sets the value of this field from a text string.

Implements database_interface::DBFieldBase.

Reimplemented in database_interface::DBField< std::vector< std::string > >, database_interface::DBField< std::string >, and database_interface::DBField< bool >.

Definition at line 329 of file db_field.h.

template<class T>
const T& database_interface::DBFieldData< T >::get ( ) const [inline]

Definition at line 321 of file db_field.h.

template<class T>
T& database_interface::DBFieldData< T >::get ( ) [inline]

Definition at line 323 of file db_field.h.

template<class T>
virtual bool database_interface::DBFieldData< T >::toBinary ( const char *&  binary,
size_t &  length 
) const [inline, virtual]

Gets a pointer to the value of this field as a binary chunk of data.

Field MAINTAINS OWNERSHIP of the binary data; caller is not allowed to modify / delete it.

Implements database_interface::DBFieldBase.

Reimplemented in database_interface::DBField< std::vector< char > >.

Definition at line 340 of file db_field.h.

template<class T>
virtual bool database_interface::DBFieldData< T >::toString ( std::string &  str) const [inline, virtual]

Gets the value of this field as a text string.

Implements database_interface::DBFieldBase.

Reimplemented in database_interface::DBField< std::string >, and database_interface::DBField< bool >.

Definition at line 334 of file db_field.h.


Member Data Documentation

template<class T>
T database_interface::DBFieldData< T >::data_ [protected]

Definition at line 280 of file db_field.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends


database_interface
Author(s): Matei Ciocarlie and Lorenz Mosenlechner
autogenerated on Wed Jan 16 2013 13:32:14