ifw-core  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Header.hpp
Go to the documentation of this file.
1 
9 #ifndef IFW_DIT_DID_HEADER_HPP_
10 #define IFW_DIT_DID_HEADER_HPP_
11 
12 #include <string>
13 
14 #include "ctd/defines/defines.hpp"
15 
16 #include "ctd/file/Yaml.hpp"
17 
18 
19 namespace dit {
20  namespace did {
21 
23  // TODO: Consider to use "enum class".
24  typedef enum {
31 
34  } DidHdrField;
35 
36  const std::string HEADER_TAG = "Header";
37 
38  // Dictionary Header Fields.
39  const std::string DID_HDR_FIELD_NAME_STR = "Name";
40  const std::string DID_HDR_FIELD_SCOPE_STR = "Scope";
41  const std::string DID_HDR_FIELD_CRE_DATE_STR = "CreationDate";
42  const std::string DID_HDR_FIELD_VERSION_STR = "Version";
43  const std::string DID_HDR_FIELD_INCLUDE_STR = "Include";
44  const std::string DID_HDR_FIELD_DESCRIPTION_STR = "Description";
45 
46  const std::map<DidHdrField, std::string> DID_HDR_FIELDS_NB_MAP = {
47  {DidHdrField::DID_HDR_FIELD_NAME, DID_HDR_FIELD_NAME_STR},
48  {DidHdrField::DID_HDR_FIELD_SCOPE, DID_HDR_FIELD_SCOPE_STR},
49  {DidHdrField::DID_HDR_FIELD_CRE_DATE, DID_HDR_FIELD_CRE_DATE_STR},
50  {DidHdrField::DID_HDR_FIELD_VERSION, DID_HDR_FIELD_VERSION_STR},
51  {DidHdrField::DID_HDR_FIELD_INCLUDE, DID_HDR_FIELD_INCLUDE_STR},
52  {DidHdrField::DID_HDR_FIELD_DESCRIPTION, DID_HDR_FIELD_DESCRIPTION_STR}
53  };
54 
55  const std::map<std::string, DidHdrField> DID_HDR_FIELDS_NAME_MAP {
62  };
63 
64 
66  class Header {
67  public:
68 
69 
70  Header();
71 
76  explicit Header(const ctd::file::Yaml& did);
77 
78  ~Header();
79 
85  void Parse(const ctd::file::Yaml& did);
86 
88  std::string GetName() const;
89 
91  std::string GetScope() const;
92 
95 
97  std::string GetVersion() const;
98 
100  const std::vector<std::string>& GetIncludes() const;
101 
103  std::string GetDescription() const;
104 
110  std::string ToString(const DidHdrField fields = DidHdrField::DID_HDR_FIELD_ALL,
111  const bool compact = false) const;
112 
113  private:
114  std::string m_name;
115  std::string m_scope;
116  ctd::defines::IsoTime m_creation_date;
117  std::string m_version;
118  std::vector<std::string> m_includes;
119  std::string m_description;
120  };
121 
122  }
123 }
124 
125 #endif // !IFW_DIT_DID_HEADER_HPP_
Class to handle YAML files.
Class implementing the handling of Yaml files in the ICS environment.
Definition: Yaml.hpp:27
Data Interface Dictionary header class.
Definition: Header.hpp:66
Header()
Definition: Header.cpp:12
Definition: Header.hpp:25
std::string GetDescription() const
Return Description.
Definition: Header.cpp:99
const std::vector< std::string > & GetIncludes() const
Return reference to list of include files.
Definition: Header.cpp:92
ctd::defines::IsoTime GetCreationDate() const
Return creation date (ISO8601).
Definition: Header.cpp:78
const std::string DID_HDR_FIELD_DESCRIPTION_STR
Definition: Header.hpp:44
const std::string DID_HDR_FIELD_INCLUDE_STR
Definition: Header.hpp:43
Common definitions.
Definition: Header.hpp:26
const std::string DID_HDR_FIELD_SCOPE_STR
Definition: Header.hpp:40
std::string GetName() const
Return (file)name, from where the dictionary was loaded.
Definition: Header.cpp:64
DidHdrField
Dictionary header field types.
Definition: Header.hpp:24
const std::string DID_HDR_FIELD_NAME_STR
Definition: Header.hpp:39
const std::map< std::string, DidHdrField > DID_HDR_FIELDS_NAME_MAP
Definition: Header.hpp:55
std::string GetScope() const
Return scope.
Definition: Header.cpp:71
std::string ToString(const DidHdrField fields=DidHdrField::DID_HDR_FIELD_ALL, const bool compact=false) const
Get string copy of one or more header fields.
Definition: Header.cpp:106
~Header()
Definition: Header.cpp:24
const std::string DID_HDR_FIELD_VERSION_STR
Definition: Header.hpp:42
const std::string DID_HDR_FIELD_CRE_DATE_STR
Definition: Header.hpp:41
std::string IsoTime
ISO8601 data type.
Definition: types.hpp:30
std::string GetVersion() const
Return version (control string).
Definition: Header.cpp:85
Definition: Header.hpp:29
Definition: Header.hpp:32
Definition: Header.hpp:30
void Parse(const ctd::file::Yaml &did)
Parse Parse/extract the fields of the DID header, contained in the string buffer. ...
Definition: Header.cpp:29
Definition: Header.hpp:27
const std::map< DidHdrField, std::string > DID_HDR_FIELDS_NB_MAP
Definition: Header.hpp:46
Definition: Header.hpp:28
const std::string HEADER_TAG
Definition: Header.hpp:36