Pivot table

struct pivot_cache_record_value_t

Public Types

enum class record_type

Values:

enumerator unknown
enumerator boolean
enumerator date_time
enumerator character
enumerator numeric
enumerator blank
enumerator error
enumerator shared_item_index
using value_type = std::variant<bool, double, std::size_t, std::string_view, date_time_t>

Public Functions

pivot_cache_record_value_t()
pivot_cache_record_value_t(std::string_view s)
pivot_cache_record_value_t(double v)
pivot_cache_record_value_t(size_t index)
bool operator==(const pivot_cache_record_value_t &other) const
bool operator!=(const pivot_cache_record_value_t &other) const

Public Members

record_type type
value_type value
struct pivot_cache_item_t

Public Types

enum class item_type

Values:

enumerator unknown
enumerator boolean
enumerator date_time
enumerator character
enumerator numeric
enumerator blank
enumerator error
using value_type = std::variant<bool, double, std::string_view, date_time_t, error_value_t>

Public Functions

pivot_cache_item_t()
pivot_cache_item_t(std::string_view s)
pivot_cache_item_t(double numeric)
pivot_cache_item_t(bool boolean)
pivot_cache_item_t(const date_time_t &date_time)
pivot_cache_item_t(error_value_t error)
pivot_cache_item_t(const pivot_cache_item_t &other)
pivot_cache_item_t(pivot_cache_item_t &&other)
bool operator<(const pivot_cache_item_t &other) const
bool operator==(const pivot_cache_item_t &other) const
pivot_cache_item_t &operator=(pivot_cache_item_t other)
void swap(pivot_cache_item_t &other)

Public Members

item_type type
value_type value
struct pivot_cache_group_data_t

Group data for a pivot cache field.

Public Functions

pivot_cache_group_data_t(size_t _base_field)
pivot_cache_group_data_t(const pivot_cache_group_data_t &other)
pivot_cache_group_data_t(pivot_cache_group_data_t &&other)
pivot_cache_group_data_t() = delete

Public Members

pivot_cache_indices_t base_to_group_indices

Mapping of base field member indices to the group field item indices.

std::optional<range_grouping_type> range_grouping
pivot_cache_items_t items

Individual items comprising the group.

size_t base_field

0-based index of the base field.

struct range_grouping_type

Public Functions

range_grouping_type() = default
range_grouping_type(const range_grouping_type &other) = default

Public Members

pivot_cache_group_by_t group_by = pivot_cache_group_by_t::range
bool auto_start = true
bool auto_end = true
double start = 0.0
double end = 0.0
double interval = 1.0
date_time_t start_date
date_time_t end_date
struct pivot_cache_field_t

Public Functions

pivot_cache_field_t()
pivot_cache_field_t(std::string_view _name)
pivot_cache_field_t(const pivot_cache_field_t &other)
pivot_cache_field_t(pivot_cache_field_t &&other)

Public Members

std::string_view name

Field name. It must be interned with the string pool belonging to the document.

pivot_cache_items_t items
std::optional<double> min_value
std::optional<double> max_value
std::optional<date_time_t> min_date
std::optional<date_time_t> max_date
std::unique_ptr<pivot_cache_group_data_t> group_data
class pivot_cache

Public Types

using fields_type = std::vector<pivot_cache_field_t>
using records_type = std::vector<pivot_cache_record_t>

Public Functions

pivot_cache(pivot_cache_id_t cache_id, string_pool &sp)
~pivot_cache()
void insert_fields(fields_type fields)

Bulk-insert all the fields in one step. Note that this will replace any pre-existing fields if any.

Parameters:

fields – field instances to move into storage.

void insert_records(records_type record)
size_t get_field_count() const
const pivot_cache_field_t *get_field(size_t index) const

Retrieve a field data by its index.

Parameters:

index – index of the field to retrieve.

Returns:

pointer to the field instance, or nullptr if the index is out-of-range.

pivot_cache_id_t get_id() const
const records_type &get_all_records() const
class pivot_collection

Public Functions

pivot_collection(document &doc)
~pivot_collection()
void insert_worksheet_cache(std::string_view sheet_name, const ixion::abs_range_t &range, std::unique_ptr<pivot_cache> &&cache)

Insert a new pivot cache associated with a worksheet source.

Parameters:
  • sheet_name – name of the sheet where the source data is.

  • range – range of the source data. Note that the sheet indices are not used.

  • cache – pivot cache instance to store.

void insert_worksheet_cache(std::string_view table_name, std::unique_ptr<pivot_cache> &&cache)

Insert a new pivot cache associated with a table name.

Parameters:
  • table_name – source table name.

  • cache – pivot cache instance to store.

size_t get_cache_count() const

Count the number of pivot caches currently stored.

Returns:

number of pivot caches currently stored in the document.

const pivot_cache *get_cache(std::string_view sheet_name, const ixion::abs_range_t &range) const
pivot_cache *get_cache(pivot_cache_id_t cache_id)
const pivot_cache *get_cache(pivot_cache_id_t cache_id) const