2017-02-16 20:12:30 +01:00
|
|
|
/*****************************************************************************
|
2018-06-15 14:07:34 +02:00
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
2017-02-16 20:12:30 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-02-16 20:12:30 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-02-16 20:12:30 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2017-12-26 22:15:04 +01:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-16 20:12:30 +01:00
|
|
|
#include "../common.h"
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
#include <string>
|
|
|
|
|
2017-02-22 18:52:33 +01:00
|
|
|
interface IStream;
|
2018-06-22 22:58:08 +02:00
|
|
|
template<typename T> struct IConfigEnum;
|
2017-02-22 18:52:33 +01:00
|
|
|
|
2017-02-16 20:12:30 +01:00
|
|
|
interface IIniWriter
|
|
|
|
{
|
|
|
|
virtual ~IIniWriter() = default;
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
virtual void WriteSection(const std::string& name) abstract;
|
2017-02-16 20:12:30 +01:00
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
virtual void WriteBoolean(const std::string& name, bool value) abstract;
|
|
|
|
virtual void WriteInt32(const std::string& name, int32_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;
|
2017-02-16 20:12:30 +01:00
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
template<typename T> void WriteEnum(const std::string& name, T value, const IConfigEnum<T>& configEnum)
|
2017-02-16 20:12:30 +01:00
|
|
|
{
|
|
|
|
std::string key = configEnum.GetName(value);
|
2017-02-17 00:22:26 +01:00
|
|
|
if (key.empty())
|
2017-02-16 20:12:30 +01:00
|
|
|
{
|
2018-06-20 17:56:57 +02:00
|
|
|
WriteInt32(name, value);
|
2017-02-16 20:12:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteEnum(name, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
void WriteString(const std::string& name, const utf8* value);
|
2017-02-16 20:12:30 +01:00
|
|
|
};
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
IIniWriter* CreateIniWriter(IStream* stream);
|