| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // property.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>
- #include "reflection/forward.h"
- namespace reflection {
- class Property {
- private:
- std::string context_;
- std::string type_name_;
- std::vector<std::string> path_;
-
- public:
- explicit Property(std::string const &context = "") : context_(context) {}
-
- template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
- Property(std::string const &context, std::string const & type_name, C const & path)
- : context_(context), type_name_(type_name),
- path_(path.begin(), path.end()) {}
-
- template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
- Property(std::string const & type_name, C const & path)
- : Property("", type_name, path) {}
- std::string_view context() const { return context_; }
-
- std::string_view type_name() const { return type_name_; }
-
- auto begin() const { return path_.begin(); }
- auto end() const { return path_.end(); }
-
- protected:
- friend bool operator<(Property const &lhs, Property const &rhs) {
- return lhs.path_ < rhs.path_;
- }
- };
- }
|