7 #ifndef litesql_persistent_hpp
8 #define litesql_persistent_hpp
27 typedef std::map<std::string, std::vector<pair<FieldType, std::string> > > Updates;
32 const std::string& sequence);
33 void update(
const Updates& updates);
35 void updateField(litesql::Persistent::Updates& updates,
36 const std::string& table,
39 updates[table].push_back(make_pair(fld.fieldType(),
40 litesql::convert<const T&, std::string>(fld.value())));
41 fld.setModified(
false);
44 void prepareUpdate(Updates& updates,
const std::string& table);
45 void deleteFromTable(
const std::string& table,
const std::string&
id);
79 virtual void onDelete() {}
A base class of databases.
Definition: database.hpp:33
holds field value
Definition: field.hpp:75
An abstract base class of persistents objects.
Definition: persistent.hpp:25
const Persistent & operator=(const Persistent &p)
copies values and keeps fields unchanged
Definition: persistent.cpp:14
bool inDatabase
flag that indicates that object is stored in some database.
Definition: persistent.hpp:52
virtual ~Persistent()
empty
Definition: persistent.hpp:81
bool isInDatabase() const
returns true if object is in database
Definition: persistent.hpp:63
static std::vector< std::string > getTablesFromFieldTypes(const std::vector< FieldType > &fdatas)
selectObjectQuery uses this to list tables used by Persistent
const Database * db
pointer to current Database Persistent is assigned to.
Definition: persistent.hpp:49
Persistent(const Database &_db)
creates empty Persistent
Definition: persistent.hpp:77
int oldKey
used to keep track of ID changes.
Definition: persistent.hpp:56
std::string insert(Record &tables, Records &fieldRecs, Records &values, const std::string &sequence)
executed when object is created into database
Definition: persistent.cpp:23
Persistent(const Persistent &p)
copies values and registers Field-objects to fields
Definition: persistent.hpp:69
const Database & getDatabase() const
returns reference to Database the object is in
Definition: persistent.hpp:59
SQL data row wrapper.
Definition: types.hpp:20
select<T>, intersect<T>, union_<T>, except<T>
int atoi(const std::string &s)
string version of atoi
std::vector< Record > Records
shortcut
Definition: types.hpp:26