Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
core_lib::csv_grid::TRow< C, T > Class Template Referencefinal

Class defining a row of the grid. More...

`#include <CsvGridRow.h>`

## Public Types
using | container_type = C< T, std::allocator< T > >
| typedef for container type
using | cell_type = T
| typedef for container type

## Public Member Functions
| TRow ()=default
| Default constructor.
| TRow (const TRow &)=default
| Copy constructor.
| TRow (TRow &&)=default
| Move constructor.
| TRow (size_t numCols)
| Initializing constructor. More...
| TRow (const std::string &line, eCellFormatOptions options)
| Initializing constructor. More...
| TRow (std::initializer_list< T > cells)
| Initializer list constructor. More...
| ~TRow ()=default
| Destructor.
TRow & | operator= (const TRow &)=default
| Copy assignment operator.
TRow & | operator= (TRow &&)=default
| Move assignment operator.
cell_type & | operator[] (size_t col)
| Subscript operator. More...
const cell_type & | operator[] (size_t col) const
| Const subscript operator. More...
bool | Empty () const
| Get empty state of row. More...
size_t | GetSize () const
| Get the number of columns. More...
void | SetSize (size_t cols)
| Set the number of columns in the row. More...
template<typename V >
void | AddColumn (V value)
| Add a column with the given value. More...
void | AddColumn ()
| Add a column with default value. More...
template<typename V >
void | InsertColumn (size_t col, V value)
| Insert a new cell. More...
void | InsertColumn (size_t col)
| Insert a new cell. More...
void | ClearCells ()
| Clear the cells' contents. More...
void | ResetRow ()
| Clear the entire row. More...

## Private Member Functions
void | LoadRowFromCsvFileLine (const std::string &line, eCellFormatOptions options)
| Load a row from a line in a CSV file. More...
void | OutputRowToStream (std::ostream &os) const
| Write the row's contents to a stream object. More...
void | TokenizeLineQuoted (const std::string &line)
| Tokenize a row with double quoted cells. More...
void | TokenizeLine (const std::string &line)
| Tokenize a row with simple cells. More...

## Private Attributes
reserver::ContainerReserver< C, T > | m_reserve {}
| The reservation function to use when initialising the container.
container_type | m_cells {}
| The row's cells.

## Friends
class | TCsvGrid< C, T >
| Friend declaration of CsvGrid so it can have private access to its rows.

## Detailed Description

### template<template< class, class > class C, class T = Cell>
class core_lib::csv_grid::TRow< C, T >

Class defining a row of the grid.

This class provides the definition of the interface for a row within the grid. A row contains cells and each cell's position represents a column within the grid.

## Constructor & Destructor Documentation

## ◆ TRow() [1/3]

template<template< class, class > class C, class T = Cell>

core_lib::csv_grid::TRow< C, T >::TRow | ( | size_t | numCols | ) |
| inline explicit

Initializing constructor.

Parameters

  [in] | numCols | - The initial number of columns.

Create the row with an initial number of columns.

## ◆ TRow() [2/3]

template<template< class, class > class C, class T = Cell>

core_lib::csv_grid::TRow< C, T >::TRow | ( | const std::string & | line,
|  | eCellFormatOptions | options
| ) |  |
| inline

Initializing constructor.

Parameters

  [in] | line | - The initial value string - a comma separated line from a CSV file.
  [in] | options | - The line format.

Create the row with an initial value and specify whether cells are wrapped in double quotes in the CSV file.

## ◆ TRow() [3/3]

template<template< class, class > class C, class T = Cell>

core_lib::csv_grid::TRow< C, T >::TRow | ( | std::initializer_list< T > | cells | ) |
| inline

Initializer list constructor.

Parameters

  [in] | cells | - The initial list of cells.

Create the row from the given list of cells.

## Member Function Documentation

## ◆ AddColumn() [1/2]

template<template< class, class > class C, class T = Cell>
template<typename V >

void core_lib::csv_grid::TRow< C, T >::AddColumn | ( | V | value | ) |
| inline

Add a column with the given value.

Parameters

  [in] | value | - The cell's value for the new column.

The column count is increased by one and the new cell is initialised with the given string.

## ◆ AddColumn() [2/2]

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::AddColumn | ( |  | ) |
| inline

Add a column with default value.

The column count is increased by one and the new cell is initialised default value from default cell constructor.

## ◆ ClearCells()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::ClearCells | ( |  | ) |
| inline

