property.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // property.h
  3. // reflection
  4. //
  5. // Created by Sam Jaffe on 2/20/23.
  6. // Copyright © 2023 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <string>
  10. #include <string_view>
  11. #include <vector>
  12. #include "reflection/forward.h"
  13. namespace reflection {
  14. class Property {
  15. private:
  16. std::string context_;
  17. std::string type_name_;
  18. std::vector<std::string> path_;
  19. public:
  20. explicit Property(std::string const &context = "") : context_(context) {}
  21. template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
  22. Property(std::string const &context, std::string const & type_name, C const & path)
  23. : context_(context), type_name_(type_name),
  24. path_(path.begin(), path.end()) {}
  25. template <typename C, typename = std::enable_if_t<IS_SCOPE_CONTAINER(C)>>
  26. Property(std::string const & type_name, C const & path)
  27. : Property("", type_name, path) {}
  28. std::string_view context() const { return context_; }
  29. std::string_view type_name() const { return type_name_; }
  30. auto begin() const { return path_.begin(); }
  31. auto end() const { return path_.end(); }
  32. };
  33. }