Qore CsvUtil Module Reference  1.5
CsvUtil::CsvStringWriter Class Reference

The CsvStringWriter class for in-memory string CSV creation. More...

Inheritance diagram for CsvUtil::CsvStringWriter:

Public Member Functions

 constructor (*hash opts)
 creates the CsvStringWriter single-type mode with content in the memory More...
 
 constructor (hash spec, hash opts)
 creates the CsvStringWriter single-type mode with content in the memory More...
 
string getContent ()
 Get the current in-memory content as a string.
 
string write (Qore::AbstractIterator iterator)
 Stream iterator and return a CSV-formatted output string. More...
 
string write (list l)
 Stream the contents of the list and return CSV-formatted output as a string. More...
 
private writeRawLine (list values)
 This method must be overridden in child classes to provide the output implementation.
 
- Public Member Functions inherited from CsvUtil::AbstractCsvWriter
 constructor (string n_errname, *hash n_opts)
 Creates the AbstractCsvWriter in single-type mode. More...
 
 constructor (string n_errname, hash spec, hash n_opts)
 Creates the AbstractCsvWriter in single-type mode. More...
 
private string prepareRawLine (list values)
 Prepare a string (line with EOF) with formatting and escaping. More...
 
private processCommonOptions (*hash n_opts, int C_OPTx)
 Process options and set internal variables.
 
private processSpec ()
 Process specification and set internal variable for mapping.
 
 write (Qore::AbstractIterator iterator)
 Stream an iterator into the output. More...
 
 write (Qore::SQL::SQLStatement iterator)
 Stream an iterator into the output. More...
 
 write (list l)
 Stream the contents of the list into the output. More...
 
private writeHeaders ()
 Write csv headers.
 
 writeLine (list values)
 Write a line with a list of values; data are checked against column rules. More...
 
 writeLine (hash values)
 Write a line with headers-values hash. More...
 
 writeLine (string type, list values)
 Write a line with headers-values list. More...
 
 writeLine (string type, hash values)
 Write a line for a specific record from a hash to the output. More...
 

Detailed Description

The CsvStringWriter class for in-memory string CSV creation.

Member Function Documentation

CsvUtil::CsvStringWriter::constructor ( *hash  opts)

creates the CsvStringWriter single-type mode with content in the memory

Parameters
optsAbstractCsvWriter Constructor Option Hash Overview
Exceptions
CSVSTRINGITER-ERRORin the case of incorrect options
CsvUtil::CsvStringWriter::constructor ( hash  spec,
hash  opts 
)

creates the CsvStringWriter single-type mode with content in the memory

Parameters
speca hash of field and type definitions; see Option Field Hash for more information
optsAbstractCsvWriter Constructor Option Hash Overview
Exceptions
CSVSTRINGITER-ERRORin the case of incorrect options
string CsvUtil::CsvStringWriter::write ( Qore::AbstractIterator  iterator)

Stream iterator and return a CSV-formatted output string.

Parameters
iteratoran iterator to stream data
Returns
the CSV-formatted output string corresponding to the input data

The iterator has to contain List or Hash as a return value of getValue() method.

Exceptions
CSVFILEWRITER-DATA-ERRORwhen the data does not fit defined column constraints or when getValue does not return list or hash
string CsvUtil::CsvStringWriter::write ( list  l)

Stream the contents of the list and return CSV-formatted output as a string.

Parameters
la list of input data to format as CSV output
Returns
the CSV-formatted output string corresponding to the input data

The list has to contain List or Hash elements that can be formatted according to the CSV definition

Exceptions
CSVFILEWRITER-DATA-ERRORwhen the data does not fit defined column constraints or when the list elements have the wrong type or values