Orcus
Public Member Functions | List of all members
orcus::orcus_xml Class Reference

Public Member Functions

 orcus_xml (const orcus_xml &)=delete
 
orcus_xmloperator= (const orcus_xml &)=delete
 
 orcus_xml (xmlns_repository &ns_repo, spreadsheet::iface::import_factory *im_fact, spreadsheet::iface::export_factory *ex_fact)
 
void set_namespace_alias (const pstring &alias, const pstring &uri, bool default_ns=false)
 
void set_cell_link (const pstring &xpath, const pstring &sheet, spreadsheet::row_t row, spreadsheet::col_t col)
 
void start_range (const pstring &sheet, spreadsheet::row_t row, spreadsheet::col_t col)
 
void append_field_link (const pstring &xpath, const pstring &label)
 
void set_range_row_group (const pstring &xpath)
 
void commit_range ()
 
void append_sheet (const pstring &name)
 
void read_stream (const char *p, size_t n)
 
void read_map_definition (const char *p, size_t n)
 
void detect_map_definition (const char *p, size_t n)
 
void write_map_definition (const char *p, size_t n, std::ostream &out) const
 
void write (const char *p_in, size_t n_in, std::ostream &out) const
 

Member Function Documentation

◆ append_field_link()

void orcus::orcus_xml::append_field_link ( const pstring xpath,
const pstring label 
)

Append a field that is mapped to a specified path in the XML document to the current linked range.

Parameters
xpathpath to the element or attribute to link as a field.
labelcustom header label to use in lieu of the name of the linked entity.

◆ append_sheet()

void orcus::orcus_xml::append_sheet ( const pstring name)

Append a new sheet to the spreadsheet document.

Parameters
namename of the sheet.

◆ commit_range()

void orcus::orcus_xml::commit_range ( )

Commit the mapping definition of the current range.

◆ detect_map_definition()

void orcus::orcus_xml::detect_map_definition ( const char *  p,
size_t  n 
)

Read a stream containing the source XML document, automatically detect all linkable ranges and import them one range per sheet.

Parameters
ppointer to the buffer that contains the source XML document.
nsize of the buffer.

◆ read_map_definition()

void orcus::orcus_xml::read_map_definition ( const char *  p,
size_t  n 
)

Read an XML stream that contains an entire set of mapping rules.

This method also inserts all necessary sheets into the document model.

Parameters
ppointer to the buffer that contains the XML string.
nsize of the buffer.

◆ read_stream()

void orcus::orcus_xml::read_stream ( const char *  p,
size_t  n 
)

Read the stream containing the source XML document.

Parameters
ppointer to the buffer containing the source XML document.
nsize of the buffer.

◆ set_cell_link()

void orcus::orcus_xml::set_cell_link ( const pstring xpath,
const pstring sheet,
spreadsheet::row_t  row,
spreadsheet::col_t  col 
)

Define a mapping of a single element or attribute to a single cell location.

Parameters
xpathpath to the element or attribute to link.
sheetsheet index (0-based) of the linked cell location.
rowrow index (0-based) of the linked cell location.
colcolumn index (0-based) of the linked cell location.

◆ set_namespace_alias()

void orcus::orcus_xml::set_namespace_alias ( const pstring alias,
const pstring uri,
bool  default_ns = false 
)

Define a namespace and its alias used in a map file.

Parameters
aliasalias for the namespace.
urinamespace value.
default_nswhether or not to use this namespace as the default namespace. When this value is set to true, the namespace being set will be applied for all elements and attributes used in the paths without explicit namespace values.

◆ set_range_row_group()

void orcus::orcus_xml::set_range_row_group ( const pstring xpath)

Set the element located in the specified path as a row group in the current linked range.

If the element is defined as a row-group element, the row index will increment whenever that element closes.

Parameters
xpathpath to the element to use as a row group element.

◆ start_range()

void orcus::orcus_xml::start_range ( const pstring sheet,
spreadsheet::row_t  row,
spreadsheet::col_t  col 
)

Initiate the mapping definition of a linked range. The definition will get committed when the commit_range method is called.

Parameters
sheetsheet index (0-based) of the linked cell location.
rowrow index (0-based) of the linked cell location.
colcolumn index (0-based) of the linked cell location.

◆ write()

void orcus::orcus_xml::write ( const char *  p_in,
size_t  n_in,
std::ostream &  out 
) const

Write the linked cells and ranges in the spreadsheet document as an XML document using the same map definition rules used to load the content.

Note that this requires the source XML document stream, as it re-uses parts of the source stream.

Parameters
p_inpointer to the buffer that contains the source XML document.
n_insize of the buffer containing the source XML document.
outoutput stream to write the XML document to.

◆ write_map_definition()

void orcus::orcus_xml::write_map_definition ( const char *  p,
size_t  n,
std::ostream &  out 
) const

Read a stream containing the source XML document, automatically detect all linkable ranges, and write a map definition file depicting the detected ranges.

Parameters
ppointer to the buffer that contains the source XML document.
nsize of the buffer.
outoutput stream to write the map definition file to.