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 ORCUS_SPREADSHEET_TYPES_HPP
9 #define ORCUS_SPREADSHEET_TYPES_HPP
10 
11 #include "../env.hpp"
12 
13 #include <cstdlib>
14 #include <cstdint>
15 #include <iosfwd>
16 #include <initializer_list>
17 #include <string_view>
18 #include <vector>
19 
20 // NB: This header should only define primitive data types, enums and structs.
21 
22 namespace orcus { namespace spreadsheet {
23 
25 using row_t = int32_t;
27 using col_t = int32_t;
29 using sheet_t = int32_t;
31 using color_elem_t = uint8_t;
33 using col_width_t = uint16_t;
35 using row_height_t = uint16_t;
37 using string_id_t = uint32_t;
39 using pivot_cache_id_t = uint32_t;
40 
47 ORCUS_DLLPUBLIC col_width_t get_default_column_width();
48 
55 ORCUS_DLLPUBLIC row_height_t get_default_row_height();
56 
60 enum class error_value_t
61 {
66  unknown = 0,
68  null,
70  div0,
72  value,
74  ref,
76  name,
78  num,
80  na
81 };
82 
87 enum class border_direction_t
88 {
90  unknown = 0,
92  top,
94  bottom,
96  left,
98  right,
103  diagonal,
105  diagonal_bl_tr,
107  diagonal_tl_br
108 };
109 
113 enum class border_style_t
114 {
115  unknown = 0,
116  none,
117  solid,
118  dash_dot,
119  dash_dot_dot,
120  dashed,
121  dotted,
122  double_border,
123  hair,
124  medium,
125  medium_dash_dot,
126  medium_dash_dot_dot,
127  medium_dashed,
128  slant_dash_dot,
129  thick,
130  thin,
131  double_thin,
132  fine_dashed
133 };
134 
138 enum class fill_pattern_t
139 {
140  none = 0,
141  solid,
142  dark_down,
143  dark_gray,
144  dark_grid,
145  dark_horizontal,
146  dark_trellis,
147  dark_up,
148  dark_vertical,
149  gray_0625,
150  gray_125,
151  light_down,
152  light_gray,
153  light_grid,
154  light_horizontal,
155  light_trellis,
156  light_up,
157  light_vertical,
158  medium_gray
159 };
160 
166 enum class strikethrough_style_t
167 {
168  none = 0,
169  solid,
170  dash,
171  dot_dash,
172  dot_dot_dash,
173  dotted,
174  long_dash,
175  wave
176 };
177 
183 enum class strikethrough_type_t
184 {
185  unknown = 0,
186  none,
187  single_type,
188  double_type
189 };
190 
196 enum class strikethrough_width_t
197 {
198  unknown = 0,
199  width_auto,
200  thin,
201  medium,
202  thick,
203  bold
204 };
205 
211 enum class strikethrough_text_t
212 {
213  unknown = 0,
215  slash,
217  cross
218 };
219 
224 enum class formula_grammar_t
225 {
227  unknown = 0,
229  xls_xml,
231  xlsx,
233  ods,
235  gnumeric
236 };
237 
241 enum class formula_t
242 {
244  unknown = 0,
246  array,
248  data_table,
250  normal,
252  shared
253 };
254 
260 enum class formula_ref_context_t
261 {
266  global = 0,
267 
269  named_expression_base,
270 
275  named_range,
276 };
277 
282 enum class formula_error_policy_t
283 {
284  unknown,
286  fail,
288  skip
289 };
290 
294 enum class underline_t
295 {
297  none = 0,
299  single_line,
305  single_accounting,
307  double_line,
313  double_accounting,
315  dotted,
317  dash,
319  long_dash,
321  dot_dash,
323  dot_dot_dash,
325  wave
326 };
327 
336 enum class underline_width_t
337 {
338  none = 0,
339  automatic,
340  bold,
341  dash,
342  medium,
343  thick,
344  thin,
345  percent,
346  positive_integer,
347  positive_length
348 };
349 
356 enum class underline_mode_t
357 {
359  continuous = 0,
361  skip_white_space
362 };
363 
369 enum class underline_type_t
370 {
371  none = 0,
373  single_type,
375  double_type
376 };
377 
381 enum class hor_alignment_t
382 {
383  unknown = 0,
384  left,
385  center,
386  right,
387  justified,
388  distributed,
389  filled
390 };
391 
395 enum class ver_alignment_t
396 {
397  unknown = 0,
398  top,
399  middle,
400  bottom,
401  justified,
402  distributed
403 };
404 
409 enum class xf_category_t
410 {
411  unknown,
413  cell,
415  cell_style,
417  differential,
418 };
419 
425 enum class data_table_type_t
426 {
427  column,
428  row,
429  both
430 };
431 
435 enum class totals_row_function_t
436 {
437  none = 0,
438  sum,
439  minimum,
440  maximum,
441  average,
442  count,
443  count_numbers,
444  standard_deviation,
445  variance,
446  custom
447 };
448 
452 enum class conditional_format_t
453 {
454  unknown = 0,
455  condition,
456  date,
457  formula,
458  colorscale,
459  databar,
460  iconset
461 };
462 
466 enum class condition_operator_t
467 {
468  unknown = 0,
469  equal,
470  less,
471  greater,
472  greater_equal,
473  less_equal,
474  not_equal,
475  between,
476  not_between,
477  duplicate,
478  unique,
479  top_n,
480  bottom_n,
481  above_average,
482  below_average,
483  above_equal_average,
484  below_equal_average,
485  contains_error,
486  contains_no_error,
487  begins_with,
488  ends_with,
489  contains,
490  contains_blanks,
491  not_contains,
492  expression
493 };
494 
503 enum class condition_type_t
504 {
505  unknown = 0,
506  value,
507  automatic,
508  max,
509  min,
510  formula,
511  percent,
512  percentile
513 };
514 
519 enum class condition_date_t
520 {
521  unknown = 0,
522  today,
523  yesterday,
524  tomorrow,
525  last_7_days,
526  this_week,
527  next_week,
528  last_week,
529  this_month,
530  next_month,
531  last_month,
532  this_year,
533  next_year,
534  last_year,
535 };
536 
541 enum class databar_axis_t
542 {
543  none = 0,
544  middle,
545  automatic
546 };
547 
551 enum class pivot_cache_group_by_t
552 {
558  unknown = 0,
560  days,
562  hours,
564  minutes,
566  months,
568  quarters,
570  range,
572  seconds,
574  years
575 };
576 
580 struct address_t
581 {
582  row_t row;
583  col_t column;
584 };
585 
590 {
591  row_t rows;
592  col_t columns;
593 };
594 
599 struct range_t
600 {
601  address_t first;
602  address_t last;
603 };
604 
610 {
611  sheet_t sheet;
612  row_t row;
613  col_t column;
614 };
615 
621 {
622  src_address_t first;
623  src_address_t last;
624 };
625 
630 ORCUS_DLLPUBLIC address_t to_rc_address(const src_address_t& r);
631 
636 ORCUS_DLLPUBLIC range_t to_rc_range(const src_range_t& r);
637 
638 ORCUS_DLLPUBLIC bool operator== (const address_t& left, const address_t& right);
639 ORCUS_DLLPUBLIC bool operator!= (const address_t& left, const address_t& right);
640 
641 ORCUS_DLLPUBLIC bool operator== (const src_address_t& left, const src_address_t& right);
642 ORCUS_DLLPUBLIC bool operator!= (const src_address_t& left, const src_address_t& right);
643 
644 ORCUS_DLLPUBLIC bool operator== (const range_t& left, const range_t& right);
645 ORCUS_DLLPUBLIC bool operator!= (const range_t& left, const range_t& right);
646 
647 ORCUS_DLLPUBLIC bool operator== (const src_range_t& left, const src_range_t& right);
648 ORCUS_DLLPUBLIC bool operator!= (const src_range_t& left, const src_range_t& right);
649 
650 ORCUS_DLLPUBLIC bool operator< (const range_t& left, const range_t& right);
651 ORCUS_DLLPUBLIC bool operator> (const range_t& left, const range_t& right);
652 
653 ORCUS_DLLPUBLIC range_t& operator+= (range_t& left, const address_t& right);
654 ORCUS_DLLPUBLIC range_t& operator-= (range_t& left, const address_t& right);
655 
656 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const address_t& v);
657 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const src_address_t& v);
658 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const range_t& v);
659 
664 {
665  color_elem_t red;
666  color_elem_t green;
667  color_elem_t blue;
668 };
669 
678 ORCUS_DLLPUBLIC totals_row_function_t to_totals_row_function_enum(std::string_view s);
679 
688 ORCUS_DLLPUBLIC pivot_cache_group_by_t to_pivot_cache_group_by_enum(std::string_view s);
689 
698 ORCUS_DLLPUBLIC error_value_t to_error_value_enum(std::string_view s);
699 
709 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb(std::string_view s);
710 
720 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb_from_name(std::string_view s);
721 
729 ORCUS_DLLPUBLIC formula_error_policy_t to_formula_error_policy(std::string_view s);
730 
731 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, error_value_t ev);
732 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, border_style_t border);
733 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, formula_grammar_t grammar);
734 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, underline_t uline);
735 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, underline_width_t ulwidth);
736 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, underline_mode_t ulmode);
737 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, underline_type_t ultype);
738 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, hor_alignment_t halign);
739 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, ver_alignment_t valign);
740 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const color_rgb_t& color);
741 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const fill_pattern_t& fill);
742 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const strikethrough_style_t& ss);
743 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const strikethrough_type_t& st);
744 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const strikethrough_width_t& sw);
745 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const strikethrough_text_t& st);
746 
747 }}
748 
749 #endif
750 
751 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: sheet.hpp:41
Definition: types.hpp:581
Definition: types.hpp:664
Definition: types.hpp:590
Definition: types.hpp:600
Definition: types.hpp:610
Definition: types.hpp:621