Clear the cells' contents.

The contents of each column's cell is cleared but the column count remains unchanged.

## ◆ Empty()

template<template< class, class > class C, class T = Cell>

bool core_lib::csv_grid::TRow< C, T >::Empty | ( |  | ) | const
| inline

Get empty state of row.

Returns
  True if row is empty.

## ◆ GetSize()

template<template< class, class > class C, class T = Cell>

size_t core_lib::csv_grid::TRow< C, T >::GetSize | ( |  | ) | const
| inline

Get the number of columns.

Returns
  The number of columns for this row.

## ◆ InsertColumn() [1/2]

template<template< class, class > class C, class T = Cell>
template<typename V >

void core_lib::csv_grid::TRow< C, T >::InsertColumn | ( | size_t | col,
|  | V | value
| ) |  |
| inline

Insert a new cell.

Parameters

  [in] | col | - The column index at which the new cell is to be inserted.
  [in] | value | - The value to assign to the newly inserted cell.

The column count is increased by one and the new cell is initialised with the given string.

Note
  If the index is out of bounds a std::out_of_range exception is thrown.

## ◆ InsertColumn() [2/2]

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::InsertColumn | ( | size_t | col | ) |
| inline

Insert a new cell.

Parameters

  [in] | col | - The column index at which the new cell is to be inserted.

The column count is increased by one and the new cell is initialised with the default cell constructor.

Note
  If the index is out of bounds a std::out_of_range exception is thrown.

## ◆ LoadRowFromCsvFileLine()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::LoadRowFromCsvFileLine | ( | const std::string & | line,
|  | eCellFormatOptions | options
| ) |  |
| inline private

Load a row from a line in a CSV file.

Parameters

  [in] | line | - The line from the CSV file.
  [in] | options | - The cell format options.

Create a row by loading it from a line read in from a CSV file. The options parameter is used to decide how to tokenize the line.

## ◆ operator[]() [1/2]

template<template< class, class > class C, class T = Cell>

cell_type& core_lib::csv_grid::TRow< C, T >::operator[] | ( | size_t | col | ) |
| inline

Subscript operator.

Parameters

  [in] | col | - A 0-based column index.

Returns
  The cell at the given column index.

Retrieve the cell at a given column index within a row.

Note
  If the index is out of bounds a std::out_of_range exception is thrown.

## ◆ operator[]() [2/2]

template<template< class, class > class C, class T = Cell>

const cell_type& core_lib::csv_grid::TRow< C, T >::operator[] | ( | size_t | col | ) | const
| inline

Const subscript operator.

Parameters

  [in] | col | - A 0-based column index.

Returns
  The cell at the given column index.

Retrieve the cell at a given column index within a row.

Note
  If the index is out of bounds a std::out_of_range exception is thrown.

## ◆ OutputRowToStream()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::OutputRowToStream | ( | std::ostream & | os | ) | const
| inline private

Write the row's contents to a stream object.

Parameters

  [in,out] | os | - The stream object to write to.

The row's contents are formatted using CSV formating and output to the stream object.

## ◆ ResetRow()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::ResetRow | ( |  | ) |
| inline

Clear the entire row.

The cells are completely removed from the row leaving the column count as 0 afterwards.

## ◆ SetSize()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::SetSize | ( | size_t | cols | ) |
| inline

Set the number of columns in the row.

Parameters

  [in] | cols | - The number of columns to set.

If the number of columns are being increased then existing content is preserved and new cells are added at the end of the row forming the extra columns.

## ◆ TokenizeLine()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::TokenizeLine | ( | const std::string & | line | ) |
| inline private

Tokenize a row with simple cells.

Parameters

  [in] | line | - A CSV file's line of text.

The comma separated row's tokens are extracted using a simple getline based algorithm. This versio ncannot handle double quoted cells.

## ◆ TokenizeLineQuoted()

template<template< class, class > class C, class T = Cell>

void core_lib::csv_grid::TRow< C, T >::TokenizeLineQuoted | ( | const std::string & | line | ) |
| inline private

Tokenize a row with double quoted cells.

Parameters

  [in] | line | - A CSV file's line of text.

The comma separated row's tokens are extracted using a boost tokenizer object. This does impact the performance slightly.

The documentation for this class was generated from the following file:

- D:/Projects/CoreLibrary/Include/CsvGrid/CsvGridRow.h