mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-28 22:37:03 +00:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
45
src/util/IniParser/IniParser.h
Normal file
45
src/util/IniParser/IniParser.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
class IniParser
|
||||
{
|
||||
private:
|
||||
class IniSection
|
||||
{
|
||||
public:
|
||||
IniSection(std::string_view sectionName, size_t lineNumber) : m_sectionName(sectionName), m_lineNumber(lineNumber) {}
|
||||
std::string_view m_sectionName;
|
||||
size_t m_lineNumber;
|
||||
std::vector<std::pair<std::string_view, std::string_view>> m_optionPairs;
|
||||
};
|
||||
|
||||
public:
|
||||
IniParser(std::span<char> iniContents, std::string_view name = {});
|
||||
IniParser(std::span<unsigned char> iniContents, std::string_view name = {}) : IniParser(std::span<char>((char*)iniContents.data(), iniContents.size()), name) {};
|
||||
|
||||
// section and option iterating
|
||||
bool NextSection();
|
||||
std::string_view GetCurrentSectionName();
|
||||
size_t GetCurrentSectionLineNumber();
|
||||
std::optional<std::string_view> FindOption(std::string_view optionName);
|
||||
std::span<std::pair<std::string_view, std::string_view>> GetAllOptions();
|
||||
|
||||
private:
|
||||
// parsing
|
||||
bool parse();
|
||||
bool ReadNextLine(std::string_view& lineString);
|
||||
void TrimWhitespaces(std::string_view& str);
|
||||
void StartSection(std::string_view sectionName, size_t lineNumber);
|
||||
void PrintWarning(int lineNumber, std::string_view msg, std::string_view lineView);
|
||||
|
||||
std::vector<char> m_iniFileData;
|
||||
std::string m_name;
|
||||
bool m_isValid{ false };
|
||||
size_t m_parseOffset{ 0 };
|
||||
std::vector<IniSection> m_sectionList;
|
||||
size_t m_currentSectionIndex{std::numeric_limits<size_t>::max()};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue