#pragma once #include #include #include #include namespace nodes { class SymbolDocs { public: SymbolDocs() {} SymbolDocs(std::string &&description) : description_(std::move(description)) {} SymbolDocs(const std::string &description) : description_(description) {} bool add_annotation_info(const std::string &annotation, std::string &&info) { if (annotations_info_ids_.count(annotation) == 0) { annotations_info_ids_[annotation] = annotations_info_.size(); annotations_info_.emplace_back(annotation, std::move(info)); return true; } return false; } bool add_annotation_info(const std::string &annotation, const std::string &info) { if (annotations_info_ids_.count(annotation) == 0) { annotations_info_ids_[annotation] = annotations_info_.size(); annotations_info_.emplace_back(annotation, std::move(info)); return true; } return false; } // std::optional get_description() { if (description_.has_value()) { return &description_.value(); } return std::nullopt; } std::optional get_description() const { if (description_.has_value()) { return &description_.value(); } return std::nullopt; } // std::optional get_annotation_info(const std::string &annotation) { auto info_iterator = annotations_info_ids_.find(annotation); if (info_iterator != annotations_info_ids_.end()) { return &annotations_info_[info_iterator->second].second; } return std::nullopt; } std::optional get_annotation_info(const std::string &annotation) const { auto info_iterator = annotations_info_ids_.find(annotation); if (info_iterator != annotations_info_ids_.end()) { return &annotations_info_[info_iterator->second].second; } return std::nullopt; } // size_t annotations_info_size() const { return annotations_info_.size(); } std::string *get_annotation(size_t id) { return &annotations_info_[id].first; } const std::string *get_annotation(size_t id) const { return &annotations_info_[id].first; } std::string *get_annotation_info(size_t id) { return &annotations_info_[id].second; } const std::string *get_annotation_info(size_t id) const { return &annotations_info_[id].second; } // private: std::optional description_; std::vector> annotations_info_; std::unordered_map annotations_info_ids_; }; } // namespace nodes