Cogs.Core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::Core::Variable Struct Reference

Runtime control variable. More...

#include <Variables.h>

Public Member Functions

 Variable ()=default
 Default constructs a Variable instance. By default holds no value.
 
 Variable (StringView name, StringView value)
 Constructs a variable with the given name and value.
 
void operator= (const StringView &value)
 Overloaded assignment operator to allow assigning a variable directly from a string.
 
VariablesetValue (const StringView &value)
 Set the value of the variable to the given string value.
 
VariablesetBool (bool value)
 
VariablesetFloat (float value)
 
VariablesetDouble (double value)
 
VariablesetInt (int value)
 
VariablesetVec2 (glm::vec2 value)
 
VariablesetVec3 (glm::vec3 value)
 
VariablesetVec4 (glm::vec4 value)
 
const StringView getName () const
 Get the name of the variable.
 
void setName (const StringView &str)
 
void setStatic ()
 
const StringView getValue (StringView defaultValue="") const
 Get the value string.
 
const char * getCString () const
 
bool getBool (bool defaultValue=false) const
 
float getFloat (float defaultValue=0.0f) const
 
double getDouble (double defaultValue=0.0) const
 
int getInt (int defaultValue=0) const
 
glm::vec2 getVec2 (glm::vec2 defaultValue={}) const
 
glm::vec3 getVec3 (glm::vec3 defaultValue={}) const
 
glm::vec4 getVec4 (glm::vec4 defaultValue={}) const
 
bool isEmpty () const
 
bool isStatic () const
 
 operator bool () const
 
ParsedDataType getType () const
 

Private Member Functions

void setValid ()
 

Private Attributes

std::string name
 
ValueVariant value
 
std::string stringValue
 
VariableFlags variableFlags = VariableFlags::Empty
 

Detailed Description

Runtime control variable.

Definition at line 26 of file Variables.h.

Constructor & Destructor Documentation

◆ Variable()

Cogs::Core::Variable::Variable ( StringView  name,
StringView  value 
)
inline

Constructs a variable with the given name and value.

Parameters
nameString name of the variable.
valueString value of the variable.

Definition at line 37 of file Variables.h.

Member Function Documentation

◆ getBool()

bool Cogs::Core::Variable::getBool ( bool  defaultValue = false) const
inline

Definition at line 75 of file Variables.h.

◆ getCString()

const char * Cogs::Core::Variable::getCString ( ) const
inline

Definition at line 74 of file Variables.h.

◆ getDouble()

double Cogs::Core::Variable::getDouble ( double  defaultValue = 0.0) const
inline

Definition at line 77 of file Variables.h.

◆ getFloat()

float Cogs::Core::Variable::getFloat ( float  defaultValue = 0.0f) const
inline

Definition at line 76 of file Variables.h.

◆ getInt()

int Cogs::Core::Variable::getInt ( int  defaultValue = 0) const
inline

Definition at line 78 of file Variables.h.

◆ getName()

const StringView Cogs::Core::Variable::getName ( ) const
inline

Get the name of the variable.

Definition at line 67 of file Variables.h.

◆ getType()

ParsedDataType Cogs::Core::Variable::getType ( ) const
inline

Definition at line 88 of file Variables.h.

◆ getValue()

const StringView Cogs::Core::Variable::getValue ( StringView  defaultValue = "") const
inline

Get the value string.

Definition at line 73 of file Variables.h.

◆ getVec2()

glm::vec2 Cogs::Core::Variable::getVec2 ( glm::vec2  defaultValue = {}) const
inline

Definition at line 79 of file Variables.h.

◆ getVec3()

glm::vec3 Cogs::Core::Variable::getVec3 ( glm::vec3  defaultValue = {}) const
inline

Definition at line 80 of file Variables.h.

◆ getVec4()

glm::vec4 Cogs::Core::Variable::getVec4 ( glm::vec4  defaultValue = {}) const
inline

Definition at line 81 of file Variables.h.

◆ isEmpty()

bool Cogs::Core::Variable::isEmpty ( ) const
inline

Definition at line 83 of file Variables.h.

◆ isStatic()

bool Cogs::Core::Variable::isStatic ( ) const
inline

Definition at line 84 of file Variables.h.

◆ operator bool()

Cogs::Core::Variable::operator bool ( ) const
inlineexplicit

Definition at line 86 of file Variables.h.

◆ operator=()

void Cogs::Core::Variable::operator= ( const StringView value)
inline

Overloaded assignment operator to allow assigning a variable directly from a string.

Parameters
valueString value of the variable.
See also
setValue()

Definition at line 49 of file Variables.h.

◆ setBool()

Variable & Cogs::Core::Variable::setBool ( bool  value)
inline

Definition at line 58 of file Variables.h.

◆ setDouble()

Variable & Cogs::Core::Variable::setDouble ( double  value)
inline

Definition at line 60 of file Variables.h.

◆ setFloat()

Variable & Cogs::Core::Variable::setFloat ( float  value)
inline

Definition at line 59 of file Variables.h.

◆ setInt()

Variable & Cogs::Core::Variable::setInt ( int  value)
inline

Definition at line 61 of file Variables.h.

◆ setName()

void Cogs::Core::Variable::setName ( const StringView str)
inline

Definition at line 68 of file Variables.h.

◆ setStatic()

void Cogs::Core::Variable::setStatic ( )
inline

Definition at line 70 of file Variables.h.

◆ setValid()

void Cogs::Core::Variable::setValid ( )
inlineprivate

Definition at line 91 of file Variables.h.

◆ setValue()

Cogs::Core::Variable & Cogs::Core::Variable::setValue ( const StringView value)

Set the value of the variable to the given string value.

Parameters
valueString value to set the variable to.

Definition at line 28 of file Variables.cpp.

References Cogs::StringView::to_string().

◆ setVec2()

Variable & Cogs::Core::Variable::setVec2 ( glm::vec2  value)
inline

Definition at line 62 of file Variables.h.

◆ setVec3()

Variable & Cogs::Core::Variable::setVec3 ( glm::vec3  value)
inline

Definition at line 63 of file Variables.h.

◆ setVec4()

Variable & Cogs::Core::Variable::setVec4 ( glm::vec4  value)
inline

Definition at line 64 of file Variables.h.

Member Data Documentation

◆ name

std::string Cogs::Core::Variable::name
private

Definition at line 93 of file Variables.h.

◆ stringValue

std::string Cogs::Core::Variable::stringValue
private

Definition at line 95 of file Variables.h.

◆ value

ValueVariant Cogs::Core::Variable::value
private

Definition at line 94 of file Variables.h.

◆ variableFlags

VariableFlags Cogs::Core::Variable::variableFlags = VariableFlags::Empty
private

Definition at line 96 of file Variables.h.


The documentation for this struct was generated from the following files: