|
LSSTApplications
1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
|
#include <Csv.h>
Public Member Functions | |
| CsvWriter (std::string const &path, CsvControl const &control, bool truncate=false, bool append=false) | |
| CsvWriter (std::ostream &out, CsvControl const &control) | |
| ~CsvWriter () | |
| CsvControl const & | getControl () const |
| void | endRecord () |
| void | flush () |
| size_t | getNumLines () const |
| size_t | getNumRecords () const |
| size_t | getNumFields () const |
Append field(s) to the end of a record | |
| void | appendFields (std::vector< std::string > const &fields) |
| void | appendField (std::string const &v) |
| void | appendField (char const *v) |
| void | appendField (bool v) |
| void | appendField (char v) |
| void | appendField (signed char v) |
| void | appendField (short v) |
| void | appendField (int v) |
| void | appendField (long v) |
| void | appendField (long long v) |
| void | appendField (unsigned char v) |
| void | appendField (unsigned short v) |
| void | appendField (unsigned int v) |
| void | appendField (unsigned long v) |
| void | appendField (unsigned long long v) |
| void | appendField (float v) |
| void | appendField (double v) |
| void | appendField (long double v) |
| void | appendNull () |
| void | write (std::string const &v) |
| void | write (char c) |
Private Member Functions | |
| CsvWriter (CsvWriter const &) | |
| CsvWriter & | operator= (CsvWriter const &) |
| void | _write (char const *s) |
| void | _writeQuoted (char const *s) |
| void | _writeUnquoted (char const *s) |
Private Attributes | |
| boost::scoped_ptr< std::ofstream > | _stream |
| Output file stream. More... | |
| std::ostream * | _out |
| Output stream. More... | |
| CsvControl | _control |
| File format. More... | |
| size_t | _numRecords |
| Number of records written. More... | |
| size_t | _numLines |
| Number of lines written. More... | |
| size_t | _numFields |
| Number of fields written. More... | |
A class for writing fields and records to Character-Separated-Value files in sequential order.
Methods are provided to output strings, bool, signed/unsigned integers, floating point types, and database NULLs. Integers are always output in base 10, and booleans are output as "1" (true) or "0". The precision of the decimal output for floating point numbers is such that the original binary value can be recovered exactly if the systems float to decimal conversion routines are correctly rounded and the input/output rounding modes agree.
This class provides the minimal exception safety guarantee - that is, exceptions will not cause crashes or leaks, and one can technically continue using the writer. However, the CSV files written under these conditions are not guaranteed to be legal. For example, partially written fields may be produced by a writer when raising an exception.
| lsst::ap::utils::CsvWriter::CsvWriter | ( | std::string const & | path, |
| CsvControl const & | control, | ||
| bool | truncate = false, |
||
| bool | append = false |
||
| ) |
Creates a new CsvWriter that outputs to the given file.
| path | Name of file to write to. |
| control | CSV format of the output file. |
| truncate | If true, an existing file is truncated. Otherwise, an attempt to create a writer for an existing file raises an exception unless append is true. |
| append | If true, append to an existing file. Has no effect if truncate is true. |
| lsst::ap::utils::CsvWriter::CsvWriter | ( | std::ostream & | out, |
| CsvControl const & | control | ||
| ) |
Creates a new CsvWriter that sends output to the given std::ostream.
This std::ostream must be kept alive for the life-time of the CsvWriter. If it is externally modified while the writer is alive (e.g. its exception mask is changed, or external writes are performed on it), then the behaviour and output of the writer is undefined.
|
private |
|
private |
Appends a field to the current record.
Definition at line 915 of file Csv.cc.
|
private |
Writes quoted field data, handling any required escaping.
Definition at line 977 of file Csv.cc.
|
private |
Writes unquoted field data, handling any required escaping.
Definition at line 1029 of file Csv.cc.
|
inline |
|
inline |
|
inline |
|
inline |
| void lsst::ap::utils::CsvWriter::appendField | ( | signed char | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | short | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | int | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | long | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | long long | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | unsigned char | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | unsigned short | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | unsigned int | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | unsigned long | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | unsigned long long | v | ) |
| void lsst::ap::utils::CsvWriter::appendField | ( | float | v | ) |
Appends a field for each string in the given list.
Definition at line 769 of file Csv.cc.
| void lsst::ap::utils::CsvWriter::appendField | ( | double | v | ) |
Appends a field for each string in the given list.
Definition at line 807 of file Csv.cc.
| void lsst::ap::utils::CsvWriter::appendField | ( | long double | v | ) |
Appends a field for each string in the given list.
Definition at line 845 of file Csv.cc.
| void lsst::ap::utils::CsvWriter::appendFields | ( | std::vector< std::string > const & | fields | ) |
| void lsst::ap::utils::CsvWriter::appendNull | ( | ) |
Appends a database NULL field to the current record. If there is no NULL representation, an empty field is written.
Definition at line 889 of file Csv.cc.
| void lsst::ap::utils::CsvWriter::endRecord | ( | ) |
Terminates a record - subsequent apppends will be to a new record.
Definition at line 716 of file Csv.cc.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
1.8.5