2023-07-17 23:15:12 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
namespace nodes {
|
2023-07-17 23:15:12 +03:00
|
|
|
|
|
|
|
|
class SymbolDocs {
|
|
|
|
|
public:
|
2023-07-23 19:40:27 +03:00
|
|
|
SymbolDocs() {}
|
|
|
|
|
|
2023-07-17 23:15:12 +03:00
|
|
|
SymbolDocs(std::string &&description)
|
|
|
|
|
: description_(std::move(description)) {}
|
|
|
|
|
|
|
|
|
|
SymbolDocs(const std::string &description) : description_(description) {}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-07-18 16:45:35 +03:00
|
|
|
bool add_annotation_info(const std::string &annotation, T &&info) {
|
2023-07-17 23:15:12 +03:00
|
|
|
if (annotations_info_.count(annotation) == 0) {
|
|
|
|
|
annotations_info_[annotation] = std::forward<T>(info);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-23 19:40:27 +03:00
|
|
|
std::optional<std::string *> get_description() {
|
|
|
|
|
if (description_.has_value()) {
|
|
|
|
|
return &description_.value();
|
|
|
|
|
}
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
2023-07-17 23:15:12 +03:00
|
|
|
|
2023-07-23 19:40:27 +03:00
|
|
|
std::optional<const std::string *> get_description() const {
|
|
|
|
|
if (description_.has_value()) {
|
|
|
|
|
return &description_.value();
|
|
|
|
|
}
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
2023-07-17 23:15:12 +03:00
|
|
|
|
|
|
|
|
std::optional<std::string *>
|
|
|
|
|
get_annotation_info(const std::string &annotation) {
|
|
|
|
|
auto info_iterator = annotations_info_.find(annotation);
|
|
|
|
|
if (info_iterator != annotations_info_.end()) {
|
|
|
|
|
return &info_iterator->second;
|
|
|
|
|
}
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<const std::string *>
|
|
|
|
|
get_annotation_info(const std::string &annotation) const {
|
|
|
|
|
auto info_iterator = annotations_info_.find(annotation);
|
|
|
|
|
if (info_iterator != annotations_info_.end()) {
|
|
|
|
|
return &info_iterator->second;
|
|
|
|
|
}
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2023-07-23 19:40:27 +03:00
|
|
|
std::optional<std::string> description_;
|
2023-07-17 23:15:12 +03:00
|
|
|
std::unordered_map<std::string, std::string> annotations_info_;
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
} // namespace nodes
|