symbol docs module implemented, part of file tree implemented

This commit is contained in:
ProgramSnail 2023-07-17 23:15:12 +03:00
parent b56b72c98e
commit 100779d2d4
6 changed files with 232 additions and 55 deletions

52
include/docs.hpp Normal file
View file

@ -0,0 +1,52 @@
#pragma once
#include <optional>
#include <string>
#include <unordered_map>
namespace file {
class SymbolDocs {
public:
SymbolDocs(std::string &&description)
: description_(std::move(description)) {}
SymbolDocs(const std::string &description) : description_(description) {}
template <typename T>
bool set_annotation_info(const std::string &annotation, T &&info) {
if (annotations_info_.count(annotation) == 0) {
annotations_info_[annotation] = std::forward<T>(info);
return true;
}
return false;
}
std::string *get_description() { return &description_; }
const std::string *get_description() const { return &description_; }
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:
std::string description_;
std::unordered_map<std::string, std::string> annotations_info_;
};
} // namespace file