ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
13 #include "ctd/defines/defines.hpp"
14 
15 #include "dit/did/Header.hpp"
16 #include "dit/did/Record.hpp"
17 
18 
19 namespace dit {
20 namespace did {
21 
25 class Did {
26 public:
27 
38  static std::string SubstituteIndeces(const std::string& key);
39 
49  static std::string SubstituteIndex(const std::string& key);
50 
51  typedef enum {
52  DID_HDR_NONE = 0,
57 
58  Did();
59 
60  ~Did();
61 
82  void Load(const std::string& did_filename,
83  const bool merge = false);
84 
86  void Clear();
87 
90 
93 
95  bool HasRecord(const std::string& pattern,
96  const bool allow_idx_subst = true) const;
97 
108  bool LookUp(const std::string& pattern,
109  dit::did::Record& record,
110  const bool allow_idx_subst = true,
111  const bool exception = true) const;
112 
129  void Scan(const std::string& pattern,
131  const bool allow_idx_subst = true,
132  const bool stop_first_match = false,
133  const std::list<std::string>& classes = {"*"},
135  const std::string& format_req_ex = "*",
136  const std::string& default_value_reg_ex = "*",
137  const std::string& unit_reg_ex = "*",
138  const std::string& comment_req_ex = "*",
139  const std::list<std::string>& tags_reg_ex = {"*"},
140  const std::string& description_req_ex = "*") const;
141 
152  bool LookUp(const std::string& pattern,
154  const bool allow_idx_subst = true,
155  const bool exception = false) const;
156 
158  void Add(dit::did::Record& record);
159 
161  void GetKeys(ctd::defines::List<std::string>& keys) const;
162 
169  std::string Print(const HeaderSpecifier print_header = DID_HDR_LAST,
170  const std::string& pattern = "",
171  const bool compact = false) const;
172 
173 private:
174  // Maps keyword names into keyword records.
175  std::map<std::string, dit::did::Record> m_records;
176 
177  // List of dictionaries (filenames) currently loaded
178  // (m_dids_loaded[0] = first DID loaded).
179  ctd::defines::List<std::string> m_dids_loaded;
180 
181  // Maps dictionary filename into the header of that dictionary.
183 
185  void _Load(const std::string& did_filename,
186  int8_t& recurse_level);
187 
188  int16_t _LookUp(const std::string& pattern,
190  const bool allow_idx_subst,
191  const bool exception,
192  const int16_t max_records) const;
193 
194 };
195 
196 } // namespace dit
197 } // namespace did
198 
199 #endif // !IFW_DIT_DID_HPP_
200 
~Did()
Definition: Did.cpp:73
Did()
Definition: Did.cpp:68
void Clear()
Clear the object.
Definition: Did.cpp:78
HeaderSpecifier
Definition: Did.hpp:51
DataType
Data types numeric representations.
Definition: defines.hpp:33
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:190
Definition: Did.hpp:55
const ctd::defines::List< std::string > & GetDidsLoaded() const
Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).
Definition: Did.cpp:167
Definition: defines.hpp:50
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:181
void Add(dit::did::Record &record)
Add a keyword record in the dictionary object.
Definition: Did.cpp:268
static std::string SubstituteIndeces(const std::string &key)
Substitutes numeric indeces of keyword components to the generic representation.
Definition: Did.cpp:36
Data Interface Dictionary keyword record class.
Definition: Record.hpp:96
Definition: Did.hpp:52
void Load(const std::string &did_filename, const bool merge=false)
Load the referenced dictionary.
Definition: Did.cpp:87
const ctd::defines::List< dit::did::Header > & GetHeaders() const
Get the header objects for the DIDs loaded (el [0] = first DID loaded).
Definition: Did.cpp:174
static std::string SubstituteIndex(const std::string &key)
Substitutes a numeric index of a keyword to obtain the generic representation.
Definition: Did.cpp:16
void Scan(const std::string &pattern, ctd::defines::List< 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:351
Definition: Did.hpp:53
std::string Print(const HeaderSpecifier print_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:276
Definition: Did.hpp:54
void GetKeys(ctd::defines::List< std::string > &keys) const
Generate list of keys defined.
Definition: Did.cpp:370