// // context.h // reflection // // Created by Sam Jaffe on 8/6/22. // Copyright © 2022 Sam Jaffe. All rights reserved. // #pragma once #include #include #include "reflection/forward.h" #include "reflection/object.h" namespace reflection { class Context { public: struct Arg : std::pair { template Arg(std::string_view id, T &&value) : pair(id, Object(std::forward(value), std::string(id))) {} Arg(Object &&obj) : pair("", std::move(obj)) { first = second.name(); } }; public: explicit Context(std::initializer_list data) : data_(data.begin(), data.end()) {} Object get(std::string_view id) const { return data_.at(id); } template ()))>>> Object get(C const & container) const { return Object::get(get(*std::begin(container)), ++std::begin(container), std::end(container)); } private: std::unordered_map data_; }; }