Files
UnleashedRecomp-hedge-dev/UnleashedRecomp/mod/ini_file.h
Skyth (Asilkan) a397a90551 Mod loader implementation. (#66)
* Initial mod loader implementation.

* Allow iterating in mod directories.

* Initial append archive implementation.

* Avoid calling function wrappers when loading append ARs.

For some reason they cause issues. Should investigate later.

* UMM merge archive support.

* Load merge archives without archive lists.

* Less thread locals.

I shouldn't worry about string allocations this much when the game itself spams them...

* Check for read-only UMM archives.

TODO: Skip merging as it's currently just doing duplicate loads.

* Skip loading merge archives if they are read-only.

* Merge only archives.

* Implement decompression.

* Fix append ARLs not loading.

* Initial save file redirection implementation.

* Slightly refactor resolved path usage.

* Implement save file redirection fallback.

* Set a default save file path if none is provided.

* Check for enabled option & replace backward slashes with forward ones in mod save file paths.

* Convert back slashes to forward ones when iterating directories.

* Make CSB limit dynamic.

* Cache append/merge archive lookups.

* Close stream after reading compressed ARL.

* Fix UMM/HMM ARL file path inconsistency.
2024-12-31 20:20:07 +03:00

47 lines
1.1 KiB
C++

#pragma once
#include <xxHashMap.h>
class IniFile
{
protected:
struct Property
{
std::string name;
std::string value;
};
struct Section
{
std::string name;
xxHashMap<Property> properties;
};
xxHashMap<Section> m_sections;
static size_t hashStr(const std::string_view& str);
static bool isWhitespace(char value);
static bool isNewLine(char value);
public:
bool read(const std::filesystem::path& filePath);
std::string getString(const std::string_view& sectionName, const std::string_view& propertyName, std::string defaultValue) const;
bool getBool(const std::string_view& sectionName, const std::string_view& propertyName, bool defaultValue) const;
template<typename T>
T get(const std::string_view& sectionName, const std::string_view& propertyName, T defaultValue) const;
template<typename T>
void enumerate(const T& function) const;
template<typename T>
void enumerate(const std::string_view& sectionName, const T& function) const;
bool contains(const std::string_view& sectionName) const;
};
#include "ini_file.inl"