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,
const char *defaults_filename,
49 const char *
tag = NULL);
51 void load(
const char *
tag = NULL);
53 virtual void tag(
const char *
tag);
54 virtual std::list<std::string>
tags();
56 virtual bool exists(
const char *path);
57 virtual bool is_float(
const char *path);
58 virtual bool is_uint(
const char *path);
59 virtual bool is_int(
const char *path);
60 virtual bool is_bool(
const char *path);
65 virtual std::string
get_type(
const char *path);
66 virtual float get_float(
const char *path);
67 virtual unsigned int get_uint(
const char *path);
68 virtual int get_int(
const char *path);
69 virtual bool get_bool(
const char *path);
70 virtual std::string
get_string(
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_comment(
const char *path, std::string &comment);
82 virtual void set_comment(
const char *path,
const char *comment);
84 virtual void erase(
const char *path);
119 virtual bool valid()
const;
121 virtual const char *
path()
const;
122 virtual const char *
type()
const;
126 virtual bool is_int()
const;
133 virtual unsigned int get_uint()
const;
146 ::sqlite3_stmt *__stmt;
165 std::string
get_type(
const char *table,
const char *path);
166 bool exists(
const char *sql,
const char *path);
167 ::sqlite3_stmt *
get_value(
const char *type,
const char *path);
168 ::sqlite3_stmt * prepare_update(
const char *sql,
const char *path);
169 ::sqlite3_stmt * prepare_insert_value(
const char *sql,
const char *type,
171 void execute_insert_or_update(sqlite3_stmt *stmt);
172 void dump(::sqlite3 *tdb,
const char *dumpfile);
173 void import(::sqlite3 *tdb,
const char *dumpfile);
174 void import_default(
const char *default_dump);
175 void attach_default(
const char *db_file);
185 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 int get_int(const char *path)
Get value from configuration which is of type int.
SQLite configuration value iterator.
virtual bool is_bool() const
Check if current value is a bool.
SQLiteConfiguration()
Constructor.
virtual bool get_bool(const char *path)
Get value from configuration which is of type bool.
Configuration storage using SQLite.
Fawkes library namespace.
virtual int get_int() const
Get int value.
virtual std::string get_string() const
Get string value.
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.
std::string get_modtype() const
Get modification type.
bool try_lock()
Try to lock the config.
virtual bool is_float() const
Check if current value is a float.
virtual std::string get_comment(const char *path)
Get comment of value at given path.
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.
void try_dump()
Try to dump default configuration.
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 void load(const char *filename, const char *defaults_filename, const char *tag=NULL)
Load configuration.
virtual ~SQLiteConfiguration()
Destructor.
virtual float get_float(const char *path)
Get value from configuration which is of type float.
virtual float get_float() const
Get float value.
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 std::string get_as_string() const
Get value as string.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
virtual bool is_int() const
Check if current value is a int.
virtual bool is_string(const char *path)
Check if a value is of type string.
Immediately acquire lock, no more reading or writing possible.
virtual bool next()
Check if there is another element and advance to this if possible.
virtual const char * path() const
Path of value.
virtual void tag(const char *tag)
Tag this configuration version.
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_uint() const
Check if current value is a unsigned int.
virtual void set_bool(const char *path, bool b)
Set new value in configuration of type bool.
virtual std::string get_comment() const
Get comment.
void transaction_rollback()
Rollback SQL Transaction.
virtual ~SQLiteValueIterator()
Destructor.
virtual const char * type() const
Type of value.
virtual bool exists(const char *path)
Check if a given value exists.
virtual bool get_bool() const
Get bool value.
virtual unsigned int get_uint() const
Get unsigned int value.
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.
ValueIterator * iterator_hostspecific()
Iterator for all host-specific values.
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 erase_default(const char *path)
Erase the given default value from the configuration.
virtual std::list< std::string > tags()
List of tags.
void transaction_commit()
Commit SQL Transaction.
Mutex mutual exclusion lock.
std::string get_oldvalue() const
Get old value (as string).
Interface for configuration handling.
virtual void set_comment(const char *path, std::string &comment)
Set new comment for existing value.
virtual bool is_string() const
Check if current value is a string.
virtual bool valid() const
Check if the current element is valid.
SQLiteValueIterator(::sqlite3_stmt *stmt, void *p=NULL)
Constructor.
Immediately acquire lock, reading remains possible.
virtual bool is_default() const
Check if current value was read from the default config.
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.