A DBFieldBase that also contains data and perform implicit conversion to and from string. More...
#include <db_field.h>
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. More... | |
virtual bool | fromString (const std::string &str) |
Sets the value of this field from a text string. More... | |
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. More... | |
virtual bool | toString (std::string &str) const |
Gets the value of this field as a text string. More... | |
Public Member Functions inherited from database_interface::DBFieldBase | |
DBFieldBase (Type type, DBClass *owner, std::string name, std::string table_name, bool write_permission) | |
std::string | getName () const |
DBClass * | getOwner () |
const DBClass * | getOwner () const |
bool | getReadFromDatabase () const |
std::string | getSequenceName () const |
std::string | getTableName () const |
Type | getType () const |
bool | getWritePermission () const |
bool | getWriteToDatabase () const |
void | setReadFromDatabase (bool sync) |
void | setReadWrite (bool sync) |
void | setSequenceName (std::string seq) |
void | setWriteToDatabase (bool sync) |
Protected Member Functions | |
void | copy (const DBFieldData< T > *other) |
DBFieldData (DBClass *owner, const DBFieldData *other) | |
Copy constructor also copies the data itself. More... | |
Protected Member Functions inherited from database_interface::DBFieldBase | |
DBFieldBase (DBClass *owner, const DBFieldBase *other) | |
Copy constructor is protected, it should only be called by derived classes which also copy the data. More... | |
Protected Attributes | |
T | data_ |
Protected Attributes inherited from database_interface::DBFieldBase | |
std::string | name_ |
The name of the column that this field is stored in in the database. More... | |
DBClass * | owner_ |
The class that this field is part of. More... | |
bool | read_from_database_ |
Marks if this field should be read from the database when its owner is read. More... | |
std::string | sequence_name_ |
Optional: the name of a database sequence that is used as a default value for this field. More... | |
std::string | table_name_ |
The name of the table that this field is stored in the database. More... | |
Type | type_ |
The type of this field, either TEXT or BINARY. More... | |
bool | write_permission_ |
Marks if this field is allowed to be used to modify the database. More... | |
bool | write_to_database_ |
Marks if this field should be saved to the database when its owner is saved. More... | |
Additional Inherited Members | |
Public Types inherited from database_interface::DBFieldBase | |
enum | Type { TEXT, BINARY } |
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.
|
inlineprotected |
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.
|
inline |
Definition at line 318 of file db_field.h.
|
inlineprotected |
Definition at line 290 of file db_field.h.
|
inline |
Definition at line 325 of file db_field.h.
|
inline |
Definition at line 327 of file db_field.h.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
inline |
Definition at line 321 of file db_field.h.
|
inline |
Definition at line 323 of file db_field.h.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
protected |
Definition at line 280 of file db_field.h.