Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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__
+