Orcus
 All Classes Functions Variables Enumerations Enumerator Pages
types.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_TYPES_HPP
9 #define INCLUDED_ORCUS_TYPES_HPP
10 
11 #include <cstdlib>
12 #include <vector>
13 #include <string>
14 #include "pstring.hpp"
15 #include "env.hpp"
16 
17 namespace orcus {
18 
19 // XML specific types
20 
21 typedef size_t xml_token_t;
22 typedef const char* xmlns_id_t;
23 
24 ORCUS_PSR_DLLPUBLIC extern const xmlns_id_t XMLNS_UNKNOWN_ID;
25 ORCUS_PSR_DLLPUBLIC extern const xml_token_t XML_UNKNOWN_TOKEN;
26 ORCUS_PSR_DLLPUBLIC extern const size_t index_not_found;
27 ORCUS_PSR_DLLPUBLIC extern const size_t unspecified;
28 
29 struct xml_name_t
30 {
31  xmlns_id_t ns;
32  pstring name;
33 
34  xml_name_t() : ns(XMLNS_UNKNOWN_ID), name() {}
35  xml_name_t(xmlns_id_t _ns, const pstring& _name) : ns(_ns), name(_name) {}
36  xml_name_t(const xml_name_t& r) : ns(r.ns), name(r.name) {}
37 };
38 
39 struct ORCUS_PSR_DLLPUBLIC xml_token_attr_t
40 {
41  xmlns_id_t ns;
42  xml_token_t name;
43  pstring raw_name;
44  pstring value;
45 
52  bool transient;
53 
56  xmlns_id_t _ns, xml_token_t _name, const pstring& _value, bool _transient);
58  xmlns_id_t _ns, xml_token_t _name, const pstring& _raw_name,
59  const pstring& _value, bool _transient);
60 };
61 
66 struct ORCUS_PSR_DLLPUBLIC xml_token_element_t
67 {
68  xmlns_id_t ns;
69  xml_token_t name;
70  pstring raw_name;
71  std::vector<xml_token_attr_t> attrs;
72 
73  xml_token_element_t& operator= (xml_token_element_t) = delete;
74 
76  xml_token_element_t(xmlns_id_t _ns, xml_token_t _name, const pstring& _raw_name, std::vector<xml_token_attr_t>&& _attrs);
79 };
80 
81 // Other types
82 
83 enum class length_unit_t
84 {
85  unknown = 0,
86  centimeter,
87  millimeter,
88  xlsx_column_digit,
89  inch,
90  point,
91  twip,
92  pixel
93 
94  // TODO: Add more.
95 };
96 
97 struct ORCUS_DLLPUBLIC length_t
98 {
99  length_unit_t unit;
100  double value;
101 
102  length_t();
103 
104  std::string print() const;
105 };
106 
107 struct ORCUS_PSR_DLLPUBLIC date_time_t
108 {
109  int year;
110  int month;
111  int day;
112  int hour;
113  int minute;
114  double second;
115 
116  date_time_t();
117 
118  std::string to_string() const;
119 };
120 
121 typedef ::std::vector<xml_token_attr_t> xml_attrs_t;
122 
123 }
124 
125 #endif
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: types.hpp:39
Definition: pstring.hpp:24
Definition: types.hpp:107
Definition: types.hpp:66
Definition: types.hpp:97
Definition: types.hpp:29