mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Move common structureddatadef classes to objcommon
This commit is contained in:
@ -1,13 +0,0 @@
|
||||
#include "CommonStructuredDataDef.h"
|
||||
|
||||
CommonStructuredDataDef::CommonStructuredDataDef()
|
||||
: CommonStructuredDataDef(0)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataDef::CommonStructuredDataDef(const int version)
|
||||
: m_version(version),
|
||||
m_checksum(0u),
|
||||
m_size_in_byte(0u)
|
||||
{
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CommonStructuredDataEnum.h"
|
||||
#include "CommonStructuredDataStruct.h"
|
||||
|
||||
class CommonStructuredDataDef
|
||||
{
|
||||
public:
|
||||
std::vector<std::unique_ptr<CommonStructuredDataEnum>> m_enums;
|
||||
std::vector<std::unique_ptr<CommonStructuredDataStruct>> m_structs;
|
||||
std::vector<CommonStructuredDataIndexedArray> m_indexed_arrays;
|
||||
std::vector<CommonStructuredDataEnumedArray> m_enumed_arrays;
|
||||
|
||||
int m_version;
|
||||
size_t m_checksum;
|
||||
CommonStructuredDataType m_root_type;
|
||||
size_t m_size_in_byte;
|
||||
|
||||
CommonStructuredDataDef();
|
||||
explicit CommonStructuredDataDef(int version);
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
#include "CommonStructuredDataEnum.h"
|
||||
|
||||
CommonStructuredDataEnumEntry::CommonStructuredDataEnumEntry()
|
||||
: m_value(0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnumEntry::CommonStructuredDataEnumEntry(std::string name, const size_t value)
|
||||
: m_name(std::move(name)),
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnum::CommonStructuredDataEnum()
|
||||
: m_reserved_entry_count(-1)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnum::CommonStructuredDataEnum(std::string name)
|
||||
: m_name(std::move(name)),
|
||||
m_reserved_entry_count(-1)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnum::CommonStructuredDataEnum(std::string name, const int reservedEntryCount)
|
||||
: m_name(std::move(name)),
|
||||
m_reserved_entry_count(reservedEntryCount)
|
||||
{
|
||||
}
|
||||
|
||||
size_t CommonStructuredDataEnum::ElementCount() const
|
||||
{
|
||||
return m_reserved_entry_count > 0 ? static_cast<size_t>(m_reserved_entry_count) : m_entries.size();
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
struct CommonStructuredDataEnumEntry
|
||||
{
|
||||
std::string m_name;
|
||||
size_t m_value;
|
||||
|
||||
CommonStructuredDataEnumEntry();
|
||||
CommonStructuredDataEnumEntry(std::string name, size_t value);
|
||||
};
|
||||
|
||||
struct CommonStructuredDataEnum
|
||||
{
|
||||
std::string m_name;
|
||||
int m_reserved_entry_count;
|
||||
std::vector<CommonStructuredDataEnumEntry> m_entries;
|
||||
|
||||
CommonStructuredDataEnum();
|
||||
explicit CommonStructuredDataEnum(std::string name);
|
||||
CommonStructuredDataEnum(std::string name, int reservedEntryCount);
|
||||
|
||||
_NODISCARD size_t ElementCount() const;
|
||||
};
|
@ -1,32 +0,0 @@
|
||||
#include "CommonStructuredDataStruct.h"
|
||||
|
||||
CommonStructuredDataStructEntry::CommonStructuredDataStructEntry()
|
||||
: m_offset_in_bits(0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataStructEntry::CommonStructuredDataStructEntry(std::string name)
|
||||
: m_name(std::move(name)),
|
||||
m_offset_in_bits(0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataStructEntry::CommonStructuredDataStructEntry(std::string name, const CommonStructuredDataType type, const size_t offsetInBits)
|
||||
: m_name(std::move(name)),
|
||||
m_type(type),
|
||||
m_offset_in_bits(offsetInBits)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataStruct::CommonStructuredDataStruct()
|
||||
: m_bit_offset(0u),
|
||||
m_size_in_byte(0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataStruct::CommonStructuredDataStruct(std::string name)
|
||||
: m_name(std::move(name)),
|
||||
m_bit_offset(0u),
|
||||
m_size_in_byte(0u)
|
||||
{
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "CommonStructuredDataTypes.h"
|
||||
|
||||
struct CommonStructuredDataStructEntry
|
||||
{
|
||||
std::string m_name;
|
||||
CommonStructuredDataType m_type;
|
||||
size_t m_offset_in_bits;
|
||||
|
||||
CommonStructuredDataStructEntry();
|
||||
explicit CommonStructuredDataStructEntry(std::string name);
|
||||
CommonStructuredDataStructEntry(std::string name, CommonStructuredDataType type, size_t offsetInBits);
|
||||
};
|
||||
|
||||
struct CommonStructuredDataStruct
|
||||
{
|
||||
std::string m_name;
|
||||
std::vector<CommonStructuredDataStructEntry> m_properties;
|
||||
size_t m_bit_offset;
|
||||
size_t m_size_in_byte;
|
||||
|
||||
CommonStructuredDataStruct();
|
||||
explicit CommonStructuredDataStruct(std::string name);
|
||||
};
|
@ -1,126 +0,0 @@
|
||||
#include "CommonStructuredDataTypes.h"
|
||||
|
||||
CommonStructuredDataType::CommonStructuredDataType()
|
||||
: m_category(CommonStructuredDataTypeCategory::UNKNOWN),
|
||||
m_info({0})
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataType::CommonStructuredDataType(const CommonStructuredDataTypeCategory category)
|
||||
: m_category(category),
|
||||
m_info({0})
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataType::CommonStructuredDataType(const CommonStructuredDataTypeCategory category, const size_t extraInfo)
|
||||
: m_category(category),
|
||||
m_info({extraInfo})
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs)
|
||||
{
|
||||
if (lhs.m_category < rhs.m_category)
|
||||
return true;
|
||||
if (rhs.m_category < lhs.m_category)
|
||||
return false;
|
||||
return lhs.m_info.type_index < rhs.m_info.type_index;
|
||||
}
|
||||
|
||||
bool operator<=(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
bool operator>(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
bool operator>=(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
CommonStructuredDataIndexedArray::CommonStructuredDataIndexedArray()
|
||||
: CommonStructuredDataIndexedArray({}, 0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataIndexedArray::CommonStructuredDataIndexedArray(const CommonStructuredDataType type, const size_t elementCount)
|
||||
: CommonStructuredDataIndexedArray(type, elementCount, 0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataIndexedArray::CommonStructuredDataIndexedArray(const CommonStructuredDataType type, const size_t elementCount, const size_t elementSize)
|
||||
: m_array_type(type),
|
||||
m_element_count(elementCount),
|
||||
m_element_size_in_bits(elementSize)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs)
|
||||
{
|
||||
if (lhs.m_array_type < rhs.m_array_type)
|
||||
return true;
|
||||
if (rhs.m_array_type < lhs.m_array_type)
|
||||
return false;
|
||||
return lhs.m_element_count < rhs.m_element_count;
|
||||
}
|
||||
|
||||
bool operator<=(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
bool operator>(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
bool operator>=(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
CommonStructuredDataEnumedArray::CommonStructuredDataEnumedArray()
|
||||
: CommonStructuredDataEnumedArray({}, 0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnumedArray::CommonStructuredDataEnumedArray(const CommonStructuredDataType type, const size_t enumIndex)
|
||||
: CommonStructuredDataEnumedArray(type, enumIndex, 0u, 0u)
|
||||
{
|
||||
}
|
||||
|
||||
CommonStructuredDataEnumedArray::CommonStructuredDataEnumedArray(const CommonStructuredDataType type, const size_t enumIndex, const size_t elementCount, const size_t elementSizeInBits)
|
||||
: m_array_type(type),
|
||||
m_enum_index(enumIndex),
|
||||
m_element_count(elementCount),
|
||||
m_element_size_in_bits(elementSizeInBits)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs)
|
||||
{
|
||||
if (lhs.m_array_type < rhs.m_array_type)
|
||||
return true;
|
||||
if (rhs.m_array_type < lhs.m_array_type)
|
||||
return false;
|
||||
return lhs.m_enum_index < rhs.m_enum_index;
|
||||
}
|
||||
|
||||
bool operator<=(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
bool operator>(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
bool operator>=(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
enum class CommonStructuredDataTypeCategory
|
||||
{
|
||||
UNKNOWN,
|
||||
INT,
|
||||
BYTE,
|
||||
BOOL,
|
||||
FLOAT,
|
||||
SHORT,
|
||||
STRING,
|
||||
ENUM,
|
||||
STRUCT,
|
||||
INDEXED_ARRAY,
|
||||
ENUM_ARRAY
|
||||
};
|
||||
|
||||
union CommonStructuredDataTypeExtraInfo
|
||||
{
|
||||
size_t string_length;
|
||||
size_t type_index;
|
||||
};
|
||||
|
||||
struct CommonStructuredDataType
|
||||
{
|
||||
CommonStructuredDataTypeCategory m_category;
|
||||
CommonStructuredDataTypeExtraInfo m_info;
|
||||
|
||||
CommonStructuredDataType();
|
||||
explicit CommonStructuredDataType(CommonStructuredDataTypeCategory category);
|
||||
CommonStructuredDataType(CommonStructuredDataTypeCategory category, size_t extraInfo);
|
||||
|
||||
friend bool operator<(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs);
|
||||
friend bool operator<=(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs);
|
||||
friend bool operator>(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs);
|
||||
friend bool operator>=(const CommonStructuredDataType& lhs, const CommonStructuredDataType& rhs);
|
||||
};
|
||||
|
||||
struct CommonStructuredDataIndexedArray
|
||||
{
|
||||
CommonStructuredDataType m_array_type;
|
||||
size_t m_element_count;
|
||||
size_t m_element_size_in_bits;
|
||||
|
||||
CommonStructuredDataIndexedArray();
|
||||
CommonStructuredDataIndexedArray(CommonStructuredDataType type, size_t elementCount);
|
||||
CommonStructuredDataIndexedArray(CommonStructuredDataType type, size_t elementCount, size_t elementSize);
|
||||
|
||||
friend bool operator<(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs);
|
||||
friend bool operator<=(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs);
|
||||
friend bool operator>(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs);
|
||||
friend bool operator>=(const CommonStructuredDataIndexedArray& lhs, const CommonStructuredDataIndexedArray& rhs);
|
||||
};
|
||||
|
||||
struct CommonStructuredDataEnumedArray
|
||||
{
|
||||
CommonStructuredDataType m_array_type;
|
||||
size_t m_enum_index;
|
||||
size_t m_element_count;
|
||||
size_t m_element_size_in_bits;
|
||||
|
||||
CommonStructuredDataEnumedArray();
|
||||
CommonStructuredDataEnumedArray(CommonStructuredDataType type, size_t enumIndex);
|
||||
CommonStructuredDataEnumedArray(CommonStructuredDataType type, size_t enumIndex, size_t elementCount, size_t elementSizeInBits);
|
||||
|
||||
friend bool operator<(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs);
|
||||
friend bool operator<=(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs);
|
||||
friend bool operator>(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs);
|
||||
friend bool operator>=(const CommonStructuredDataEnumedArray& lhs, const CommonStructuredDataEnumedArray& rhs);
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "StructuredDataDefParserState.h"
|
||||
#include "Domain/CommonStructuredDataDef.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Parsing/Simple/SimpleParserValue.h"
|
||||
#include "Parsing/Impl/AbstractParser.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
#include "Domain/CommonStructuredDataDef.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
|
||||
namespace sdd
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Domain/CommonStructuredDataDef.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
|
||||
class StructuredDataDefReader
|
||||
|
Reference in New Issue
Block a user