MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Config Class Reference

#include <MRConfig.h>

Public Types

typedef std::vector< const char * > Enum
 Description of a enumeration as a map between [0...N) and N strings.
 

Public Member Functions

 Config (Config const &)=delete
 
void operator= (Config const &)=delete
 
MRMESH_API void reset (std::string appName)
 
MRMESH_API const std::string & getAppName () const
 
MRMESH_API void writeToFile ()
 writes current config to file. (implicitly called from destructor)
 
MRMESH_API bool hasBool (const std::string &key) const
 returns true if MRColor with presented key exists
 
MRMESH_API bool getBool (const std::string &key, bool defaultValue=false) const
 returns MRColor with presented key
 
MRMESH_API void setBool (const std::string &key, bool keyValue)
 sets MRColor for presented key
 
MRMESH_API bool hasColor (const std::string &key) const
 returns true if MRColor with presented key exists
 
MRMESH_API Color getColor (const std::string &key, const Color &defaultValue=Color::black()) const
 returns MRColor with presented key
 
MRMESH_API void setColor (const std::string &key, const Color &keyValue)
 sets MRColor for presented key
 
MRMESH_API bool hasFileStack (const std::string &key) const
 returns true if 'recently used' files exist
 
MRMESH_API FileNamesStack getFileStack (const std::string &key, const FileNamesStack &defaultValue=FileNamesStack()) const
 returns 'recently used' files list
 
MRMESH_API void setFileStack (const std::string &key, const FileNamesStack &keyValue)
 sets 'recently used' files list
 
MRMESH_API bool hasVector2i (const std::string &key) const
 returns true if Vector2i with presented key exists
 
MRMESH_API Vector2i getVector2i (const std::string &key, const Vector2i &defaultValue=Vector2i()) const
 returns Vector2i with presented key
 
MRMESH_API void setVector2i (const std::string &key, const Vector2i &keyValue)
 sets Vector2i for presented key
 
MRMESH_API bool hasEnum (const Enum &enumeration, const std::string &key) const
 returns true if given enumeration value with this key exists and is correct
 
MRMESH_API int getEnum (const Enum &enumeration, const std::string &key, int defaultValue=0) const
 returns custom enumeration value
 
MRMESH_API void setEnum (const Enum &enumeration, const std::string &key, int keyValue)
 sets custom enumeration value
 
MRMESH_API bool hasViewportMask (const std::string &key) const
 
MRMESH_API ViewportMask getViewportMask (const std::string &key, ViewportMask defaultValue={}) const
 
MRMESH_API void setViewportMask (const std::string &key, ViewportMask newValue)
 
MRMESH_API bool hasJsonValue (const std::string &key)
 returns true if json value with this key exists
 
MRMESH_API Json::Value getJsonValue (const std::string &key, const Json::Value &defaultValue={})
 returns custom json value
 
MRMESH_API void setJsonValue (const std::string &key, const Json::Value &keyValue)
 sets custom json value
 
Json::Value toJson () const
 returns json with content of this config
 
void fromJson (const Json::Value &config)
 replace current config content with given one
 

Static Public Member Functions

static MRMESH_API Configinstance ()
 

Member Typedef Documentation

◆ Enum

typedef std::vector<const char*> MR::Config::Enum

Description of a enumeration as a map between [0...N) and N strings.

Constructor & Destructor Documentation

◆ Config()

MR::Config::Config ( Config const & )
delete

Member Function Documentation

◆ fromJson()

void MR::Config::fromJson ( const Json::Value & config)
inline

replace current config content with given one

◆ getAppName()

MRMESH_API const std::string & MR::Config::getAppName ( ) const

◆ getBool()

MRMESH_API bool MR::Config::getBool ( const std::string & key,
bool defaultValue = false ) const

returns MRColor with presented key

◆ getColor()

MRMESH_API Color MR::Config::getColor ( const std::string & key,
const Color & defaultValue = Color::black() ) const

returns MRColor with presented key

◆ getEnum()

MRMESH_API int MR::Config::getEnum ( const Enum & enumeration,
const std::string & key,
int defaultValue = 0 ) const

returns custom enumeration value

◆ getFileStack()

MRMESH_API FileNamesStack MR::Config::getFileStack ( const std::string & key,
const FileNamesStack & defaultValue = FileNamesStack() ) const

returns 'recently used' files list

◆ getJsonValue()

MRMESH_API Json::Value MR::Config::getJsonValue ( const std::string & key,
const Json::Value & defaultValue = {} )

returns custom json value

◆ getVector2i()

MRMESH_API Vector2i MR::Config::getVector2i ( const std::string & key,
const Vector2i & defaultValue = Vector2i() ) const

returns Vector2i with presented key

◆ getViewportMask()

MRMESH_API ViewportMask MR::Config::getViewportMask ( const std::string & key,
ViewportMask defaultValue = {} ) const

◆ hasBool()

MRMESH_API bool MR::Config::hasBool ( const std::string & key) const

returns true if MRColor with presented key exists

◆ hasColor()

MRMESH_API bool MR::Config::hasColor ( const std::string & key) const

returns true if MRColor with presented key exists

◆ hasEnum()

MRMESH_API bool MR::Config::hasEnum ( const Enum & enumeration,
const std::string & key ) const

returns true if given enumeration value with this key exists and is correct

◆ hasFileStack()

MRMESH_API bool MR::Config::hasFileStack ( const std::string & key) const

returns true if 'recently used' files exist

◆ hasJsonValue()

MRMESH_API bool MR::Config::hasJsonValue ( const std::string & key)

returns true if json value with this key exists

◆ hasVector2i()

MRMESH_API bool MR::Config::hasVector2i ( const std::string & key) const

returns true if Vector2i with presented key exists

◆ hasViewportMask()

MRMESH_API bool MR::Config::hasViewportMask ( const std::string & key) const

◆ instance()

static MRMESH_API Config & MR::Config::instance ( )
static

◆ operator=()

void MR::Config::operator= ( Config const & )
delete

◆ reset()

MRMESH_API void MR::Config::reset ( std::string appName)

looks up (~/.local/share/<appname>/config.json) or (AppData<appname>\config.json) creates directory if not presented

◆ setBool()

MRMESH_API void MR::Config::setBool ( const std::string & key,
bool keyValue )

sets MRColor for presented key

◆ setColor()

MRMESH_API void MR::Config::setColor ( const std::string & key,
const Color & keyValue )

sets MRColor for presented key

◆ setEnum()

MRMESH_API void MR::Config::setEnum ( const Enum & enumeration,
const std::string & key,
int keyValue )

sets custom enumeration value

◆ setFileStack()

MRMESH_API void MR::Config::setFileStack ( const std::string & key,
const FileNamesStack & keyValue )

sets 'recently used' files list

◆ setJsonValue()

MRMESH_API void MR::Config::setJsonValue ( const std::string & key,
const Json::Value & keyValue )

sets custom json value

◆ setVector2i()

MRMESH_API void MR::Config::setVector2i ( const std::string & key,
const Vector2i & keyValue )

sets Vector2i for presented key

◆ setViewportMask()

MRMESH_API void MR::Config::setViewportMask ( const std::string & key,
ViewportMask newValue )

◆ toJson()

Json::Value MR::Config::toJson ( ) const
inline

returns json with content of this config

◆ writeToFile()

MRMESH_API void MR::Config::writeToFile ( )

writes current config to file. (implicitly called from destructor)


The documentation for this class was generated from the following file: