mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-06 06:58:46 +00:00
folder structure refactoring
This commit is contained in:
parent
ef88e6af86
commit
78c696b99a
30 changed files with 40 additions and 22 deletions
102
include/nodes/doc_nodes.hpp
Normal file
102
include/nodes/doc_nodes.hpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
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<std::string *> get_description() {
|
||||
if (description_.has_value()) {
|
||||
return &description_.value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const std::string *> get_description() const {
|
||||
if (description_.has_value()) {
|
||||
return &description_.value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
std::optional<std::string *>
|
||||
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<const std::string *>
|
||||
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 get_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<std::string> description_;
|
||||
std::vector<std::pair<std::string, std::string>> annotations_info_;
|
||||
std::unordered_map<std::string, size_t> annotations_info_ids_;
|
||||
};
|
||||
|
||||
} // namespace nodes
|
||||
Loading…
Add table
Add a link
Reference in a new issue