Orcus
Loading...
Searching...
No Matches
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 <cstdint>
12#include <cstdlib>
13#include <vector>
14#include <string>
15#include <unordered_set>
16#include "env.hpp"
17
18namespace orcus {
19
20class xmlns_context;
21class xmlns_repository;
22
26using xml_token_t = std::size_t;
27
33using xmlns_id_t = const char*;
34
40struct ORCUS_PSR_DLLPUBLIC parse_error_value_t
41{
43 std::string_view str;
45 std::ptrdiff_t offset;
46
49 parse_error_value_t(std::string_view _str, std::ptrdiff_t _offset);
50
51 parse_error_value_t& operator=(const parse_error_value_t& other);
52
53 bool operator==(const parse_error_value_t& other) const;
54 bool operator!=(const parse_error_value_t& other) const;
55};
56
61struct ORCUS_PSR_DLLPUBLIC xml_name_t
62{
63 enum to_string_type { use_alias, use_short_name };
64
65 xmlns_id_t ns;
66 std::string_view name;
67
68 xml_name_t() noexcept;
69 xml_name_t(xmlns_id_t _ns, std::string_view _name);
70 xml_name_t(const xml_name_t& other);
71
72 xml_name_t& operator= (const xml_name_t& other);
73
74 bool operator== (const xml_name_t& other) const noexcept;
75 bool operator!= (const xml_name_t& other) const noexcept;
76
91 std::string to_string(const xmlns_context& cxt, to_string_type type) const;
92
103 std::string to_string(const xmlns_repository& repo) const;
104};
105
109struct ORCUS_PSR_DLLPUBLIC xml_token_attr_t
110{
111 xmlns_id_t ns;
112 xml_token_t name;
113 std::string_view raw_name;
114 std::string_view value;
115
124
128 xmlns_id_t _ns, xml_token_t _name, std::string_view _value, bool _transient);
130 xmlns_id_t _ns, xml_token_t _name, std::string_view _raw_name,
131 std::string_view _value, bool _transient);
132
133 xml_token_attr_t& operator=(const xml_token_attr_t& other);
134};
135
136using xml_token_attrs_t = std::vector<xml_token_attr_t>;
137
147struct ORCUS_PSR_DLLPUBLIC xml_token_element_t
148{
149 xmlns_id_t ns;
150 xml_token_t name;
151 std::string_view raw_name;
152 xml_token_attrs_t attrs;
153
154 xml_token_element_t& operator= (xml_token_element_t) = delete;
155
157 xml_token_element_t(xmlns_id_t _ns, xml_token_t _name, std::string_view _raw_name, std::vector<xml_token_attr_t>&& _attrs);
160};
161
167enum class character_set_t
168{
169 unspecified = 0,
170 adobe_standard_encoding,
171 adobe_symbol_encoding,
172 amiga_1251,
173 ansi_x3_110_1983,
174 asmo_449,
175 big5,
176 big5_hkscs,
177 bocu_1,
178 brf,
179 bs_4730,
180 bs_viewdata,
181 cesu_8,
182 cp50220,
183 cp51932,
184 csa_z243_4_1985_1,
185 csa_z243_4_1985_2,
186 csa_z243_4_1985_gr,
187 csn_369103,
188 dec_mcs,
189 din_66003,
190 dk_us,
191 ds_2089,
192 ebcdic_at_de,
193 ebcdic_at_de_a,
194 ebcdic_ca_fr,
195 ebcdic_dk_no,
196 ebcdic_dk_no_a,
197 ebcdic_es,
198 ebcdic_es_a,
199 ebcdic_es_s,
200 ebcdic_fi_se,
201 ebcdic_fi_se_a,
202 ebcdic_fr,
203 ebcdic_it,
204 ebcdic_pt,
205 ebcdic_uk,
206 ebcdic_us,
207 ecma_cyrillic,
208 es,
209 es2,
210 euc_jp,
211 euc_kr,
212 extended_unix_code_fixed_width_for_japanese,
213 gb18030,
214 gb2312,
215 gb_1988_80,
216 gb_2312_80,
217 gbk,
218 gost_19768_74,
219 greek7,
220 greek7_old,
221 greek_ccitt,
222 hp_desktop,
223 hp_legal,
224 hp_math8,
225 hp_pi_font,
226 hp_roman8,
227 hz_gb_2312,
228 ibm00858,
229 ibm00924,
230 ibm01140,
231 ibm01141,
232 ibm01142,
233 ibm01143,
234 ibm01144,
235 ibm01145,
236 ibm01146,
237 ibm01147,
238 ibm01148,
239 ibm01149,
240 ibm037,
241 ibm038,
242 ibm1026,
243 ibm1047,
244 ibm273,
245 ibm274,
246 ibm275,
247 ibm277,
248 ibm278,
249 ibm280,
250 ibm281,
251 ibm284,
252 ibm285,
253 ibm290,
254 ibm297,
255 ibm420,
256 ibm423,
257 ibm424,
258 ibm437,
259 ibm500,
260 ibm775,
261 ibm850,
262 ibm851,
263 ibm852,
264 ibm855,
265 ibm857,
266 ibm860,
267 ibm861,
268 ibm862,
269 ibm863,
270 ibm864,
271 ibm865,
272 ibm866,
273 ibm868,
274 ibm869,
275 ibm870,
276 ibm871,
277 ibm880,
278 ibm891,
279 ibm903,
280 ibm904,
281 ibm905,
282 ibm918,
283 ibm_symbols,
284 ibm_thai,
285 iec_p27_1,
286 inis,
287 inis_8,
288 inis_cyrillic,
289 invariant,
290 iso_10367_box,
291 iso_10646_j_1,
292 iso_10646_ucs_2,
293 iso_10646_ucs_4,
294 iso_10646_ucs_basic,
295 iso_10646_unicode_latin1,
296 iso_10646_utf_1,
297 iso_11548_1,
298 iso_2022_cn,
299 iso_2022_cn_ext,
300 iso_2022_jp,
301 iso_2022_jp_2,
302 iso_2022_kr,
303 iso_2033_1983,
304 iso_5427,
305 iso_5427_1981,
306 iso_5428_1980,
307 iso_646_basic_1983,
308 iso_646_irv_1983,
309 iso_6937_2_25,
310 iso_6937_2_add,
311 iso_8859_1,
312 iso_8859_10,
313 iso_8859_13,
314 iso_8859_14,
315 iso_8859_15,
316 iso_8859_16,
317 iso_8859_1_windows_3_0_latin_1,
318 iso_8859_1_windows_3_1_latin_1,
319 iso_8859_2,
320 iso_8859_2_windows_latin_2,
321 iso_8859_3,
322 iso_8859_4,
323 iso_8859_5,
324 iso_8859_6,
325 iso_8859_6_e,
326 iso_8859_6_i,
327 iso_8859_7,
328 iso_8859_8,
329 iso_8859_8_e,
330 iso_8859_8_i,
331 iso_8859_9,
332 iso_8859_9_windows_latin_5,
333 iso_8859_supp,
334 iso_ir_90,
335 iso_unicode_ibm_1261,
336 iso_unicode_ibm_1264,
337 iso_unicode_ibm_1265,
338 iso_unicode_ibm_1268,
339 iso_unicode_ibm_1276,
340 it,
341 jis_c6220_1969_jp,
342 jis_c6220_1969_ro,
343 jis_c6226_1978,
344 jis_c6226_1983,
345 jis_c6229_1984_a,
346 jis_c6229_1984_b,
347 jis_c6229_1984_b_add,
348 jis_c6229_1984_hand,
349 jis_c6229_1984_hand_add,
350 jis_c6229_1984_kana,
351 jis_encoding,
352 jis_x0201,
353 jis_x0212_1990,
354 jus_i_b1_002,
355 jus_i_b1_003_mac,
356 jus_i_b1_003_serb,
357 koi7_switched,
358 koi8_r,
359 koi8_u,
360 ks_c_5601_1987,
361 ksc5636,
362 kz_1048,
363 latin_greek,
364 latin_greek_1,
365 latin_lap,
366 macintosh,
367 microsoft_publishing,
368 mnem,
369 mnemonic,
370 msz_7795_3,
371 nats_dano,
372 nats_dano_add,
373 nats_sefi,
374 nats_sefi_add,
375 nc_nc00_10_81,
376 nf_z_62_010,
377 nf_z_62_010_1973,
378 ns_4551_1,
379 ns_4551_2,
380 osd_ebcdic_df03_irv,
381 osd_ebcdic_df04_1,
382 osd_ebcdic_df04_15,
383 pc8_danish_norwegian,
384 pc8_turkish,
385 pt,
386 pt2,
387 ptcp154,
388 scsu,
389 sen_850200_b,
390 sen_850200_c,
391 shift_jis,
392 t_101_g2,
393 t_61_7bit,
394 t_61_8bit,
395 tis_620,
396 tscii,
397 unicode_1_1,
398 unicode_1_1_utf_7,
399 unknown_8bit,
400 us_ascii,
401 us_dk,
402 utf_16,
403 utf_16be,
404 utf_16le,
405 utf_32,
406 utf_32be,
407 utf_32le,
408 utf_7,
409 utf_7_imap,
410 utf_8,
411 ventura_international,
412 ventura_math,
413 ventura_us,
414 videotex_suppl,
415 viqr,
416 viscii,
417 windows_1250,
418 windows_1251,
419 windows_1252,
420 windows_1253,
421 windows_1254,
422 windows_1255,
423 windows_1256,
424 windows_1257,
425 windows_1258,
426 windows_31j,
427 windows_874,
428};
429
433struct ORCUS_PSR_DLLPUBLIC xml_declaration_t
434{
435 uint8_t version_major;
436 uint8_t version_minor;
437 character_set_t encoding;
438 bool standalone;
439
441 xml_declaration_t(uint8_t _version_major, uint8_t _version_minor, character_set_t _encoding, bool _standalone);
444
445 xml_declaration_t& operator= (const xml_declaration_t& other);
446
447 bool operator== (const xml_declaration_t& other) const;
448 bool operator!= (const xml_declaration_t& other) const;
449};
450
454enum class length_unit_t
455{
456 unknown = 0,
457 centimeter,
458 millimeter,
466 xlsx_column_digit,
467 inch,
468 point,
470 twip,
471 pixel
472};
473
477enum class format_t
478{
479 unknown = 0,
480 ods,
481 xlsx,
482 gnumeric,
483 xls_xml,
484 csv
485};
486
490enum class dump_format_t
491{
492 unknown = 0,
493 none,
494 check,
495 csv,
496 flat,
497 html,
498 json,
499 xml,
500 yaml,
501 debug_state
502};
503
507struct ORCUS_PSR_DLLPUBLIC length_t
508{
509 length_unit_t unit;
510 double value;
511
512 length_t();
513 length_t(length_unit_t _unit, double _value);
514 length_t(const length_t& other);
515 length_t& operator= (const length_t& other);
516
517 std::string to_string() const;
518
519 bool operator== (const length_t& other) const noexcept;
520 bool operator!= (const length_t& other) const noexcept;
521};
522
526struct ORCUS_PSR_DLLPUBLIC date_time_t
527{
528 int year;
529 int month;
530 int day;
531 int hour;
532 int minute;
533 double second;
534
535 date_time_t();
536 date_time_t(int _year, int _month, int _day);
537 date_time_t(int _year, int _month, int _day, int _hour, int _minute, double _second);
538 date_time_t(const date_time_t& other);
539 ~date_time_t();
540
541 date_time_t& operator= (date_time_t other);
542
543 bool operator== (const date_time_t& other) const;
544 bool operator!= (const date_time_t& other) const;
545 bool operator< (const date_time_t& other) const;
546
552 std::string to_string() const;
553
559 void swap(date_time_t& other);
560
575 static date_time_t from_chars(std::string_view str);
576};
577
588ORCUS_PSR_DLLPUBLIC dump_format_t to_dump_format_enum(std::string_view s);
589
600ORCUS_PSR_DLLPUBLIC character_set_t to_character_set(std::string_view s);
601
608ORCUS_PSR_DLLPUBLIC std::vector<std::pair<std::string_view, dump_format_t>> get_dump_format_entries();
609
610ORCUS_PSR_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const length_t& v);
611ORCUS_PSR_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const date_time_t& v);
612ORCUS_PSR_DLLPUBLIC std::ostream& operator<< (std::ostream& os, format_t v);
613
618ORCUS_PSR_DLLPUBLIC extern const std::size_t INDEX_NOT_FOUND;
619
623ORCUS_PSR_DLLPUBLIC extern const xmlns_id_t XMLNS_UNKNOWN_ID;
624
628ORCUS_PSR_DLLPUBLIC extern const xml_token_t XML_UNKNOWN_TOKEN;
629
630}
631
632#endif
633/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition xml_namespace.hpp:100
Definition xml_namespace.hpp:30
Definition types.hpp:527
static date_time_t from_chars(std::string_view str)
std::string to_string() const
void swap(date_time_t &other)
Definition types.hpp:508
Definition types.hpp:41
std::string_view str
Definition types.hpp:43
std::ptrdiff_t offset
Definition types.hpp:45
Definition types.hpp:434
Definition types.hpp:62
std::string to_string(const xmlns_repository &repo) const
std::string to_string(const xmlns_context &cxt, to_string_type type) const
Definition types.hpp:110
bool transient
Definition types.hpp:123
Definition types.hpp:148