ifw-core 6.0.0
Loading...
Searching...
No Matches
did.hpp
Go to the documentation of this file.
1
6#ifndef IFW_DIT_DID_HPP_
7#define IFW_DIT_DID_HPP_
8
9#include <limits.h>
10
11#include <string>
12
15
16namespace ifw::core::dit::did {
17
19 typedef enum {
20 NONE = 0,
23 ALL
25
29 class Did {
30 public:
41 static std::string SubstituteIndeces(const std::string& key);
42
52 static std::string SubstituteIndex(const std::string& key);
53
54 Did();
55
56 ~Did();
57
70 void Load(const std::string& did_filename, const bool clear = false);
71
73 void Clear();
74
76 const std::vector<std::string>& GetDidsLoaded() const;
77
79 const std::vector<std::string>& GetDidsLoadedCompletePath() const;
80
82 const std::vector<ifw::core::dit::did::Header>& GetHeaders() const;
83
85 bool HasRecord(const std::string& pattern, const bool allow_idx_subst = true) const;
86
97 bool LookUp(const std::string& pattern,
99 const bool allow_idx_subst = true,
100 const bool exception = true) const;
101
112 bool LookUp(const std::string &pattern,
113 std::vector<ifw::core::dit::did::Record>& records,
114 const bool allow_idx_subst = true,
115 const bool exception = false) const;
116
118 void GetKeys(std::vector<std::string>& keys) const;
119
126 std::string ToString(HdrSpec header = HdrSpec::LAST,
127 const std::string& pattern = "",
128 const bool compact = false) const;
129
131 friend std::ostream &operator<<(std::ostream& os, const Did &did);
132
133 private:
134 std::unique_ptr<elt::configng::CiiConfigDocument> m_did_doc;
135
136 // List of dictionaries (filenames) currently loaded
137 // (m_dids_loaded[0] = first DID loaded).
138 std::vector<std::string> m_dids_loaded;
139 std::vector<std::string> m_dids_loaded_complete_path;
140
141 // Maps dictionary filename into the header of that dictionary.
142 std::vector<ifw::core::dit::did::Header> m_headers;
143
144 // Maps keyword names into keyword records.
145 std::map<std::string, ifw::core::dit::did::Record> m_records;
146
147 // Map with alternative keyword names for keys with optional indeces.
148 std::map<std::string, ifw::core::dit::did::Record*> m_alt_records;
149
150 int16_t _LookUp(const std::string& pattern,
151 std::vector<ifw::core::dit::did::Record> &records,
152 const bool allow_idx_subst,
153 const bool exception,
154 const int16_t max_records) const;
155 };
156
157} // namespace ifw::core::dit::did
158
159#endif // !IFW_DIT_DID_HPP_
Data Interface Dictionary class.
Definition did.hpp:29
bool LookUp(const std::string &pattern, std::vector< ifw::core::dit::did::Record > &records, const bool allow_idx_subst=true, const bool exception=false) const
LookUp Scan the dictionary for keys with the given regular expression pattern.
Did()
Definition did.cpp:67
void GetKeys(std::vector< std::string > &keys) const
Generate list of keys defined.
Definition did.cpp:391
void Load(const std::string &did_filename, const bool clear=false)
Load the referenced dictionary.
Definition did.cpp:83
void Clear()
Clear the object.
Definition did.cpp:75
const std::vector< std::string > & GetDidsLoaded() const
Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition did.cpp:198
bool HasRecord(const std::string &pattern, const bool allow_idx_subst=true) const
Check if a record, is contained in the object.
Definition did.cpp:213
~Did()
Definition did.cpp:71
static std::string SubstituteIndeces(const std::string &key)
Substitutes numeric indeces of keyword components to the generic representation.
Definition did.cpp:31
static std::string SubstituteIndex(const std::string &key)
Substitutes a numeric index of a keyword to obtain the generic representation.
Definition did.cpp:12
bool LookUp(const std::string &pattern, ifw::core::dit::did::Record &record, const bool allow_idx_subst=true, const bool exception=true) const
Look up a key in the DIDs loaded. First occurrence taken.
Definition did.cpp:219
friend std::ostream & operator<<(std::ostream &os, const Did &did)
Dump the contents of the class on the output stream.
Definition did.cpp:385
std::string ToString(HdrSpec header=HdrSpec::LAST, const std::string &pattern="", const bool compact=false) const
Create a DID from the content in the object in a string buffer.
Definition did.cpp:304
const std::vector< std::string > & GetDidsLoadedCompletePath() const
Get the complete filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition did.cpp:203
const std::vector< ifw::core::dit::did::Header > & GetHeaders() const
Get the header objects for the DIDs loaded (el [0] = first DID loaded).
Definition did.cpp:208
Data Interface Dictionary keyword record class.
Definition record.hpp:46
Definition defines.cpp:12
HdrSpec
Used to refer to which header(s) to address.
Definition did.hpp:19
@ ALL
Definition did.hpp:23
@ FIRST
Definition did.hpp:21
@ NONE
Definition did.hpp:20
@ LAST
Definition did.hpp:22