mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-16 17:57:57 -05:00
Use custom parser values instead of simple parser values for parsing Zone definitions
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Parsing/IParserValue.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/TokenPos.h"
|
||||
|
||||
enum class ZoneDefinitionParserValueType
|
||||
{
|
||||
// Meta tokens
|
||||
INVALID,
|
||||
END_OF_FILE,
|
||||
|
||||
CHARACTER,
|
||||
STRING,
|
||||
FIELD,
|
||||
|
||||
// End
|
||||
MAX
|
||||
};
|
||||
|
||||
class ZoneDefinitionParserValue final : public IParserValue
|
||||
{
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
ZoneDefinitionParserValueType m_type;
|
||||
size_t m_hash;
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
std::string* string_value;
|
||||
} m_value;
|
||||
|
||||
static ZoneDefinitionParserValue Invalid(TokenPos pos);
|
||||
static ZoneDefinitionParserValue EndOfFile(TokenPos pos);
|
||||
static ZoneDefinitionParserValue Character(TokenPos pos, char c);
|
||||
static ZoneDefinitionParserValue String(TokenPos pos, std::string* str);
|
||||
static ZoneDefinitionParserValue Field(TokenPos pos, std::string* field);
|
||||
|
||||
private:
|
||||
ZoneDefinitionParserValue(TokenPos pos, ZoneDefinitionParserValueType type);
|
||||
|
||||
public:
|
||||
~ZoneDefinitionParserValue() override;
|
||||
ZoneDefinitionParserValue(const ZoneDefinitionParserValue& other) = delete;
|
||||
ZoneDefinitionParserValue(ZoneDefinitionParserValue&& other) noexcept;
|
||||
ZoneDefinitionParserValue& operator=(const ZoneDefinitionParserValue& other) = delete;
|
||||
ZoneDefinitionParserValue& operator=(ZoneDefinitionParserValue&& other) noexcept;
|
||||
|
||||
_NODISCARD bool IsEof() const override;
|
||||
_NODISCARD const TokenPos& GetPos() const override;
|
||||
|
||||
_NODISCARD char CharacterValue() const;
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& FieldValue() const;
|
||||
_NODISCARD size_t FieldHash() const;
|
||||
};
|
Reference in New Issue
Block a user