Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-04 18:44:17 +0000
committerStijn Buys <ingar@osirion.org>2008-02-04 18:44:17 +0000
commitad340b52a0a4e86edd5b54b01d74aac731a6a812 (patch)
tree60df22b53a8b980c4791bdff9522a409e7b19da8 /src/core/cvar.h
parent151a2ac2434f4b4c23c107d9c21e4a18dd1a3c68 (diff)
basic cvar implementation
Diffstat (limited to 'src/core/cvar.h')
-rw-r--r--src/core/cvar.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/core/cvar.h b/src/core/cvar.h
new file mode 100644
index 0000000..f407395
--- /dev/null
+++ b/src/core/cvar.h
@@ -0,0 +1,63 @@
+/*
+ core/cvar.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CORE_CVAR_H__
+#define __INCLUDED_CORE_CVAR_H__
+
+#include <sstream>
+
+namespace core {
+
+/** new cvars have to be added through the cvar::set functions
+ * and not created directly.
+ */
+class Cvar_t {
+public:
+ Cvar_t(const char *cvarname, unsigned int cvarflags = 0);
+ Cvar_t(const std::string &cvarname, unsigned int cvarflags = 0);
+
+ inline const std::string &name() const { return cvar_name; }
+ inline const std::string &value() const {return cvar_value; }
+
+ Cvar_t &operator=(const char *cvarvalue);
+ Cvar_t &operator=(const std::string &cvarvalue);
+ Cvar_t &operator=(int cvarvalue);
+
+private:
+ std::string cvar_name;
+ std::string cvar_value;
+ unsigned int cvar_flags;
+};
+
+typedef Cvar_t *Cvar;
+
+/// the cvar registry
+namespace cvar
+{
+
+/// create a new cvar containing a string value
+Cvar set(const char *cvarname, const char *value);
+
+/// create a new cvar containing an integer value
+Cvar set(const char *cvarname, int value);
+
+/// delete a cvar
+void unset(const char *cvarname);
+
+// delete a cvar
+void unset(const std::string &cvarname);
+
+/// search for a named cvar, returns 0 if not found
+Cvar find(const std::string &cvarname);
+/// search for a named cvar, returns 0 if not found
+Cvar find(const char *cvarname);
+
+} // namespace cvar
+
+} // namespace core
+
+#endif // __INCLUDED_CORE_CVAR_H__
+