OpenRCT2/src/openrct2/config/IniWriter.hpp

55 lines
1.8 KiB
C++
Raw Normal View History

#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
2017-02-16 20:12:30 +01:00
/*****************************************************************************
* 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
2017-12-26 22:15:04 +01:00
#pragma once
2017-02-16 20:12:30 +01:00
#include <string>
#include "../common.h"
interface IStream;
template <typename T> struct IConfigEnum;
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(IStream * stream);