1#ifndef HYPERISO_LHA_READER_H
2#define HYPERISO_LHA_READER_H
14#include <unordered_set>
79 R
"x(((?:[+-])?(?:\d+\.\d*|\.\d+)(?:[eEdD][+-]\d+)?|(\d+(?:[eEdD][+-]\d+)?))|(?:[+-]?\d+(?!\.))|(block)|(decay)|(\n)|([ \t]+)|(#.*)|([\w\=\.]+)|([^#]*))x",
80 std::regex_constants::icase
115 std::unordered_set<Prototype> blockPrototypes;
126 void fill_prototypes(std::string_view lha_path);
139 std::vector<Token> tokenize(
const std::string& src)
const;
155 std::map<BlockName, std::vector<std::vector<std::string>>> parse_tokens(std::vector<Token> tokens,
bool comments =
false)
const;
171 void addBlock(std::map<
BlockName, std::shared_ptr<LhaBlock>>& blocks,
const BlockName&
id,
const std::vector<std::vector<std::string>>& lines)
const;
198 std::shared_ptr<DBNode> toDBNode(std::map<
BlockName, std::shared_ptr<LhaBlock>> blocks)
const;
213 std::shared_ptr<DBNode>
readFromFile(
const std::string& input_file)
const override;
229 std::shared_ptr<DBNode>
parse(
const std::string& src)
const override;
241 void writeToFile(
const std::string& filename,
const std::shared_ptr<DBNode>& root)
const;
254 void set_prototypes(
const std::unordered_set<Prototype>& prototypes);
Hierarchical key–value tree with JSON/YAML serialization.
Abstract interface for (de)serializing data as DBNode trees.
const std::regex analyzer_rx(R"x(((?:[+-])?(?:\d+\.\d*|\.\d+)(?:[eEdD][+-]\d+)?|(\d+(?:[eEdD][+-]\d+)?))|(?:[+-]?\d+(?!\.))|(block)|(decay)|(\n)|([ \t]+)|(#.*)|([\w\=\.]+)|([^#]*))x", std::regex_constants::icase)
TokenType
Token categories used during LHA lexical analysis.
Block identifier with alias support.
Abstract base class for data parsers.
Parser for LHA/FLHA files, producing blocks and a DBNode representation.
std::shared_ptr< DBNode > readFromFile(const std::string &input_file) const override
Parses an LHA/FLHA file from disk and returns its DBNode representation.
void writeToFile(const std::string &filename, const std::shared_ptr< DBNode > &root) const
Serializes a DBNode structure back to an LHA-like file.
std::shared_ptr< DBNode > parse(const std::string &src) const override
Parses LHA/FLHA content from an in-memory string.
void set_prototypes(const std::unordered_set< Prototype > &prototypes)
Sets the set of block prototypes used by the parser.
Representation of a single LHA/FLHA block and its entries.
Represents the structure of an LHA block, specifying columns for values, scales, and renormalization ...
Single lexical token produced from an LHA file.