mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 14:02:59 +01:00
Add int64_t support to INI parser (#12374)
This commit is contained in:
committed by
GitHub
parent
6ba6184602
commit
3b60740128
@@ -155,6 +155,23 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t GetInt64(const std::string& name, int64_t defaultValue) const override
|
||||
{
|
||||
int64_t result = defaultValue;
|
||||
std::string value;
|
||||
if (TryGetString(name, &value))
|
||||
{
|
||||
try
|
||||
{
|
||||
result = std::stoll(value);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
float GetFloat(const std::string& name, float defaultValue) const override
|
||||
{
|
||||
float result = defaultValue;
|
||||
@@ -388,6 +405,11 @@ public:
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
int64_t GetInt64([[maybe_unused]] const std::string& name, int64_t defaultValue) const override
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
float GetFloat([[maybe_unused]] const std::string& name, float defaultValue) const override
|
||||
{
|
||||
return defaultValue;
|
||||
|
||||
@@ -24,6 +24,7 @@ interface IIniReader
|
||||
|
||||
virtual bool GetBoolean(const std::string& name, bool defaultValue) const abstract;
|
||||
virtual int32_t GetInt32(const std::string& name, int32_t defaultValue) const abstract;
|
||||
virtual int64_t GetInt64(const std::string& name, int64_t defaultValue) const abstract;
|
||||
virtual float GetFloat(const std::string& name, float defaultValue) const abstract;
|
||||
virtual std::string GetString(const std::string& name, const std::string& defaultValue) const abstract;
|
||||
virtual bool TryGetString(const std::string& name, std::string* outValue) const abstract;
|
||||
|
||||
@@ -48,6 +48,11 @@ public:
|
||||
WriteProperty(name, std::to_string(value));
|
||||
}
|
||||
|
||||
void WriteInt64(const std::string& name, int64_t value) override
|
||||
{
|
||||
WriteProperty(name, std::to_string(value));
|
||||
}
|
||||
|
||||
void WriteFloat(const std::string& name, float value) override
|
||||
{
|
||||
WriteProperty(name, std::to_string(value));
|
||||
|
||||
@@ -24,6 +24,7 @@ interface IIniWriter
|
||||
|
||||
virtual void WriteBoolean(const std::string& name, bool value) abstract;
|
||||
virtual void WriteInt32(const std::string& name, int32_t value) abstract;
|
||||
virtual void WriteInt64(const std::string& name, int64_t value) abstract;
|
||||
virtual void WriteFloat(const std::string& name, float value) abstract;
|
||||
virtual void WriteString(const std::string& name, const std::string& value) abstract;
|
||||
virtual void WriteEnum(const std::string& name, const std::string& key) abstract;
|
||||
|
||||
Reference in New Issue
Block a user