diff options
author | peterbell10 <peterbell10@live.co.uk> | 2018-02-05 00:07:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-05 00:07:12 +0100 |
commit | d3c1c626f569e5aa58085425924cca45927b6199 (patch) | |
tree | c65dee850358467c9afebdd37fcd4f6fb95a475a /src/WorldStorage/FastNBT.cpp | |
parent | cChunk and cChunkData: Use vectors for block get and set functions (#4172) (diff) | |
download | cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.gz cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.bz2 cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.lz cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.xz cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.zst cuberite-d3c1c626f569e5aa58085425924cca45927b6199.zip |
Diffstat (limited to 'src/WorldStorage/FastNBT.cpp')
-rw-r--r-- | src/WorldStorage/FastNBT.cpp | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 237773733..99148e126 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -35,6 +35,35 @@ static const int MAX_LIST_ITEMS = 10000; //////////////////////////////////////////////////////////////////////////////// // cNBTParseErrorCategory: +namespace +{ + +class cNBTParseErrorCategory final : + public std::error_category +{ + cNBTParseErrorCategory() = default; +public: + /** Category name */ + virtual const char * name() const NOEXCEPT override + { + return "NBT parse error"; + } + + /** Maps a parse error code to an error message */ + virtual AString message(int a_Condition) const override; + + /** Returns the canonical error category instance. */ + static const cNBTParseErrorCategory & Get() NOEXCEPT + { + static cNBTParseErrorCategory Category; + return Category; + } +}; + + + + + AString cNBTParseErrorCategory::message(int a_Condition) const { switch (static_cast<eNBTParseError>(a_Condition)) @@ -91,22 +120,19 @@ AString cNBTParseErrorCategory::message(int a_Condition) const { return "Unknown tag"; } + } + UNREACHABLE("Unsupported nbt parse error"); +} - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wcovered-switch-default" - #pragma clang diagnostic ignored "-Wunreachable-code" - #endif +} // namespace (anonymous) - default: - { - return "<unrecognized error>"; - } - #ifdef __clang__ - #pragma clang diagnostic pop - #endif - } + + + +std::error_code make_error_code(eNBTParseError a_Err) NOEXCEPT +{ + return { static_cast<int>(a_Err), cNBTParseErrorCategory::Get() }; } @@ -337,14 +363,12 @@ eNBTParseError cParsedNBT::ReadTag(void) return eNBTParseError::npSuccess; } - #if !defined(__clang__) - default: - #endif case TAG_Min: { return eNBTParseError::npUnknownTag; } } // switch (iType) + UNREACHABLE("Unsupported nbt tag type"); } #undef CASE_SIMPLE_TAG |