Orcus
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 
53  bool transient;
54 
57  xmlns_id_t _ns, xml_token_t _name, const pstring& _value, bool _transient);
59  xmlns_id_t _ns, xml_token_t _name, const pstring& _raw_name,
60  const pstring& _value, bool _transient);
61 };
62 
67 struct ORCUS_PSR_DLLPUBLIC xml_token_element_t
68 {
69  xmlns_id_t ns;
70  xml_token_t name;
71  pstring raw_name;
72  std::vector<xml_token_attr_t> attrs;
73 
74  xml_token_element_t& operator= (xml_token_element_t) = delete;
75 
77  xml_token_element_t(xmlns_id_t _ns, xml_token_t _name, const pstring& _raw_name, std::vector<xml_token_attr_t>&& _attrs);
80 };
81 
82 // Other types
83 
84 enum class length_unit_t
85 {
86  unknown = 0,
87  centimeter,
88  millimeter,
89  xlsx_column_digit,
90  inch,
91  point,
92  twip,
93  pixel
94 
95  // TODO: Add more.
96 };
97 
98 enum class format_t
99 {
100  unknown = 0,
101  ods,
102  xlsx,
103  gnumeric,
104  xls_xml,
105  csv
106 };
107 
108 struct ORCUS_DLLPUBLIC length_t
109 {
110  length_unit_t unit;
111  double value;
112 
113  length_t();
114 
115  std::string to_string() const;
116 };
117 
118 struct ORCUS_DLLPUBLIC date_time_t
119 {
120  int year;
121  int month;
122  int day;
123  int hour;
124  int minute;
125  double second;
126 
127  date_time_t();
128  date_time_t(int _year, int _month, int _day);
129  date_time_t(int _year, int _month, int _day, int _hour, int _minute, double _second);
130  date_time_t(const date_time_t& other);
131  ~date_time_t();
132 
133  date_time_t& operator= (date_time_t other);
134 
135  bool operator== (const date_time_t& other) const;
136  bool operator!= (const date_time_t& other) const;
137 
138  std::string to_string() const;
139 
140  void swap(date_time_t& other);
141 };
142 
143 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const date_time_t& v);
144 
145 typedef ::std::vector<xml_token_attr_t> xml_attrs_t;
146 
147 }
148 
149 #endif
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: types.hpp:39
Definition: pstring.hpp:24
Definition: types.hpp:118
Definition: types.hpp:67
Definition: types.hpp:108
Definition: types.hpp:29
Definition: base64.hpp:15