Disabled unused variable and fallthrough warnings from std. Changed Store to be a template with tag that is used with a using declaration.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#ifndef ESX_READER_HPP
|
||||
#define ESX_READER_HPP
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 5264 )
|
||||
#pragma warning( disable : 5262 )
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
#include <array>
|
||||
@@ -9,6 +12,7 @@
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <fstream>
|
||||
#pragma warning( pop )
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
@@ -58,10 +62,10 @@ enum class RecordType {
|
||||
// Aggregate types
|
||||
//
|
||||
|
||||
struct FourCC : utility::Store<FourCC, uint32_t> { };
|
||||
struct FormID : utility::Store<FormID, uint32_t> { };
|
||||
struct Timestamp : utility::Store<Timestamp, uint16_t> { };
|
||||
struct VCInfo : utility::Store<VCInfo, uint16_t> { };
|
||||
using FourCC = utility::Store<struct FourCCTag , uint32_t>;
|
||||
using FormID = utility::Store<struct FormIDTag , uint32_t>;
|
||||
using Timestamp = utility::Store<struct TimestampTag, uint16_t>;
|
||||
using VCInfo = utility::Store<struct VCInfoTag , uint16_t>;
|
||||
|
||||
struct Flag {
|
||||
RecordType type;
|
||||
@@ -85,14 +89,14 @@ struct GroupHeader {
|
||||
int16_t y, x;
|
||||
};
|
||||
|
||||
struct TopType : utility::Store<TopType, FourCC> { };
|
||||
struct ParentWorld : utility::Store<ParentWorld, FormID> { };
|
||||
struct BlockNumber : utility::Store<BlockNumber, int32_t> { };
|
||||
struct SubBlockNumber : utility::Store<SubBlockNumber, int32_t> { };
|
||||
struct BlockCoord : utility::Store<BlockCoord, Coord> { };
|
||||
struct SubBlockCoord : utility::Store<SubBlockCoord, Coord> { };
|
||||
struct ParentCell : utility::Store<ParentCell, FormID> { };
|
||||
struct ParentDialogue : utility::Store<ParentDialogue, FormID> { };
|
||||
using TopType = utility::Store<struct TopTypeTag , FourCC >;
|
||||
using ParentWorld = utility::Store<struct ParentWorldTag , FormID >;
|
||||
using BlockNumber = utility::Store<struct BlockNumberTag , int32_t>;
|
||||
using SubBlockNumber = utility::Store<struct SubBlockNumberTag, int32_t>;
|
||||
using BlockCoord = utility::Store<struct BlockCoordTag , Coord >;
|
||||
using SubBlockCoord = utility::Store<struct SubBlockCoordTag , Coord >;
|
||||
using ParentCell = utility::Store<struct ParentCellTag , FormID >;
|
||||
using ParentDialogue = utility::Store<struct ParentDialogueTag, FormID >;
|
||||
|
||||
union GroupLabel {
|
||||
TopType top_type;
|
||||
@@ -115,8 +119,8 @@ struct GroupHeader {
|
||||
};
|
||||
|
||||
struct RecordHeader {
|
||||
struct Flags : utility::Store<Flags, uint32_t> { };
|
||||
struct Version : utility::Store<Version, uint16_t> { };
|
||||
using Flags = utility::Store<struct FlagsTag , uint32_t>;
|
||||
using Version = utility::Store<struct VersionTag, uint16_t>;
|
||||
|
||||
FourCC type;
|
||||
uint32_t size;
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include "esx_reader.hpp"
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 5264 )
|
||||
#pragma warning( disable : 5262 )
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#pragma warning( pop )
|
||||
|
||||
static constexpr auto esx_name = "Skyrim.esm";
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#ifndef UTILITY_HPP
|
||||
#define UTILITY_HPP
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 5264 )
|
||||
#pragma warning( disable : 5262 )
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <bit>
|
||||
#pragma warning( pop )
|
||||
|
||||
namespace utility {
|
||||
|
||||
@@ -15,12 +19,10 @@ T::size_type index_of(const T &container, typename T::const_iterator &iter)
|
||||
return static_cast<T::size_type>(distance);
|
||||
}
|
||||
|
||||
// This is a base class for a generic store for some value that can be represented by
|
||||
// type Type but should not be type checked as type Type, but rather some more constrained class.
|
||||
// CRTP is the derived class, and is used as a tag to prevent having Store as a base class to
|
||||
// multiple derived types.
|
||||
template <typename CRTP, typename Type>
|
||||
struct Store {
|
||||
// Along the lines of https://github.com/joboccara/NamedType
|
||||
// Usage: using StoreType = Store<struct StoreTypeTag, type>;
|
||||
template <typename Tag, typename Type>
|
||||
struct Store final {
|
||||
static_assert(std::is_trivial_v<Type>);
|
||||
Type value;
|
||||
friend constexpr auto operator<=>(const Store &, const Store &) = default;
|
||||
|
||||
Reference in New Issue
Block a user