8#ifndef INCLUDED_ORCUS_SPREADSHEET_PIVOT_HPP
9#define INCLUDED_ORCUS_SPREADSHEET_PIVOT_HPP
12#include "../types.hpp"
33namespace spreadsheet {
36class pivot_collection;
40class debug_state_dumper_pivot_cache;
41class debug_state_dumper_pivot_table;
45using pivot_cache_indices_t = std::vector<size_t>;
49 using value_type = std::variant<bool, double, std::size_t, std::string_view, date_time_t, error_value_t>;
51 enum class record_type
75using pivot_cache_record_t = std::vector<pivot_cache_record_value_t>;
79 using value_type = std::variant<bool, double, std::string_view, date_time_t, error_value_t>;
83 unknown = 0, boolean, date_time, character, numeric, blank, error
107using pivot_cache_items_t = std::vector<pivot_cache_item_t>;
116 pivot_cache_group_by_t group_by = pivot_cache_group_by_t::range;
118 bool auto_start =
true;
119 bool auto_end =
true;
123 double interval = 1.0;
137 std::optional<range_grouping_type> range_grouping;
162 pivot_cache_items_t items;
164 std::optional<double> min_value;
165 std::optional<double> max_value;
167 std::optional<date_time_t> min_date;
168 std::optional<date_time_t> max_date;
170 std::unique_ptr<pivot_cache_group_data_t> group_data;
184 using value_type = std::variant<std::size_t, pivot_field_item_t>;
209using pivot_items_t = std::vector<pivot_item_t>;
213 pivot_axis_t axis = pivot_axis_t::unknown;
226using pivot_fields_t = std::vector<pivot_field_t>;
230 enum class value_type { unknown = 0, index, data };
232 value_type type = value_type::unknown;
233 std::size_t index = 0;
247using pivot_ref_rc_fields_t = std::vector<pivot_ref_rc_field_t>;
251 std::size_t field = 0;
252 std::optional<std::size_t> item;
264using pivot_ref_page_fields_t = std::vector<pivot_ref_page_field_t>;
268 std::size_t field = 0;
269 std::string_view name;
270 pivot_data_subtotal_t subtotal = pivot_data_subtotal_t::unknown;
272 pivot_data_show_data_as_t show_data_as = pivot_data_show_data_as_t::unknown;
273 std::size_t base_field = 0;
274 std::size_t base_item = 0;
286using pivot_ref_data_fields_t = std::vector<pivot_ref_data_field_t>;
296 pivot_field_item_t type = pivot_field_item_t::unknown;
299 std::size_t repeat = 0;
300 std::vector<std::size_t> items;
301 std::optional<std::size_t> data_item;
313using pivot_ref_rc_items_t = std::vector<pivot_ref_rc_item_t>;
317 friend class detail::debug_state_dumper_pivot_cache;
318 friend class detail::debug_state_dumper_pivot_table;
322 std::unique_ptr<impl> mp_impl;
325 using fields_type = std::vector<pivot_cache_field_t>;
326 using records_type = std::vector<pivot_cache_record_t>;
339 void insert_records(records_type record);
341 size_t get_field_count()
const;
353 pivot_cache_id_t get_id()
const;
355 const records_type& get_all_records()
const;
360 friend class detail::debug_state_dumper_pivot_table;
364 std::unique_ptr<impl> mp_impl;
375 std::string_view get_name()
const;
376 void set_name(std::string_view name);
377 void set_cache_id(pivot_cache_id_t cache_id);
378 void set_range(
const ixion::abs_rc_range_t& range);
379 void set_pivot_fields(pivot_fields_t fields);
380 void set_row_fields(pivot_ref_rc_fields_t fields);
381 void set_column_fields(pivot_ref_rc_fields_t fields);
382 void set_page_fields(pivot_ref_page_fields_t fields);
383 void set_data_fields(pivot_ref_data_fields_t fields);
384 void set_row_items(pivot_ref_rc_items_t items);
385 void set_column_items(pivot_ref_rc_items_t items);
391 std::unique_ptr<impl> mp_impl;
394 using outdir_type = std::variant<std::string_view, std::u16string_view>;
409 std::string_view sheet_name,
const ixion::abs_range_t& range, std::unique_ptr<pivot_cache>&& cache);
429 std::string_view sheet_name,
const ixion::abs_range_t& range)
const;
433 const pivot_cache* get_cache(pivot_cache_id_t cache_id)
const;
435 void dump_debug_state(
const outdir_type& outdir)
const;
438ORCUS_SPM_DLLPUBLIC std::ostream& operator<<(std::ostream& os,
const pivot_cache_item_t& item);
440ORCUS_SPM_DLLPUBLIC std::ostream& operator<<(std::ostream& os,
const pivot_item_t& v);
Definition document.hpp:55
const pivot_cache_field_t * get_field(size_t index) const
void insert_fields(fields_type fields)
void insert_worksheet_cache(std::string_view sheet_name, const ixion::abs_range_t &range, std::unique_ptr< pivot_cache > &&cache)
size_t get_cache_count() const
void insert_worksheet_cache(std::string_view table_name, std::unique_ptr< pivot_cache > &&cache)
Definition string_pool.hpp:26
std::string_view name
Definition pivot.hpp:160
pivot_cache_indices_t base_to_group_indices
Definition pivot.hpp:135
pivot_cache_items_t items
Definition pivot.hpp:142
size_t base_field
Definition pivot.hpp:145