Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CXMLSpreadsheet Class Reference

Reader for XML spreadsheet and CSV table data. More...

#include <Utils/XMLSpreadsheet/CXMLSpreadsheet.h>

Classes

struct  SCell
 One spreadsheet cell. More...
struct  SRow
 One spreadsheet row that owns its cells. More...
struct  SSheet
 One spreadsheet sheet that owns its rows. More...

Public Member Functions

 CXMLSpreadsheet ()
 Construct an empty spreadsheet.
virtual ~CXMLSpreadsheet ()
 Destroy the spreadsheet and all loaded data.
bool open (const char *file)
 Load spreadsheet data from an XML file.
bool open (io::IXMLReader *xmlReader)
 Load spreadsheet data from an existing XML reader.
bool openCSV (const char *file)
 Load spreadsheet data from a CSV file.
u32 getSheetCount ()
 Get the number of loaded sheets.
SSheetgetSheet (int i)
 Get a sheet by index.
SSheetoperator[] (int i)
 Get a sheet by index.
SCellgetCell (SSheet *sheet, u32 row, u32 col)
 Find a cell by row and column.
SCellgetCell (SSheet *sheet, const char *cellName)
 Find a cell by spreadsheet cell name.
std::list< SCell * > getRange (SSheet *sheet, u32 fromRow, u32 fromCol, u32 toRow, u32 toCol)
 Get all cells inside a rectangular range.
std::list< SCell * > getRange (SSheet *sheet, const char *from, const char *to)
 Get all cells inside a named rectangular range.
bool convertCellName (const char *cellName, u32 &row, u32 &col)
 Convert a spreadsheet cell name into row and column indexes.
void clear ()
 Clear all loaded sheets and data.

Protected Member Functions

bool splitCsvLine (const std::string &line, char delimiter, std::vector< std::string > &cells)
 Split one CSV line into cell strings.
bool combineLine (std::vector< std::string > &cols, std::vector< std::string > &cells)
 Combine parsed columns with continuation cells for multi-line CSV fields.

Protected Attributes

std::vector< SSheet * > m_sheets

Detailed Description

Reader for XML spreadsheet and CSV table data.

The class owns all sheet, row, and cell objects it creates. Pointers returned by lookup functions remain valid until clear or the spreadsheet destructor.

Member Function Documentation

◆ combineLine()

bool Skylicht::CXMLSpreadsheet::combineLine ( std::vector< std::string > & cols,
std::vector< std::string > & cells )
protected

Combine parsed columns with continuation cells for multi-line CSV fields.

Parameters
colsCurrent accumulated columns.
cellsNewly parsed cells.
Returns
True when a complete row is available.

◆ convertCellName()

bool Skylicht::CXMLSpreadsheet::convertCellName ( const char * cellName,
u32 & row,
u32 & col )

Convert a spreadsheet cell name into row and column indexes.

Parameters
cellNameCell name such as A1.
rowReceives row index.
colReceives column index.
Returns
True if the name was converted.

◆ getCell() [1/2]

SCell * Skylicht::CXMLSpreadsheet::getCell ( SSheet * sheet,
const char * cellName )

Find a cell by spreadsheet cell name.

Parameters
sheetSheet to search.
cellNameCell name such as A1.
Returns
Cell pointer, or null when not found.

◆ getCell() [2/2]

SCell * Skylicht::CXMLSpreadsheet::getCell ( SSheet * sheet,
u32 row,
u32 col )

Find a cell by row and column.

Parameters
sheetSheet to search.
rowRow index.
colColumn index.
Returns
Cell pointer, or null when not found.

◆ getRange() [1/2]

std::list< SCell * > Skylicht::CXMLSpreadsheet::getRange ( SSheet * sheet,
const char * from,
const char * to )

Get all cells inside a named rectangular range.

Parameters
sheetSheet to search.
fromFirst cell name, such as A1.
toLast cell name, such as C10.
Returns
List of matching cell pointers.

◆ getRange() [2/2]

std::list< SCell * > Skylicht::CXMLSpreadsheet::getRange ( SSheet * sheet,
u32 fromRow,
u32 fromCol,
u32 toRow,
u32 toCol )

Get all cells inside a rectangular range.

Parameters
sheetSheet to search.
fromRowFirst row index.
fromColFirst column index.
toRowLast row index.
toColLast column index.
Returns
List of matching cell pointers.

◆ getSheet()

SSheet * Skylicht::CXMLSpreadsheet::getSheet ( int i)
inline

Get a sheet by index.

Parameters
iZero-based sheet index.
Returns
Sheet pointer owned by the spreadsheet.

◆ getSheetCount()

u32 Skylicht::CXMLSpreadsheet::getSheetCount ( )
inline

Get the number of loaded sheets.

Returns
Sheet count.

◆ open() [1/2]

bool Skylicht::CXMLSpreadsheet::open ( const char * file)

Load spreadsheet data from an XML file.

Parameters
filePath to the XML spreadsheet file.
Returns
True if loading succeeds.

◆ open() [2/2]

bool Skylicht::CXMLSpreadsheet::open ( io::IXMLReader * xmlReader)

Load spreadsheet data from an existing XML reader.

Parameters
xmlReaderXML reader positioned at the spreadsheet source.
Returns
True if loading succeeds.

◆ openCSV()

bool Skylicht::CXMLSpreadsheet::openCSV ( const char * file)

Load spreadsheet data from a CSV file.

Parameters
filePath to the CSV file.
Returns
True if loading succeeds.

◆ operator[]()

SSheet * Skylicht::CXMLSpreadsheet::operator[] ( int i)
inline

Get a sheet by index.

Parameters
iZero-based sheet index.
Returns
Sheet pointer owned by the spreadsheet.

◆ splitCsvLine()

bool Skylicht::CXMLSpreadsheet::splitCsvLine ( const std::string & line,
char delimiter,
std::vector< std::string > & cells )
protected

Split one CSV line into cell strings.

Parameters
lineSource CSV line.
delimiterCSV delimiter character.
cellsReceives parsed cells.
Returns
True if the line was split successfully.

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