ifw-core 7.0.0
 
Loading...
Searching...
No Matches
did.hpp
Go to the documentation of this file.
1
6
7#ifndef IFW_DIT_DID_HPP_
8#define IFW_DIT_DID_HPP_
9
10#include <limits.h>
11
12#include <string>
13
16
17namespace ifw::core::dit::did {
18
20 typedef enum {
21 NONE = 0,
25 } HdrSpec;
26
30 class Did {
31 public:
42 static std::string SubstituteIndeces(const std::string& key);
43
53 static std::string SubstituteIndex(const std::string& key);
54
55 Did();
56
57 ~Did();
58
71 void Load(const std::string& did_filename, const bool clear = false);
72
74 void Clear();
75
77 const std::vector<std::string>& GetDidsLoaded() const;
78
80 const std::vector<std::string>& GetDidsLoadedCompletePath() const;
81
83 const std::vector<ifw::core::dit::did::Header>& GetHeaders() const;
84
86 bool HasRecord(const std::string& pattern, const bool allow_idx_subst = true) const;
87
98 bool LookUp(const std::string& pattern,
100 const bool allow_idx_subst = true,
101 const bool exception = true) const;
102
113 bool LookUp(const std::string &pattern,
114 std::vector<ifw::core::dit::did::Record>& records,
115 const bool allow_idx_subst = true,
116 const bool exception = false) const;
117
119 void GetKeys(std::vector<std::string>& keys) const;
120
127 std::string ToString(HdrSpec header = HdrSpec::LAST,
128 const std::string& pattern = "",
129 const bool compact = false) const;
130
132 friend std::ostream &operator<<(std::ostream& os, const Did &did);
133
134 private:
135 std::unique_ptr<elt::configng::CiiConfigDocument> m_did_doc;
136
137 // List of dictionaries (filenames) currently loaded
138 // (m_dids_loaded[0] = first DID loaded).
139 std::vector<std::string> m_dids_loaded;
140 std::vector<std::string> m_dids_loaded_complete_path;
141
142 // Maps dictionary filename into the header of that dictionary.
143 std::vector<ifw::core::dit::did::Header> m_headers;
144
145 // Maps keyword names into keyword records.
146 std::map<std::string, ifw::core::dit::did::Record> m_records;
147
148 // Map with alternative keyword names for keys with optional indeces.
149 std::map<std::string, ifw::core::dit::did::Record*> m_alt_records;
150
151 int16_t _LookUp(const std::string& pattern,
152 std::vector<ifw::core::dit::did::Record> &records,
153 const bool allow_idx_subst,
154 const bool exception,
155 const int16_t max_records) const;
156 };
157
158} // namespace ifw::core::dit::did
159
160#endif // !IFW_DIT_DID_HPP_
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:69
void GetKeys(std::vector< std::string > &keys) const
Generate list of keys defined.
Definition did.cpp:393
void Load(const std::string &did_filename, const bool clear=false)
Load the referenced dictionary.
Definition did.cpp:85
void Clear()
Clear the object.
Definition did.cpp:77
const std::vector< std::string > & GetDidsLoaded() const
Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition did.cpp:200
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:215
~Did()
Definition did.cpp:73
static std::string SubstituteIndeces(const std::string &key)
Substitutes numeric indeces of keyword components to the generic representation.
Definition did.cpp:33
static std::string SubstituteIndex(const std::string &key)
Substitutes a numeric index of a keyword to obtain the generic representation.
Definition did.cpp:14
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:221
friend std::ostream & operator<<(std::ostream &os, const Did &did)
Dump the contents of the class on the output stream.
Definition did.cpp:387
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:306
const std::vector< std::string > & GetDidsLoadedCompletePath() const
Get the complete filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition did.cpp:205
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:210
Data Interface Dictionary keyword record class.
Definition record.hpp:49
Definition defines.cpp:15
HdrSpec
Used to refer to which header(s) to address.
Definition did.hpp:20
@ ALL
Definition did.hpp:24
@ FIRST
Definition did.hpp:22
@ NONE
Definition did.hpp:21
@ LAST
Definition did.hpp:23