2017-02-16 20:12:30 +01:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "../common.h"
|
2017-02-22 18:46:10 +01:00
|
|
|
#include "ConfigEnum.hpp"
|
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;
|
|
|
|
virtual void WriteSint32(const std::string &name, sint32 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;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-02-17 00:22:26 +01:00
|
|
|
WriteSint32(name, value);
|
2017-02-16 20:12:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteEnum(name, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteString(const std::string &name, const utf8 * value);
|
|
|
|
};
|
|
|
|
|
|
|
|
IIniWriter * CreateIniWriter(const std::string &path);
|