24 #ifndef __CONFIG_SQLITE_H_ 25 #define __CONFIG_SQLITE_H_ 27 #include <config/config.h> 28 #include <utils/system/hostinfo.h> 48 virtual void load(
const char *filename);
50 virtual bool exists(
const char *path);
51 virtual bool is_float(
const char *path);
52 virtual bool is_uint(
const char *path);
53 virtual bool is_int(
const char *path);
54 virtual bool is_bool(
const char *path);
56 virtual bool is_list(
const char *path);
60 virtual std::string
get_type(
const char *path);
61 virtual float get_float(
const char *path);
62 virtual unsigned int get_uint(
const char *path);
63 virtual int get_int(
const char *path);
64 virtual bool get_bool(
const char *path);
65 virtual std::string
get_string(
const char *path);
66 virtual std::vector<float>
get_floats(
const char *path);
67 virtual std::vector<unsigned int>
get_uints(
const char *path);
68 virtual std::vector<int>
get_ints(
const char *path);
69 virtual std::vector<bool>
get_bools(
const char *path);
70 virtual std::vector<std::string>
get_strings(
const char *path);
75 virtual void set_float(
const char *path,
float f);
76 virtual void set_uint(
const char *path,
unsigned int uint);
77 virtual void set_int(
const char *path,
int i);
78 virtual void set_bool(
const char *path,
bool b);
79 virtual void set_string(
const char *path, std::string &s);
80 virtual void set_string(
const char *path,
const char *s);
81 virtual void set_floats(
const char *path, std::vector<float> &f);
82 virtual void set_uints(
const char *path, std::vector<unsigned int> &uint);
83 virtual void set_ints(
const char *path, std::vector<int> &i);
84 virtual void set_bools(
const char *path, std::vector<bool> &b);
85 virtual void set_strings(
const char *path, std::vector<std::string> &s);
86 virtual void set_strings(
const char *path, std::vector<const char *> &s);
87 virtual void set_comment(
const char *path, std::string &comment);
88 virtual void set_comment(
const char *path,
const char *comment);
90 virtual void erase(
const char *path);
125 virtual bool valid()
const;
127 virtual const char *
path()
const;
128 virtual const char *
type()
const;
132 virtual bool is_int()
const;
141 virtual unsigned int get_uint()
const;
145 virtual std::vector<float>
get_floats()
const;
146 virtual std::vector<unsigned int>
get_uints()
const;
147 virtual std::vector<int>
get_ints()
const;
148 virtual std::vector<bool>
get_bools()
const;
149 virtual std::vector<std::string>
get_strings()
const;
159 ::sqlite3_stmt *__stmt;
178 ::sqlite3_stmt * get_typed_value(
const char *path,
const char *
type);
179 ::sqlite3_stmt * prepare_update(
const char *sql,
const char *path);
180 ::sqlite3_stmt * prepare_insert_value(
const char *sql,
const char *type,
182 void execute_insert_or_update(sqlite3_stmt *stmt);
183 void dump(::sqlite3 *tdb,
const char *dumpfile);
184 void import(::sqlite3 *tdb,
const char *dumpfile);
185 void import_default(
const char *default_dump);
186 void attach_default(
const char *db_file);
196 char *__default_file;
Deferred transaction, lock acquired late.
void lock()
Lock the config.
virtual void erase(const char *path)
Erase the given value from the configuration.
virtual std::string get_string(const char *path)
Get value from configuration which is of type string.
virtual bool is_default(const char *path)
Check if a value was read from the default config.
ValueIterator * iterator()
Iterator for all values.
virtual bool is_list(const char *path)
Check if a value is a list.
virtual int get_int(const char *path)
Get value from configuration which is of type int.
virtual int get_int() const
Get int value.
virtual bool is_bool() const
Check if current value is a bool.
virtual unsigned int get_uint() const
Get unsigned int value.
SQLite configuration value iterator.
SQLiteConfiguration()
Constructor.
virtual bool get_bool(const char *path)
Get value from configuration which is of type bool.
virtual std::vector< std::string > get_strings() const
Get list of values from configuration which is of type string.
Configuration storage using SQLite.
virtual std::vector< float > get_floats(const char *path)
Get list of values from configuration which is of type float.
Fawkes library namespace.
virtual std::vector< int > get_ints() const
Get list of values from configuration which is of type int.
virtual void set_bools(const char *path, std::vector< bool > &b)
Set new value in configuration of type bool.
virtual std::string get_default_comment(const char *path)
Get comment of value at given path.
ValueIterator * search(const char *path)
Iterator with search results.
virtual unsigned int get_uint(const char *path)
Get value from configuration which is of type unsigned int.
virtual void set_default_bool(const char *path, bool b)
Set new default value in configuration of type bool.
virtual std::vector< float > get_floats() const
Get list of values from configuration which is of type float.
virtual std::string get_as_string() const
Get value as string.
bool try_lock()
Try to lock the config.
virtual size_t get_list_size() const
Get number of elements in list value.
virtual std::string get_comment(const char *path)
Get comment of value at given path.
virtual bool is_string() const
Check if current value is a string.
void transaction_begin(transaction_type_t ttype=TRANSACTION_DEFERRED)
Begin SQL Transaction.
virtual void set_default_float(const char *path, float f)
Set new default value in configuration of type float.
virtual void copy(Configuration *copyconf)
Copy all values from the given configuration.
virtual void set_strings(const char *path, std::vector< std::string > &s)
Set new value in configuration of type string.
void try_dump()
Try to dump default configuration.
virtual void load(const char *filename)
Load configuration.
virtual std::string get_string() const
Get string value.
virtual void set_default_string(const char *path, std::string &s)
Set new default value in configuration of type string.
virtual bool is_int(const char *path)
Check if a value is of type int.
virtual ~SQLiteConfiguration()
Destructor.
virtual std::vector< unsigned int > get_uints(const char *path)
Get list of values from configuration which is of type unsigned int.
virtual std::vector< bool > get_bools(const char *path)
Get list of values from configuration which is of type bool.
virtual float get_float(const char *path)
Get value from configuration which is of type float.
virtual std::string get_type(const char *path)
Get type of value at given path.
virtual bool is_uint(const char *path)
Check if a value is of type unsigned int.
virtual bool is_uint() const
Check if current value is a unsigned int.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
virtual bool is_string(const char *path)
Check if a value is of type string.
Immediately acquire lock, no more reading or writing possible.
std::string get_oldvalue() const
Get old value (as string).
virtual bool next()
Check if there is another element and advance to this if possible.
virtual void set_default_comment(const char *path, const char *comment)
Set new default comment for existing default configuration value.
virtual void set_int(const char *path, int i)
Set new value in configuration of type int.
virtual bool is_list() const
Check if a value is a list.
virtual std::vector< int > get_ints(const char *path)
Get list of values from configuration which is of type int.
virtual void set_bool(const char *path, bool b)
Set new value in configuration of type bool.
void transaction_rollback()
Rollback SQL Transaction.
virtual ~SQLiteValueIterator()
Destructor.
virtual bool is_int() const
Check if current value is a int.
virtual bool exists(const char *path)
Check if a given value exists.
virtual const char * type() const
Type of value.
virtual std::vector< bool > get_bools() const
Get list of values from configuration which is of type bool.
virtual bool is_bool(const char *path)
Check if a value is of type bool.
virtual bool is_float(const char *path)
Check if a value is of type float.
virtual ValueIterator * get_value(const char *path)
Get value from configuration.
ValueIterator * iterator_default()
Iterator for all default values.
virtual std::vector< unsigned int > get_uints() const
Get list of values from configuration which is of type unsigned int.
virtual bool valid() const
Check if the current element is valid.
std::string get_modtype() const
Get modification type.
virtual bool is_default() const
Check if current value was read from the default config.
ValueIterator * iterator_hostspecific()
Iterator for all host-specific values.
virtual void set_floats(const char *path, std::vector< float > &f)
Set new value in configuration of type float.
Iterator interface to iterate over config values.
void unlock()
Unlock the config.
virtual void set_uint(const char *path, unsigned int uint)
Set new value in configuration of type unsigned int.
virtual void set_default_uint(const char *path, unsigned int uint)
Set new default value in configuration of type unsigned int.
virtual void set_string(const char *path, std::string &s)
Set new value in configuration of type string.
virtual void set_ints(const char *path, std::vector< int > &i)
Set new value in configuration of type int.
virtual void erase_default(const char *path)
Erase the given default value from the configuration.
void transaction_commit()
Commit SQL Transaction.
virtual std::vector< std::string > get_strings(const char *path)
Get list of values from configuration which is of type string.
virtual void set_uints(const char *path, std::vector< unsigned int > &uint)
Set new value in configuration of type unsigned int.
virtual bool get_bool() const
Get bool value.
Mutex mutual exclusion lock.
virtual bool is_float() const
Check if current value is a float.
virtual const char * path() const
Path of value.
virtual float get_float() const
Get float value.
Interface for configuration handling.
virtual void set_comment(const char *path, std::string &comment)
Set new comment for existing value.
virtual std::string get_comment() const
Get comment.
SQLiteValueIterator(::sqlite3_stmt *stmt, void *p=NULL)
Constructor.
Immediately acquire lock, reading remains possible.
transaction_type_t
Transaction type.
SQLiteValueIterator * modified_iterator()
Iterator for modified values.
virtual void set_default_int(const char *path, int i)
Set new default value in configuration of type int.