Config/Section: support u16 values
This commit is contained in:
parent
9649494f67
commit
7d509a7a94
|
@ -54,6 +54,11 @@ void Section::Set(const std::string& key, const std::string& value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Section::Set(const std::string& key, u16 newValue)
|
||||||
|
{
|
||||||
|
Section::Set(key, StringFromFormat("0x%04x", newValue));
|
||||||
|
}
|
||||||
|
|
||||||
void Section::Set(const std::string& key, u32 newValue)
|
void Section::Set(const std::string& key, u32 newValue)
|
||||||
{
|
{
|
||||||
Section::Set(key, StringFromFormat("0x%08x", newValue));
|
Section::Set(key, StringFromFormat("0x%08x", newValue));
|
||||||
|
@ -124,6 +129,18 @@ bool Section::Get(const std::string& key, int* value, int defaultValue) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Section::Get(const std::string& key, u16* value, u16 defaultValue) const
|
||||||
|
{
|
||||||
|
std::string temp;
|
||||||
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
|
if (retval && TryParse(temp, value))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
*value = defaultValue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Section::Get(const std::string& key, u32* value, u32 defaultValue) const
|
bool Section::Get(const std::string& key, u32* value, u32 defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
// Setters
|
// Setters
|
||||||
virtual void Set(const std::string& key, const std::string& value);
|
virtual void Set(const std::string& key, const std::string& value);
|
||||||
|
|
||||||
|
void Set(const std::string& key, u16 newValue);
|
||||||
void Set(const std::string& key, u32 newValue);
|
void Set(const std::string& key, u32 newValue);
|
||||||
void Set(const std::string& key, float newValue);
|
void Set(const std::string& key, float newValue);
|
||||||
void Set(const std::string& key, double newValue);
|
void Set(const std::string& key, double newValue);
|
||||||
|
@ -57,6 +58,7 @@ public:
|
||||||
const std::string& default_value = NULL_STRING) const;
|
const std::string& default_value = NULL_STRING) const;
|
||||||
|
|
||||||
bool Get(const std::string& key, int* value, int defaultValue = 0) const;
|
bool Get(const std::string& key, int* value, int defaultValue = 0) const;
|
||||||
|
bool Get(const std::string& key, u16* value, u16 defaultValue = 0) const;
|
||||||
bool Get(const std::string& key, u32* value, u32 defaultValue = 0) const;
|
bool Get(const std::string& key, u32* value, u32 defaultValue = 0) const;
|
||||||
bool Get(const std::string& key, bool* value, bool defaultValue = false) const;
|
bool Get(const std::string& key, bool* value, bool defaultValue = false) const;
|
||||||
bool Get(const std::string& key, float* value, float defaultValue = 0.0f) const;
|
bool Get(const std::string& key, float* value, float defaultValue = 0.0f) const;
|
||||||
|
|
Loading…
Reference in New Issue