xlnt
|
An object used to refer to a cell. References have two parts, the column and the row. In Excel, the reference string A1 refers to the top-left-most cell. A cell_reference can be initialized from a string of this form or a 1-indexed ordered pair of the form column, row. More...
#include <cell_reference.hpp>
Public Member Functions | |
cell_reference () | |
Default constructor makes a reference to the top-left-most cell, "A1". More... | |
cell_reference (const char *reference_string) | |
Constructs a cell_reference from a string reprenting a cell coordinate (e.g. $B14). More... | |
cell_reference (const std::string &reference_string) | |
Constructs a cell_reference from a string reprenting a cell coordinate (e.g. $B14). More... | |
cell_reference (column_t column, row_t row) | |
Constructs a cell_reference from a 1-indexed column index and row index. More... | |
cell_reference & | make_absolute (bool absolute_column=true, bool absolute_row=true) |
Converts a coordinate to an absolute coordinate string (e.g. B12 -> $B$12) Defaulting to true, absolute_column and absolute_row can optionally control whether the resulting cell_reference has an absolute column (e.g. B12 -> $B12) and absolute row (e.g. B12 -> B$12) respectively. More... | |
bool | column_absolute () const |
Returns true if the reference refers to an absolute column, otherwise false. More... | |
void | column_absolute (bool absolute_column) |
Makes this reference have an absolute column if absolute_column is true, otherwise not absolute. More... | |
bool | row_absolute () const |
Returns true if the reference refers to an absolute row, otherwise false. More... | |
void | row_absolute (bool absolute_row) |
Makes this reference have an absolute row if absolute_row is true, otherwise not absolute. More... | |
column_t | column () const |
Returns a string that identifies the column of this reference (e.g. second column from left is "B") More... | |
void | column (const std::string &column_string) |
Sets the column of this reference from a string that identifies a particular column. More... | |
column_t::index_t | column_index () const |
Returns a 1-indexed numeric index of the column of this reference. More... | |
void | column_index (column_t column) |
Sets the column of this reference from a 1-indexed number that identifies a particular column. More... | |
row_t | row () const |
Returns a 1-indexed numeric index of the row of this reference. More... | |
void | row (row_t row) |
Sets the row of this reference from a 1-indexed number that identifies a particular row. More... | |
cell_reference | make_offset (int column_offset, int row_offset) const |
Returns a cell_reference offset from this cell_reference by the number of columns and rows specified by the parameters. A negative value for column_offset or row_offset results in a reference above or left of this cell_reference, respectively. More... | |
std::string | to_string () const |
Returns a string like "A1" for cell_reference(1, 1). More... | |
range_reference | to_range () const |
Returns a 1x1 range_reference containing only this cell_reference. More... | |
range_reference | operator, (const cell_reference &other) const |
I've always wanted to overload the comma operator. cell_reference("A", 1), cell_reference("B", 1) will return range_reference(cell_reference("A", 1), cell_reference("B", 1)) More... | |
bool | operator== (const cell_reference &comparand) const |
Returns true if this reference is identical to comparand including in absoluteness of column and row. More... | |
bool | operator== (const std::string &reference_string) const |
Constructs a cell_reference from reference_string and return the result of their comparison. More... | |
bool | operator== (const char *reference_string) const |
Constructs a cell_reference from reference_string and return the result of their comparison. More... | |
bool | operator!= (const cell_reference &comparand) const |
Returns true if this reference is not identical to comparand including in absoluteness of column and row. More... | |
bool | operator!= (const std::string &reference_string) const |
Constructs a cell_reference from reference_string and return the result of their comparison. More... | |
bool | operator!= (const char *reference_string) const |
Constructs a cell_reference from reference_string and return the result of their comparison. More... | |
Static Public Member Functions | |
static std::pair< std::string, row_t > | split_reference (const std::string &reference_string) |
Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}. More... | |
static std::pair< std::string, row_t > | split_reference (const std::string &reference_string, bool &absolute_column, bool &absolute_row) |
Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}. Reference parameters absolute_column and absolute_row will be set to true if column part or row part are prefixed by a dollar-sign indicating they are absolute, otherwise false. More... | |
An object used to refer to a cell. References have two parts, the column and the row. In Excel, the reference string A1 refers to the top-left-most cell. A cell_reference can be initialized from a string of this form or a 1-indexed ordered pair of the form column, row.
xlnt::cell_reference::cell_reference | ( | ) |
Default constructor makes a reference to the top-left-most cell, "A1".
xlnt::cell_reference::cell_reference | ( | const char * | reference_string | ) |
Constructs a cell_reference from a string reprenting a cell coordinate (e.g. $B14).
xlnt::cell_reference::cell_reference | ( | const std::string & | reference_string | ) |
Constructs a cell_reference from a string reprenting a cell coordinate (e.g. $B14).
Constructs a cell_reference from a 1-indexed column index and row index.
column_t xlnt::cell_reference::column | ( | ) | const |
Returns a string that identifies the column of this reference (e.g. second column from left is "B")
void xlnt::cell_reference::column | ( | const std::string & | column_string | ) |
Sets the column of this reference from a string that identifies a particular column.
bool xlnt::cell_reference::column_absolute | ( | ) | const |
Returns true if the reference refers to an absolute column, otherwise false.
void xlnt::cell_reference::column_absolute | ( | bool | absolute_column | ) |
Makes this reference have an absolute column if absolute_column is true, otherwise not absolute.
column_t::index_t xlnt::cell_reference::column_index | ( | ) | const |
Returns a 1-indexed numeric index of the column of this reference.
void xlnt::cell_reference::column_index | ( | column_t | column | ) |
Sets the column of this reference from a 1-indexed number that identifies a particular column.
cell_reference& xlnt::cell_reference::make_absolute | ( | bool | absolute_column = true , |
bool | absolute_row = true |
||
) |
Converts a coordinate to an absolute coordinate string (e.g. B12 -> $B$12) Defaulting to true, absolute_column and absolute_row can optionally control whether the resulting cell_reference has an absolute column (e.g. B12 -> $B12) and absolute row (e.g. B12 -> B$12) respectively.
This is functionally equivalent to: cell_reference copy(*this); copy.column_absolute(absolute_column); copy.row_absolute(absolute_row); return copy;
cell_reference xlnt::cell_reference::make_offset | ( | int | column_offset, |
int | row_offset | ||
) | const |
Returns a cell_reference offset from this cell_reference by the number of columns and rows specified by the parameters. A negative value for column_offset or row_offset results in a reference above or left of this cell_reference, respectively.
bool xlnt::cell_reference::operator!= | ( | const cell_reference & | comparand | ) | const |
Returns true if this reference is not identical to comparand including in absoluteness of column and row.
bool xlnt::cell_reference::operator!= | ( | const std::string & | reference_string | ) | const |
Constructs a cell_reference from reference_string and return the result of their comparison.
bool xlnt::cell_reference::operator!= | ( | const char * | reference_string | ) | const |
Constructs a cell_reference from reference_string and return the result of their comparison.
range_reference xlnt::cell_reference::operator, | ( | const cell_reference & | other | ) | const |
I've always wanted to overload the comma operator. cell_reference("A", 1), cell_reference("B", 1) will return range_reference(cell_reference("A", 1), cell_reference("B", 1))
bool xlnt::cell_reference::operator== | ( | const cell_reference & | comparand | ) | const |
Returns true if this reference is identical to comparand including in absoluteness of column and row.
bool xlnt::cell_reference::operator== | ( | const std::string & | reference_string | ) | const |
Constructs a cell_reference from reference_string and return the result of their comparison.
bool xlnt::cell_reference::operator== | ( | const char * | reference_string | ) | const |
Constructs a cell_reference from reference_string and return the result of their comparison.
row_t xlnt::cell_reference::row | ( | ) | const |
Returns a 1-indexed numeric index of the row of this reference.
void xlnt::cell_reference::row | ( | row_t | row | ) |
Sets the row of this reference from a 1-indexed number that identifies a particular row.
bool xlnt::cell_reference::row_absolute | ( | ) | const |
Returns true if the reference refers to an absolute row, otherwise false.
void xlnt::cell_reference::row_absolute | ( | bool | absolute_row | ) |
Makes this reference have an absolute row if absolute_row is true, otherwise not absolute.
|
static |
Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}.
|
static |
Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}. Reference parameters absolute_column and absolute_row will be set to true if column part or row part are prefixed by a dollar-sign indicating they are absolute, otherwise false.
range_reference xlnt::cell_reference::to_range | ( | ) | const |
Returns a 1x1 range_reference containing only this cell_reference.
std::string xlnt::cell_reference::to_string | ( | ) | const |
Returns a string like "A1" for cell_reference(1, 1).