1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:59:56 +00:00
openmw/components/esm3/variantimp.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
1.9 KiB
C++
Raw Normal View History

2013-03-04 12:59:06 +00:00
#ifndef OPENMW_ESM_VARIANTIMP_H
#define OPENMW_ESM_VARIANTIMP_H
#include <functional>
2013-03-04 12:59:06 +00:00
#include <string>
#include "variant.hpp"
namespace ESM
{
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, std::string& value);
2013-03-04 12:59:06 +00:00
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, float& value);
2013-03-04 12:59:06 +00:00
2023-10-24 17:25:52 +00:00
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, int32_t& value);
2013-03-04 12:59:06 +00:00
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, const std::string& value);
2013-03-04 12:59:06 +00:00
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, float value);
2013-03-04 12:59:06 +00:00
2023-10-24 17:25:52 +00:00
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, int32_t value);
2013-03-04 12:59:06 +00:00
struct ReadESMVariantValue
2013-03-04 12:59:06 +00:00
{
std::reference_wrapper<ESMReader> mReader;
Variant::Format mFormat;
VarType mType;
2013-03-04 12:59:06 +00:00
ReadESMVariantValue(ESMReader& reader, Variant::Format format, VarType type)
: mReader(reader)
, mFormat(format)
, mType(type)
{
}
2013-03-04 12:59:06 +00:00
void operator()(std::monostate) const {}
2013-03-04 12:59:06 +00:00
template <typename T>
void operator()(T& value) const
{
readESMVariantValue(mReader.get(), mFormat, mType, value);
}
2013-03-04 12:59:06 +00:00
};
struct WriteESMVariantValue
2013-03-04 12:59:06 +00:00
{
std::reference_wrapper<ESMWriter> mWriter;
Variant::Format mFormat;
VarType mType;
2013-03-04 12:59:06 +00:00
WriteESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type)
: mWriter(writer)
, mFormat(format)
, mType(type)
{
}
2013-03-04 12:59:06 +00:00
void operator()(std::monostate) const {}
2013-03-04 12:59:06 +00:00
template <typename T>
void operator()(const T& value) const
{
writeESMVariantValue(mWriter.get(), mFormat, mType, value);
}
2013-03-04 12:59:06 +00:00
};
}
#endif