crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Data::ImportExport::OpenDocument Namespace Reference

Namespace for importing and exporting OpenDocument spreadsheets. More...

Typedefs

using StringString = std::pair< std::string, std::string >
 A pair of strings. More...
 
using TableRow = std::vector< std::string >
 A vector of strings used as rows in a spreadsheet table. More...
 
using Table = std::vector< TableRow >
 A vector of vectors of strings used as spreadsheet tables. More...
 
using NamedTable = std::pair< std::string, Table >
 A pair containing the name and the content of a spreadsheet table. More...
 

Variables

constexpr auto cellSpacing {5}
 The number of spaces before a OpenDocument XML cell element. More...
 
constexpr auto cellLines {3}
 The number of lines used for a OpenDocument XML cell element and its content. More...
 
constexpr auto cellConstChars {57}
 The number of additional characters for a OpenDocument XML cell element and its content. More...
 

Import and Export

std::string exportSpreadsheet (const std::vector< NamedTable > &tables, bool firstRowBold)
 Exports tables as a OpenDocument spreadsheet. More...
 

Helper

std::string cell (std::uint8_t spacing, const std::string &raw, const std::string &style)
 Creates the XML code for a simple cell containing a value. More...
 

Detailed Description

Namespace for importing and exporting OpenDocument spreadsheets.

Typedef Documentation

◆ NamedTable

using crawlservpp::Data::ImportExport::OpenDocument::NamedTable = typedef std::pair<std::string, Table>

A pair containing the name and the content of a spreadsheet table.

◆ StringString

using crawlservpp::Data::ImportExport::OpenDocument::StringString = typedef std::pair<std::string, std::string>

A pair of strings.

◆ Table

A vector of vectors of strings used as spreadsheet tables.

◆ TableRow

using crawlservpp::Data::ImportExport::OpenDocument::TableRow = typedef std::vector<std::string>

A vector of strings used as rows in a spreadsheet table.

Function Documentation

◆ cell()

std::string crawlservpp::Data::ImportExport::OpenDocument::cell ( std::uint8_t  spacing,
const std::string &  raw,
const std::string &  style 
)
inline

Creates the XML code for a simple cell containing a value.

If the given raw data is numeric, the cell will contain a float.

If the given raw data is a string, the special characters &'><" will be escaped.

Newlines will be added at the end of elements for formatting purposes, and Sub-elements will be nested with one additional space.

Parameters
spacingThe number of spaces to add before the cell.
rawThe raw data contained in the cell.
styleAn optional style argument present in the cell, in the format table:style-name="...".
Returns
A new string containing the OpenDocument XML code for the cell.

References cellConstChars, cellLines, crawlservpp::Helper::Strings::isDec(), and crawlservpp::Helper::Strings::replaceAll().

Referenced by exportSpreadsheet().

◆ exportSpreadsheet()

std::string crawlservpp::Data::ImportExport::OpenDocument::exportSpreadsheet ( const std::vector< NamedTable > &  tables,
bool  firstRowBold 
)
inline

Exports tables as a OpenDocument spreadsheet.

Parameters
tablesConstant reference to a vector containing the tables, each consisting of a pair of its name and a vector of rows, each consisting of a vector of strings representing the values in the row.
firstRowBoldSpecifies whether the first row in the tables should be formatted bold (to indicate column headings).
Returns
Copy of a string containing the content of the new OpenDocument spreadsheet to be written to disk.
Note
The result is ZIP-compressed and needs therefore be handled as binary data.

References cell(), cellSpacing, and crawlservpp::Data::Compression::Zip::compress().

Referenced by crawlservpp::Main::Server::tick().

Variable Documentation

◆ cellConstChars

constexpr auto crawlservpp::Data::ImportExport::OpenDocument::cellConstChars {57}
inline

The number of additional characters for a OpenDocument XML cell element and its content.

Referenced by cell().

◆ cellLines

constexpr auto crawlservpp::Data::ImportExport::OpenDocument::cellLines {3}
inline

The number of lines used for a OpenDocument XML cell element and its content.

Referenced by cell().

◆ cellSpacing

constexpr auto crawlservpp::Data::ImportExport::OpenDocument::cellSpacing {5}
inline

The number of spaces before a OpenDocument XML cell element.

Referenced by exportSpreadsheet().