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 
19 // NB: This header should only use primitive data types and enums.
20 
21 namespace orcus { namespace spreadsheet {
22 
23 typedef int32_t row_t;
24 typedef int32_t col_t;
25 typedef int32_t sheet_t;
26 typedef uint8_t color_elem_t;
27 typedef uint16_t col_width_t;
28 typedef uint16_t row_height_t;
29 typedef uint32_t string_id_t;
30 
31 typedef uint32_t pivot_cache_id_t;
32 
33 ORCUS_DLLPUBLIC col_width_t get_default_column_width();
34 ORCUS_DLLPUBLIC row_height_t get_default_row_height();
35 
36 enum class error_value_t
37 {
38  unknown = 0,
39  null, // #NULL!
40  div0, // #DIV/0!
41  value, // #VALUE!
42  ref, // #REF!
43  name, // #NAME?
44  num, // #NUM!
45  na // #N/A!
46 };
47 
48 enum class border_direction_t
49 {
50  unknown = 0,
51  top,
52  bottom,
53  left,
54  right,
55  diagonal,
56  diagonal_bl_tr,
57  diagonal_tl_br
58 };
59 
60 enum class border_style_t
61 {
62  unknown = 0,
63  none,
64  solid,
65  dash_dot,
66  dash_dot_dot,
67  dashed,
68  dotted,
69  double_border,
70  hair,
71  medium,
72  medium_dash_dot,
73  medium_dash_dot_dot,
74  medium_dashed,
75  slant_dash_dot,
76  thick,
77  thin,
78  double_thin,
79  fine_dashed
80 };
81 
82 enum class fill_pattern_t
83 {
84  none = 0,
85  solid,
86  dark_down,
87  dark_gray,
88  dark_grid,
89  dark_horizontal,
90  dark_trellis,
91  dark_up,
92  dark_vertical,
93  gray_0625,
94  gray_125,
95  light_down,
96  light_gray,
97  light_grid,
98  light_horizontal,
99  light_trellis,
100  light_up,
101  light_vertical,
102  medium_gray
103 };
104 
105 enum class strikethrough_style_t
106 {
107  none = 0,
108  solid,
109  dash,
110  dot_dash,
111  dot_dot_dash,
112  dotted,
113  long_dash,
114  wave
115 };
116 
117 enum class strikethrough_type_t
118 {
119  unknown = 0,
120  none,
121  single,
122  double_type
123 };
124 
125 enum class strikethrough_width_t
126 {
127  unknown = 0,
128  width_auto,
129  thin,
130  medium,
131  thick,
132  bold
133 };
134 
135 enum class strikethrough_text_t
136 {
137  unknown = 0,
138  slash,
139  cross
140 };
141 
146 enum class formula_grammar_t
147 {
149  unknown = 0,
151  xls_xml,
153  xlsx,
155  ods,
157  gnumeric
158 };
159 
160 enum class formula_t
161 {
162  unknown = 0,
163  array,
164  data_table,
165  normal,
166  shared
167 };
168 
174 enum class formula_ref_context_t
175 {
180  global = 0,
181 
183  named_expression_base,
184 
189  named_range,
190 };
191 
196 enum class formula_error_policy_t
197 {
198  unknown,
200  fail,
202  skip
203 };
204 
205 enum class underline_t
206 {
207  none = 0,
208  single_line,
209  single_accounting, // unique to xlsx
210  double_line,
211  double_accounting, // unique to xlsx
212  dotted,
213  dash,
214  long_dash,
215  dot_dash,
216  dot_dot_dot_dash, // TODO:API: -> dot_dot_dash
217  wave
218 };
219 
220 enum class underline_width_t
221 {
222  none = 0,
223  normal,
224  bold,
225  thin,
226  medium,
227  thick,
228  positive_integer,
229  percent,
230  positive_length
231 };
232 
233 enum class underline_mode_t
234 {
235  continuos = 0, // TODO:API: fix this typo
236  skip_white_space
237 };
238 
239 enum class underline_type_t
240 {
241  none = 0,
242  single, // TODO:API: standardize these values
243  double_type //necessary to not call it "double", since it is a reserved word
244 };
245 
247 {
248  underline_t underline_style;
249  underline_width_t underline_width;
250  underline_mode_t underline_mode;
251  underline_type_t underline_type;
252 };
253 
254 enum class hor_alignment_t
255 {
256  unknown = 0,
257  left,
258  center,
259  right,
260  justified,
261  distributed,
262  filled
263 };
264 
265 enum class ver_alignment_t
266 {
267  unknown = 0,
268  top,
269  middle,
270  bottom,
271  justified,
272  distributed
273 };
274 
280 enum class data_table_type_t
281 {
282  column,
283  row,
284  both
285 };
286 
290 enum class totals_row_function_t
291 {
292  none = 0,
293  sum,
294  minimum,
295  maximum,
296  average,
297  count,
298  count_numbers,
299  standard_deviation,
300  variance,
301  custom
302 };
303 
304 enum class conditional_format_t
305 {
306  unknown = 0,
307  condition,
308  date,
309  formula,
310  colorscale,
311  databar,
312  iconset
313 };
314 
315 enum class condition_operator_t
316 {
317  unknown = 0,
318  equal,
319  less,
320  greater,
321  greater_equal,
322  less_equal,
323  not_equal,
324  between,
325  not_between,
326  duplicate,
327  unique,
328  top_n,
329  bottom_n,
330  above_average,
331  below_average,
332  above_equal_average,
333  below_equal_average,
334  contains_error,
335  contains_no_error,
336  begins_with,
337  ends_with,
338  contains,
339  contains_blanks,
340  not_contains,
341  expression
342 };
343 
344 enum class condition_type_t
345 {
346  unknown = 0,
347  value,
348  automatic,
349  max,
350  min,
351  formula,
352  percent,
353  percentile
354 };
355 
356 enum class condition_date_t
357 {
358  unknown = 0,
359  today,
360  yesterday,
361  tomorrow,
362  last_7_days,
363  this_week,
364  next_week,
365  last_week,
366  this_month,
367  next_month,
368  last_month,
369  this_year,
370  next_year,
371  last_year,
372 };
373 
374 enum class databar_axis_t
375 {
376  none = 0,
377  middle,
378  automatic
379 };
380 
381 enum class pivot_cache_group_by_t
382 {
383  unknown = 0,
384  days, // grouping on "days" for date values.
385  hours, // grouping on "hours" for date values.
386  minutes, // grouping on "minutes" for date values.
387  months, // grouping on "months" for date values.
388  quarters, // grouping on "quarters" for date values.
389  range, // grouping by numeric ranges for numeric values.
390  seconds, // grouping on "seconds" for date values.
391  years // grouping on "years" for date values.
392 };
393 
394 struct address_t
395 {
396  row_t row;
397  col_t column;
398 };
399 
401 {
402  row_t rows;
403  col_t columns;
404 };
405 
406 struct range_t
407 {
408  address_t first;
409  address_t last;
410 };
411 
417 {
418  sheet_t sheet;
419  row_t row;
420  col_t column;
421 };
422 
428 {
429  src_address_t first;
430  src_address_t last;
431 };
432 
433 ORCUS_DLLPUBLIC address_t to_rc_address(const src_address_t& r);
434 ORCUS_DLLPUBLIC range_t to_rc_range(const src_range_t& r);
435 
436 ORCUS_DLLPUBLIC bool operator== (const address_t& left, const address_t& right);
437 ORCUS_DLLPUBLIC bool operator!= (const address_t& left, const address_t& right);
438 
439 ORCUS_DLLPUBLIC bool operator== (const src_address_t& left, const src_address_t& right);
440 ORCUS_DLLPUBLIC bool operator!= (const src_address_t& left, const src_address_t& right);
441 
442 ORCUS_DLLPUBLIC bool operator== (const range_t& left, const range_t& right);
443 ORCUS_DLLPUBLIC bool operator!= (const range_t& left, const range_t& right);
444 
445 ORCUS_DLLPUBLIC bool operator== (const src_range_t& left, const src_range_t& right);
446 ORCUS_DLLPUBLIC bool operator!= (const src_range_t& left, const src_range_t& right);
447 
448 ORCUS_DLLPUBLIC bool operator< (const range_t& left, const range_t& right);
449 ORCUS_DLLPUBLIC bool operator> (const range_t& left, const range_t& right);
450 
451 ORCUS_DLLPUBLIC range_t& operator+= (range_t& left, const address_t& right);
452 ORCUS_DLLPUBLIC range_t& operator-= (range_t& left, const address_t& right);
453 
454 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const address_t& v);
455 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const src_address_t& v);
456 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const range_t& v);
457 
458 struct ORCUS_DLLPUBLIC color_rgb_t
459 {
460  color_elem_t red;
461  color_elem_t green;
462  color_elem_t blue;
463 
464  color_rgb_t();
465  color_rgb_t(std::initializer_list<color_elem_t> vs);
466  color_rgb_t(const color_rgb_t& other);
467  color_rgb_t(color_rgb_t&& other);
468 
469  color_rgb_t& operator= (const color_rgb_t& other);
470 };
471 
480 ORCUS_DLLPUBLIC totals_row_function_t to_totals_row_function_enum(std::string_view s);
481 
490 ORCUS_DLLPUBLIC pivot_cache_group_by_t to_pivot_cache_group_by_enum(std::string_view s);
491 
500 ORCUS_DLLPUBLIC error_value_t to_error_value_enum(std::string_view s);
501 
511 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb(std::string_view s);
512 
522 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb_from_name(std::string_view s);
523 
531 ORCUS_DLLPUBLIC formula_error_policy_t to_formula_error_policy(std::string_view s);
532 
533 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, error_value_t ev);
534 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, formula_grammar_t grammar);
535 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const color_rgb_t& color);
536 
537 }}
538 
539 #endif
540 
541 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: sheet.hpp:34
Definition: types.hpp:395
Definition: types.hpp:459
Definition: types.hpp:401
Definition: types.hpp:407
Definition: types.hpp:417
Definition: types.hpp:428
Definition: types.hpp:247