Mercurial > audlegacy
diff libaudacious++/configdb.hh @ 2118:36d4043b3df2 trunk
[svn] - add the starting point of some audacious C++ bindings
author | nenolod |
---|---|
date | Wed, 13 Dec 2006 22:46:29 -0800 |
parents | |
children | 6d7381072a45 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libaudacious++/configdb.hh Wed Dec 13 22:46:29 2006 -0800 @@ -0,0 +1,75 @@ +#ifndef CONFIGDB_HH +#define CONFIGDB_HH + +#include <glib.h> + +#include <string> + +#ifdef _AUDACIOUS_CORE +# include "libaudacious/configdb.h" +#else +# include <audacious/configdb.h> +#endif + +namespace Audacious +{ + + /* + * Usage example: + * + * { + * Audacious::ConfigDb foo; + * Audacious::ConfValue *bar; + * + * bar = foo.GetValue("bar", "filter"); + * std::string filter = bar->asString(); + * delete bar; + * + * foo.SetValue("bar", "filter", "none"); + * + * foo.RemoveEntry("bar", "baz"); + * } + */ + + class ConfValue + { + public: + gchar *strval; + gint intval; + bool boolval; + gfloat floatval; + gdouble dblval; + + std::string asString(void); + gint asInt(void); + bool asBool(void); + gfloat asFloat(void); + gdouble asDouble(void); + + ~ConfValue(void); + }; + + class ConfigDB + { + private: + ConfigDb *db; + + public: + enum ValueType { String, Int, Bool, Float, Double }; + + ConfValue *GetValue(std::string §ion, std::string &name, ConfigDB::ValueType type); + + void SetValue(std::string §ion, std::string &name, std::string &value); + void SetValue(std::string §ion, std::string &name, gint value); + void SetValue(std::string §ion, std::string &name, bool value); + void SetValue(std::string §ion, std::string &name, gfloat value); + void SetValue(std::string §ion, std::string &name, gdouble value); + + void RemoveEntry(std::string §ion, std::string &value); + + ConfigDB(void); + ~ConfigDB(void); + }; +}; + +#endif