COOPENOMICS  v1
Кооперативная Экономика
shared_document.hpp
См. документацию.
1namespace Document {
7 inline void validate_registry_id(document2 document, uint64_t expected_registry_id) {
8 uint64_t registry_id = extract_registry_id_from_meta(document.meta);
9 eosio::check(registry_id == expected_registry_id, "Передан неверный шаблон документа");
10 }
11
18 };
19
26 inline void add_document(std::vector<named_document>& docs, const name& name, const document2& doc) {
27 docs.push_back({name, doc});
28 }
29
37 inline bool find_document(const std::vector<named_document>& docs, const name& name, document2& found_doc) {
38 for (const auto& nd : docs) {
39 if (nd.name == name) {
40 found_doc = nd.document;
41 return true;
42 }
43 }
44 return false;
45 }
46
53 inline bool has_document(const std::vector<named_document>& docs, const name& name) {
54 for (const auto& nd : docs) {
55 if (nd.name == name) {
56 return true;
57 }
58 }
59 return false;
60 }
61
62}
Definition: shared_document.hpp:1
bool has_document(const std::vector< named_document > &docs, const name &name)
Проверить наличие документа
Definition: shared_document.hpp:53
void add_document(std::vector< named_document > &docs, const name &name, const document2 &doc)
Добавить документ с проверкой длины имени
Definition: shared_document.hpp:26
void validate_registry_id(document2 document, uint64_t expected_registry_id)
Проверяет, что переданный документ соответствует ожидаемому шаблону
Definition: shared_document.hpp:7
bool find_document(const std::vector< named_document > &docs, const name &name, document2 &found_doc)
Найти документ по имени
Definition: shared_document.hpp:37
Структура именованного документа
Definition: shared_document.hpp:15
name name
Definition: shared_document.hpp:16
document2 document
Definition: shared_document.hpp:17
Definition: drafts.hpp:28
Definition: drafts.hpp:7
std::string meta
Definition: drafts.hpp:15
uint64_t extract_registry_id_from_meta(const std::string &meta_json)
Definition: utils.hpp:73