| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- //
- // scope.h
- // reflection
- //
- // Created by Sam Jaffe on 2/20/23.
- // Copyright © 2023 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <string>
- #include <string_view>
- #include <vector>
- namespace reflection {
- class Scope {
- private:
- std::string type_name_;
- std::vector<std::string> path_;
-
- public:
- template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
- Scope(std::string const & type_name, C const & path)
- : type_name_(type_name), path_(path.begin(), path.end()) {}
- Scope(std::string const & type_name, std::vector<std::string> const & path)
- : type_name_(type_name), path_(path) {}
-
- std::string_view type_name() const { return type_name_; }
- auto begin() const { return path_.begin(); }
- auto end() const { return path_.end(); }
- };
- class ContextScope : public Scope {
- private:
- std::string context_;
-
- public:
- template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
- ContextScope(std::string const & context, std::string const & type_name,
- C const & path)
- : context_(context), Scope(type_name, path) {}
- std::string_view context() const { return context_; }
- };
- }
|