4#ifndef _Stroika_Foundation_DataExchange_OptionsFile_h_
5#define _Stroika_Foundation_DataExchange_OptionsFile_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
14#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
41 using Characters::String;
88 using LoggerType = function<void (
const LoggerMessage& message)>;
100 using ModuleNameToFileNameMapperType = function<filesystem::path (
const String& moduleName,
const String& fileSuffix)>;
105 static ModuleNameToFileNameMapperType mkFilenameMapper (
const String& appName);
149 ModuleNameToFileNameMapperType moduleNameToFileNameMapper = mkFilenameMapper (
"Put-Your-App-Name-Here"sv),
153 ModuleNameToFileNameMapperType moduleNameToReadFileNameMapper, ModuleNameToFileNameMapperType moduleNameToWriteFileNameMapper,
157 ModuleNameToFileNameMapperType moduleNameToReadFileNameMapper, ModuleNameToFileNameMapperType moduleNameToWriteFileNameMapper,
198 template <
typename T>
199 nonvirtual optional<T>
Read ();
200 template <
typename T>
201 nonvirtual T
Read (
const T& defaultObj,
ReadFlags readFlags = ReadFlags::eWriteIfChanged);
212 template <
typename T>
213 nonvirtual
void Write (
const T& optionsObject);
216 nonvirtual filesystem::path GetReadFilePath_ ()
const;
217 nonvirtual filesystem::path GetWriteFilePath_ ()
const;
223 ModuleNameToFileNameMapperType fModuleNameToReadFileNameMapper_;
224 ModuleNameToFileNameMapperType fModuleNameToWriteFileNameMapper_;
234 struct OptionsFile::LoggerMessage {
236 eSuccessfullyReadFile,
239 eFailedToParseReadFile,
240 eFailedToParseReadFileBadFormat,
241 eFailedToCompareReadFile,
242 eWritingConfigFile_SoDefaultsEditable,
243 eWritingConfigFile_BecauseUpgraded,
244 eWritingConfigFile_BecauseSomethingChanged,
245 eFailedToWriteInUseValues,
248 optional<filesystem::path> fFileName;
249 optional<String> fDetails;
251 LoggerMessage (Msg msg,
const filesystem::path& fn,
const optional<String>& details = nullopt);
252 nonvirtual String FormatMessage ()
const;
267#include "OptionsFile.inl"
String is like std::u32string, except it is much easier to use, often much more space efficient,...
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
nonvirtual void WriteRaw(const BLOB &blob)
static const Variant::Writer kDefaultWriter
function< optional< Common::Version >(const String &moduleName)> ModuleNameToFileVersionMapperType
nonvirtual void Write(const T &optionsObject)
static const ModuleDataUpgraderType kDefaultUpgrader
static const LoggerType kDefaultLogger
function< VariantValue(const optional< Common::Version > &version, const VariantValue &rawVariantValue)> ModuleDataUpgraderType
nonvirtual BLOB ReadRaw() const
static const Variant::Reader kDefaultReader
nonvirtual optional< T > Read()
abstract class specifying interface for readers that map a source like XML or JSON to a VariantValue ...
abstract class specifying interface for writers VariantValue objects to serialized formats like JSON,...
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...