mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Some changes on user options.
This commit is contained in:
parent
bb74e92fc1
commit
018a2de97b
@ -298,6 +298,14 @@ String & NullString()
|
||||
return s;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
String & StringRef(const SQChar * str)
|
||||
{
|
||||
static String s;
|
||||
s.assign(str);
|
||||
return s;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr ConvNum< Int8 >::ToStr(Int8 v)
|
||||
{
|
||||
|
@ -137,6 +137,11 @@ Function & NullFunction();
|
||||
*/
|
||||
String & NullString();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve a reference to a static string with a specific value.
|
||||
*/
|
||||
String & StringRef(const SQChar * str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Compute the next power of two for the specified number.
|
||||
*/
|
||||
|
@ -581,21 +581,21 @@ void Core::EnableNullEntities()
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr Core::GetOption(CSStr name) const
|
||||
const String & Core::GetOption(const String & name) const
|
||||
{
|
||||
auto elem = m_Options.find(name);
|
||||
return (elem == m_Options.end()) ? _SC("") : elem->second.c_str();
|
||||
return (elem == m_Options.end()) ? NullString() : elem->second;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr Core::GetOption(CSStr name, CSStr value) const
|
||||
const String & Core::GetOption(const String & name, const String & value) const
|
||||
{
|
||||
auto elem = m_Options.find(name);
|
||||
return (elem == m_Options.end()) ? value : elem->second.c_str();
|
||||
return (elem == m_Options.end()) ? value : elem->second;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::SetOption(CSStr name, CSStr value)
|
||||
void Core::SetOption(const String & name, const String & value)
|
||||
{
|
||||
m_Options[name] = value;
|
||||
}
|
||||
|
@ -811,17 +811,17 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value of the specified option.
|
||||
*/
|
||||
CSStr GetOption(CSStr name) const;
|
||||
const String & GetOption(const String & name) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value of the specified option or the fall back value if it doesn't exist.
|
||||
*/
|
||||
CSStr GetOption(CSStr name, CSStr value) const;
|
||||
const String & GetOption(const String & name, const String & value) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the value of the specified option.
|
||||
*/
|
||||
void SetOption(CSStr name, CSStr value);
|
||||
void SetOption(const String & name, const String & value);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the script source associated with a certain path in the scripts list.
|
||||
|
@ -145,21 +145,21 @@ static void SqSetAreasEnabled(bool toggle)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static CSStr SqGetOption(CSStr name)
|
||||
static const String & SqGetOption(StackStrF & name)
|
||||
{
|
||||
return Core::Get().GetOption(name);
|
||||
return Core::Get().GetOption(String(name.mPtr, name.mLen));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static CSStr SqGetOptionOr(CSStr name, CSStr value)
|
||||
static const String & SqGetOptionOr(StackStrF & name, StackStrF & value)
|
||||
{
|
||||
return Core::Get().GetOption(name, value);
|
||||
return Core::Get().GetOption(String(name.mPtr, name.mLen), StringRef(value.mPtr));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void SqSetOption(CSStr name, CSStr value)
|
||||
static void SqSetOption(StackStrF & name, StackStrF & value)
|
||||
{
|
||||
return Core::Get().SetOption(name, value);
|
||||
Core::Get().SetOption(String(name.mPtr, name.mLen), String(value.mPtr, value.mLen));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user