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 <string>
|
|
|
|
#include "../common.h"
|
|
|
|
|
2017-02-22 18:52:33 +01:00
|
|
|
interface IStream;
|
2018-03-13 13:14:02 +01: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;
|
|
|
|
|
|
|
|
virtual void WriteSection(const std::string &name) abstract;
|
|
|
|
|
|
|
|
virtual void WriteBoolean(const std::string &name, bool value) abstract;
|
2018-06-20 17:28:51 +02:00
|
|
|
virtual void Writeint32_t(const std::string &name, int32_t value) abstract;
|
2017-02-16 20:12:30 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void WriteEnum(const std::string &name, T value, const IConfigEnum<T> &configEnum)
|
|
|
|
{
|
|
|
|
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:28:51 +02:00
|
|
|
Writeint32_t(name, value);
|
2017-02-16 20:12:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteEnum(name, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteString(const std::string &name, const utf8 * value);
|
|
|
|
};
|
|
|
|
|
2017-02-22 18:52:33 +01:00
|
|
|
IIniWriter * CreateIniWriter(IStream * stream);
|