view src/libaudacious++/configdb.hh @ 2438:8750a62abed8 trunk

[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a useful default get_time().
author iabervon
date Sun, 28 Jan 2007 22:09:12 -0800
parents 3149d4b1a9a9
children
line wrap: on
line source

#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", Audacious::ConfigDB::String);
	 *     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 &section, std::string &name, ConfigDB::ValueType type);

		void SetValue(std::string &section, std::string &name, std::string &value);
		void SetValue(std::string &section, std::string &name, gint value);
		void SetValue(std::string &section, std::string &name, bool value);
		void SetValue(std::string &section, std::string &name, gfloat value);
		void SetValue(std::string &section, std::string &name, gdouble value);

		void RemoveEntry(std::string &section, std::string &value);

		ConfigDB(void);
		~ConfigDB(void);
	};
};

#endif