#pragma once #include "tree_sitter_wrapper.hpp" #include namespace names { // IN PROGRESS class NameTree { public: struct Node {}; NameTree() {} bool insert_path(const std::vector &path, Node node) {} private: }; class NameStorage; class NameProxy { friend NameStorage; public: NameProxy(NameStorage *name_storage, size_t id) : name_storage_(name_storage), id_(id) {} std::string *get(); const std::string *get() const; bool operator==(const NameProxy &other) const { return name_storage_ == other.name_storage_ && id_ == other.id_; } bool operator<(const NameProxy &other) const { return name_storage_ < other.name_storage_ || (name_storage_ == other.name_storage_ && id_ < other.id_); } private: NameStorage *name_storage_; size_t id_; }; class NameStorage { friend NameProxy; public: NameProxy add_expression(const std::string &name) { storage_.push_back(name); return NameProxy(this, storage_.size() - 1); } NameProxy add_expression(std::string &&name) { storage_.push_back(std::move(name)); return NameProxy(this, storage_.size() - 1); } private: std::string *get_expression(size_t id) { return &storage_.at(id); } const std::string *get_expression(size_t id) const { return &storage_.at(id); } private: std::vector storage_; }; std::vector string_to_path(const std::string &str) { std::vector path; for (;;) { } return path; } // IN PROGRESS } // namespace names