ifw-core  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Did.hpp
Go to the documentation of this file.
1 
9 #ifndef IFW_DIT_DID_HPP_
10 #define IFW_DIT_DID_HPP_
11 
12 #include <limits.h>
13 
14 #include <string>
15 
16 #include "ctd/defines/defines.hpp"
17 
18 #include "dit/did/Header.hpp"
19 #include "dit/did/Record.hpp"
20 
21 
22 namespace dit {
23  namespace did {
24 
26  typedef enum {
32 
36  class Did {
37  public:
38 
49  static std::string SubstituteIndeces(const std::string& key);
50 
60  static std::string SubstituteIndex(const std::string& key);
61 
62 
63  Did();
64 
65  ~Did();
66 
87  void Load(const std::string& did_filename,
88  const bool merge = false);
89 
91  void Clear();
92 
94  const std::vector<std::string>& GetDidsLoaded() const;
95 
97  const std::vector<dit::did::Header>& GetHeaders() const;
98 
100  bool HasRecord(const std::string& pattern,
101  const bool allow_idx_subst = true) const;
102 
113  bool LookUp(const std::string& pattern,
114  dit::did::Record& record,
115  const bool allow_idx_subst = true,
116  const bool exception = true) const;
117 
134  void Scan(const std::string& pattern,
135  std::vector<dit::did::Record>& records,
136  const bool allow_idx_subst = true,
137  const bool stop_first_match = false,
138  const std::list<std::string>& classes = {"*"},
140  const std::string& format_req_ex = "*",
141  const std::string& default_value_reg_ex = "*",
142  const std::string& unit_reg_ex = "*",
143  const std::string& comment_req_ex = "*",
144  const std::list<std::string>& tags_reg_ex = {"*"},
145  const std::string& description_req_ex = "*") const;
146 
157  bool LookUp(const std::string& pattern,
158  std::vector<dit::did::Record>& records,
159  const bool allow_idx_subst = true,
160  const bool exception = false) const;
161 
163  void Add(dit::did::Record& record);
164 
166  void GetKeys(std::vector<std::string>& keys) const;
167 
174  std::string ToString(const HeaderSpecifier header = DID_HDR_LAST,
175  const std::string& pattern = "",
176  const bool compact = false) const;
177 
179  friend std::ostream& operator << (std::ostream& os,
180  const Did& did);
181 
182  private:
183  // Maps keyword names into keyword records.
184  std::map<std::string, dit::did::Record> m_records;
185 
186  // Map with alternative keyword names for keys with optional indeces.
187  std::map<std::string, dit::did::Record*> m_alt_records;
188 
189  // List of dictionaries (filenames) currently loaded
190  // (m_dids_loaded[0] = first DID loaded).
191  std::vector<std::string> m_dids_loaded;
192 
193  // Maps dictionary filename into the header of that dictionary.
194  std::vector<dit::did::Header> m_headers;
195 
197  void _Load(const std::string& did_filename,
198  int8_t& recurse_level);
199 
200  int16_t _LookUp(const std::string& pattern,
201  std::vector<dit::did::Record>& records,
202  const bool allow_idx_subst,
203  const bool exception,
204  const int16_t max_records) const;
205 
206  };
207 
208  }
209 }
210 
211 #endif // !IFW_DIT_DID_HPP_
~Did()
Definition: Did.cpp:72
Definition: types.hpp:51
Definition: Did.hpp:30
Definition: Did.hpp:27
void Scan(const std::string &pattern, std::vector< dit::did::Record > &records, const bool allow_idx_subst=true, const bool stop_first_match=false, const std::list< std::string > &classes={"*"}, const ctd::defines::DataType data_types=ctd::defines::DATA_TYPE_ALL, const std::string &format_req_ex="*", const std::string &default_value_reg_ex="*", const std::string &unit_reg_ex="*", const std::string &comment_req_ex="*", const std::list< std::string > &tags_reg_ex={"*"}, const std::string &description_req_ex="*") const
Scan dictionary for key records with the given properties.
Definition: Did.cpp:370
const std::vector< std::string > & GetDidsLoaded() const
Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition: Did.cpp:165
Class to handle the header in a DID.
Did()
Definition: Did.cpp:67
Definition: Did.hpp:29
friend std::ostream & operator<<(std::ostream &os, const Did &did)
Dump the contents of the class on the output stream.
Definition: Did.cpp:361
Common definitions.
void Clear()
Clear the object.
Definition: Did.cpp:77
void GetKeys(std::vector< std::string > &keys) const
Generate list of keys defined.
Definition: Did.cpp:389
DataType
Data types numeric representations.
Definition: types.hpp:34
bool LookUp(const std::string &pattern, 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:188
Class to handle a DID Record.
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:179
void Add(dit::did::Record &record)
Add a keyword record in the dictionary object.
Definition: Did.cpp:279
static std::string SubstituteIndeces(const std::string &key)
Substitutes numeric indeces of keyword components to the generic representation.
Definition: Did.cpp:35
HeaderSpecifier
Used to refer to which header(s) to address.
Definition: Did.hpp:26
Data Interface Dictionary keyword record class.
Definition: Record.hpp:158
Definition: Did.hpp:28
void Load(const std::string &did_filename, const bool merge=false)
Load the referenced dictionary.
Definition: Did.cpp:86
static std::string SubstituteIndex(const std::string &key)
Substitutes a numeric index of a keyword to obtain the generic representation.
Definition: Did.cpp:15
const std::vector< dit::did::Header > & GetHeaders() const
Get the header objects for the DIDs loaded (el [0] = first DID loaded).
Definition: Did.cpp:172
Data Interface Dictionary class.
Definition: Did.hpp:36
std::string ToString(const HeaderSpecifier header=DID_HDR_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:287