/* 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 namespace core { /// the cvar container class class Cvar_t { public: Cvar_t(unsigned int cvflags = 0); Cvar_t &operator=(const char *other); Cvar_t &operator=(const std::string &other); Cvar_t &operator=(int other); Cvar_t &operator=(float other); unsigned int flags() const; float value() const; const std::string &text() const; private: std::string cvar_text; float cvar_value; unsigned int cvar_flags; }; /// general cvar type typedef Cvar_t *Cvar; /// the cvar registry namespace cvar { /// get a cvar value from the registry /** If the a cvar with the given name already exists in the registry, * its value will not be changed. If the cvar does not exist, * it will be created */ Cvar get(const char *name, const char *value, int flags=0); /// get a cvar value from the registry /** If the a cvar with the given name already exists in the registry, * its value will not be changed. If the cvar does not exist, * it will be created */ Cvar get(const char *name, float value, int flags=0); /// set a cvar value /** If the a cvar with the given name already exists in the registry, * its value will be replaced */ Cvar set(const char *name, const char *value, int flags=0); /// set a cvar value /** If the a cvar with the given name already exists in the registry, * its value will be replaced */ Cvar set(const char *name, float value, int flags=0); /// delete a cvar from the registry void unset(const char *name); /// delete a cvar from the registry void unset(const std::string &name); /// search for a named cvar, returns 0 if not found Cvar find(const std::string &name); /// search for a named cvar, returns 0 if not found Cvar find(const char *name); /// list the cvar registry void list(); } // namespace cvar } // namespace core #endif // __INCLUDED_CORE_CVAR_H__