diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d1220f..962cea32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,6 +409,7 @@ list ( parallel/queue.hpp parallel/stack.cpp parallel/stack.hpp + parse/fwd.hpp parse/enum.cpp parse/enum.hpp parse/time.cpp diff --git a/parse/enum.hpp b/parse/enum.hpp index 249a3a49..257f0190 100644 --- a/parse/enum.hpp +++ b/parse/enum.hpp @@ -8,6 +8,8 @@ #pragma once +#include "fwd.hpp" + #include "../view.hpp" #include "../introspection.hpp" #include "../log.hpp" @@ -90,7 +92,7 @@ namespace cruft::parse::enumeration { template - void setup (std::map mapping) + cookie setup [[nodiscard]] (std::map mapping) { auto &cache = detail::cache (); @@ -100,7 +102,9 @@ namespace cruft::parse::enumeration { auto [pos, success] = cache.insert ({ index, std::move (lookup) }); if (!success) LOG_WARN ("duplicate parse setup for %! was ignored", cruft::type_name ()); - } + + return cookie {}; + }; template diff --git a/parse/fwd.hpp b/parse/fwd.hpp new file mode 100644 index 00000000..cbbca48b --- /dev/null +++ b/parse/fwd.hpp @@ -0,0 +1,15 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 2019, Danny Robson + */ + +#pragma once + +namespace cruft::parse { + namespace enumeration { + struct cookie {}; + } +} diff --git a/test/parse/enum.cpp b/test/parse/enum.cpp index 2c54a28b..9be1fbd1 100644 --- a/test/parse/enum.cpp +++ b/test/parse/enum.cpp @@ -7,11 +7,12 @@ enum enumeration_t : u16 { FOO, BAR = 2, QUX = 257 }; int main () { - cruft::parse::enumeration::setup ({ + auto const cookie = cruft::parse::enumeration::setup ({ { "FOO", FOO }, { "BAR", BAR }, { "QUX", QUX }, }); + (void)cookie; cruft::TAP::logger tap; tap.expect_eq (FOO, cruft::parse::from_string ("FOO"), "enumeration, FOO");