xlnt
|
Columns can be referred to as a string A,B,...Z,AA,AB,..,ZZ,AAA,...,ZZZ or as a 1-indexed index. This class encapsulates both of these forms of column referencing and allows for conversions between them. More...
#include <index_types.hpp>
Public Types | |
using | index_t = std::uint32_t |
Alias declaration for the internal numeric type of this column. More... | |
Public Member Functions | |
column_t () | |
Default constructor. The column points to the "A" column. More... | |
column_t (index_t column_index) | |
Constructs a column from a number. More... | |
column_t (const std::string &column_string) | |
Constructs a column from a string. More... | |
column_t (const char *column_string) | |
Constructs a column from a string. More... | |
std::string | column_string () const |
Returns a string representation of this column index. More... | |
column_t & | operator= (const std::string &rhs) |
Sets this column to be equal to rhs and return reference to self. More... | |
column_t & | operator= (const char *rhs) |
Sets this column to be equal to rhs and return reference to self. More... | |
bool | operator== (const column_t &other) const |
Returns true if this column refers to the same column as other. More... | |
bool | operator!= (const column_t &other) const |
Returns true if this column doesn't refer to the same column as other. More... | |
bool | operator== (int other) const |
Returns true if this column refers to the same column as other. More... | |
bool | operator== (index_t other) const |
Returns true if this column refers to the same column as other. More... | |
bool | operator== (const std::string &other) const |
Returns true if this column refers to the same column as other. More... | |
bool | operator== (const char *other) const |
Returns true if this column refers to the same column as other. More... | |
bool | operator!= (int other) const |
Returns true if this column doesn't refer to the same column as other. More... | |
bool | operator!= (index_t other) const |
Returns true if this column doesn't refer to the same column as other. More... | |
bool | operator!= (const std::string &other) const |
Returns true if this column doesn't refer to the same column as other. More... | |
bool | operator!= (const char *other) const |
Returns true if this column doesn't refer to the same column as other. More... | |
bool | operator> (const column_t &other) const |
Returns true if other is to the right of this column. More... | |
bool | operator>= (const column_t &other) const |
Returns true if other is to the right of or equal to this column. More... | |
bool | operator< (const column_t &other) const |
Returns true if other is to the left of this column. More... | |
bool | operator<= (const column_t &other) const |
Returns true if other is to the left of or equal to this column. More... | |
bool | operator> (const column_t::index_t &other) const |
Returns true if other is to the right of this column. More... | |
bool | operator>= (const column_t::index_t &other) const |
Returns true if other is to the right of or equal to this column. More... | |
bool | operator< (const column_t::index_t &other) const |
Returns true if other is to the left of this column. More... | |
bool | operator<= (const column_t::index_t &other) const |
Returns true if other is to the left of or equal to this column. More... | |
column_t & | operator++ () |
Pre-increments this column, making it point to the column one to the right and returning a reference to it. More... | |
column_t & | operator-- () |
Pre-deccrements this column, making it point to the column one to the left and returning a reference to it. More... | |
column_t | operator++ (int) |
Post-increments this column, making it point to the column one to the right and returning the old column. More... | |
column_t | operator-- (int) |
Post-decrements this column, making it point to the column one to the left and returning the old column. More... | |
column_t & | operator+= (const column_t &rhs) |
Adds rhs to this column and returns a reference to this column. More... | |
column_t & | operator-= (const column_t &rhs) |
Subtracts rhs from this column and returns a reference to this column. More... | |
Static Public Member Functions | |
static index_t | column_index_from_string (const std::string &column_string) |
Convert a column letter into a column number (e.g. B -> 2) More... | |
static std::string | column_string_from_index (index_t column_index) |
Convert a column number into a column letter (3 -> 'C') More... | |
Public Attributes | |
index_t | index |
Internal numeric value of this column index. More... | |
Friends | |
column_t | operator+ (column_t lhs, const column_t &rhs) |
Returns the result of adding rhs to this column. More... | |
column_t | operator- (column_t lhs, const column_t &rhs) |
Returns the result of subtracing lhs by rhs column. More... | |
bool | operator> (const column_t::index_t &left, const column_t &right) |
Returns true if other is to the right of this column. More... | |
bool | operator>= (const column_t::index_t &left, const column_t &right) |
Returns true if other is to the right of or equal to this column. More... | |
bool | operator< (const column_t::index_t &left, const column_t &right) |
Returns true if other is to the left of this column. More... | |
bool | operator<= (const column_t::index_t &left, const column_t &right) |
Returns true if other is to the left of or equal to this column. More... | |
void | swap (column_t &left, column_t &right) |
Swaps the columns that left and right refer to. More... | |
Columns can be referred to as a string A,B,...Z,AA,AB,..,ZZ,AAA,...,ZZZ or as a 1-indexed index. This class encapsulates both of these forms of column referencing and allows for conversions between them.
using xlnt::column_t::index_t = std::uint32_t |
Alias declaration for the internal numeric type of this column.
xlnt::column_t::column_t | ( | ) |
Default constructor. The column points to the "A" column.
xlnt::column_t::column_t | ( | index_t | column_index | ) |
Constructs a column from a number.
xlnt::column_t::column_t | ( | const std::string & | column_string | ) |
Constructs a column from a string.
xlnt::column_t::column_t | ( | const char * | column_string | ) |
Constructs a column from a string.
|
static |
Convert a column letter into a column number (e.g. B -> 2)
Excel only supports 1 - 3 letter column names from A->ZZZ, so we restrict our column names to 1 - 3 characters, each in the range A - Z. Strings outside this range and malformed strings will throw column_string_index_exception.
std::string xlnt::column_t::column_string | ( | ) | const |
Returns a string representation of this column index.
|
static |
Convert a column number into a column letter (3 -> 'C')
Right shift the column, column_index, by 26 to find column letters in reverse order. These indices are 1-based, and can be converted to ASCII ordinals by adding 64.
bool xlnt::column_t::operator!= | ( | const column_t & | other | ) | const |
Returns true if this column doesn't refer to the same column as other.
bool xlnt::column_t::operator!= | ( | int | other | ) | const |
Returns true if this column doesn't refer to the same column as other.
bool xlnt::column_t::operator!= | ( | index_t | other | ) | const |
Returns true if this column doesn't refer to the same column as other.
bool xlnt::column_t::operator!= | ( | const std::string & | other | ) | const |
Returns true if this column doesn't refer to the same column as other.
bool xlnt::column_t::operator!= | ( | const char * | other | ) | const |
Returns true if this column doesn't refer to the same column as other.
column_t& xlnt::column_t::operator++ | ( | ) |
Pre-increments this column, making it point to the column one to the right and returning a reference to it.
column_t xlnt::column_t::operator++ | ( | int | ) |
Post-increments this column, making it point to the column one to the right and returning the old column.
Adds rhs to this column and returns a reference to this column.
column_t& xlnt::column_t::operator-- | ( | ) |
Pre-deccrements this column, making it point to the column one to the left and returning a reference to it.
column_t xlnt::column_t::operator-- | ( | int | ) |
Post-decrements this column, making it point to the column one to the left and returning the old column.
Subtracts rhs from this column and returns a reference to this column.
bool xlnt::column_t::operator< | ( | const column_t & | other | ) | const |
Returns true if other is to the left of this column.
bool xlnt::column_t::operator< | ( | const column_t::index_t & | other | ) | const |
Returns true if other is to the left of this column.
bool xlnt::column_t::operator<= | ( | const column_t & | other | ) | const |
Returns true if other is to the left of or equal to this column.
bool xlnt::column_t::operator<= | ( | const column_t::index_t & | other | ) | const |
Returns true if other is to the left of or equal to this column.
column_t& xlnt::column_t::operator= | ( | const std::string & | rhs | ) |
Sets this column to be equal to rhs and return reference to self.
column_t& xlnt::column_t::operator= | ( | const char * | rhs | ) |
Sets this column to be equal to rhs and return reference to self.
bool xlnt::column_t::operator== | ( | const column_t & | other | ) | const |
Returns true if this column refers to the same column as other.
bool xlnt::column_t::operator== | ( | int | other | ) | const |
Returns true if this column refers to the same column as other.
bool xlnt::column_t::operator== | ( | index_t | other | ) | const |
Returns true if this column refers to the same column as other.
bool xlnt::column_t::operator== | ( | const std::string & | other | ) | const |
Returns true if this column refers to the same column as other.
bool xlnt::column_t::operator== | ( | const char * | other | ) | const |
Returns true if this column refers to the same column as other.
bool xlnt::column_t::operator> | ( | const column_t & | other | ) | const |
Returns true if other is to the right of this column.
bool xlnt::column_t::operator> | ( | const column_t::index_t & | other | ) | const |
Returns true if other is to the right of this column.
bool xlnt::column_t::operator>= | ( | const column_t & | other | ) | const |
Returns true if other is to the right of or equal to this column.
bool xlnt::column_t::operator>= | ( | const column_t::index_t & | other | ) | const |
Returns true if other is to the right of or equal to this column.
Returns the result of adding rhs to this column.
Returns the result of subtracing lhs by rhs column.
|
friend |
Returns true if other is to the left of this column.
|
friend |
Returns true if other is to the left of or equal to this column.
|
friend |
Returns true if other is to the right of this column.
|
friend |
Returns true if other is to the right of or equal to this column.
Swaps the columns that left and right refer to.
index_t xlnt::column_t::index |
Internal numeric value of this column index.