// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include namespace anki { /// @addtogroup core /// @{ /// A storage of configuration variables. class ConfigSet { public: ConfigSet(); /// Copy. ConfigSet(const ConfigSet& b) { operator=(b); } ~ConfigSet(); /// Copy. ConfigSet& operator=(const ConfigSet& b); /// @name Set the value of an option. /// @{ void set(CString option, CString value); template::value)> void set(CString option, T value) { setInternal(option, U64(value)); } template::value)> void set(CString option, T value) { setInternal(option, F64(value)); } /// @} /// @name Find an option and return its value. /// @{ F64 getNumberF64(CString option) const; F32 getNumberF32(CString option) const; U64 getNumberU64(CString option) const; U32 getNumberU32(CString option) const; U16 getNumberU16(CString option) const; U8 getNumberU8(CString option) const; Bool getBool(CString option) const; CString getString(CString option) const; /// @} /// @name Create new options. /// @{ void newOption(CString optionName, CString value, CString helpMsg); template::value)> void newOption(CString optionName, T value, T minValue, T maxValue, CString helpMsg = "") { newOptionInternal(optionName, U64(value), U64(minValue), U64(maxValue), helpMsg); } template::value)> void newOption(CString optionName, T value, T minValue, T maxValue, CString helpMsg = "") { newOptionInternal(optionName, F64(value), F64(minValue), F64(maxValue), helpMsg); } /// @} ANKI_USE_RESULT Error loadFromFile(CString filename); ANKI_USE_RESULT Error saveToFile(CString filename) const; ANKI_USE_RESULT Error setFromCommandLineArguments(U32 cmdLineArgsCount, char* cmdLineArgs[]); private: class Option; HeapAllocator m_alloc; List