LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Public Attributes | List of all members
lsst::ap::utils::CsvControl Struct Reference

Parameters that define a Character-Separated-Value dialect. More...

#include <CsvControl.h>

Public Types

enum  Quoting { QUOTE_NONE = 0, QUOTE_ALL, QUOTE_MINIMAL }
 

Public Member Functions

 CsvControl ()
 
 ~CsvControl ()
 
bool isNullRecognizable () const
 
Quoting getQuoting () const
 
char getDelimiter () const
 
char getEscapeChar () const
 
char getQuoteChar () const
 
void validate () const
 

Public Attributes

std::string null
 "String representation of NULL field values. Never quoted on output.\n" "If specified, the representation may not contain any delimiter,\n" "quote, escape or line terminator characters ('\\n'/'\\r').\n" ; More...
 
bool hasNull
 "Indicates whether the null string is valid. If set to false, the only\n" "way NULLs can be recognized/written is if standardEscapes is set to\n" "true (in which case '\\N' is mapped to NULL, assuming that '\\' is\n" "the escape character).\n" ; More...
 
std::string quoting
 "Field quoting style for CSV input/output. Legal values are:\n" "\n" "'QUOTE_MINIMAL': Only quote fields when necessary - for instance,\n" " when a field value contains a delimiter character.\n" "\n" "'QUOTE_NONE': Never quote fields.\n" "\n" "'QUOTE_ALL': Always quote fields.\n" ; More...
 
std::string delimiter
 "A one character string containing the field delimiter character.\n" "Values of '\\0', '\\n', or '\\r' are illegal.\n" ; More...
 
std::string escapeChar
 "A one character string containing the escape character. An empty\n" "string is mapped to an escape character of '\\0', which disables\n" "escaping. A value equal to the delimiter or quote character is\n" "illegal, with one exception: both the escape and quote characters\n" "can be '\\0'. The '\\n' and '\\r' characters are also illegal.\n" ; More...
 
std::string quoteChar
 "A one character string containing the character used to quote fields\n" "when quoting is set to either 'QUOTE_ALL' or 'QUOTE_MINIMAL'. An\n" "empty string is mapped to a quote character of '\\0', which disables\n" "quoting (and is only legal when quoting is set to 'QUOTE_NONE'). A\n" "value equal to the delimiter or quote character is illegal, with one\n" "exception: both the escape and quote characters can be '\\0'. The\n" "'\\n' and '\\r' characters are also illegal.\n" ; More...
 
bool skipInitialSpace
 "If true, whitespace immediately following the delimiter is ignored." ; More...
 
bool doubleQuote
 "If true, embedded quote characters are escaped with a leading quote\n" "character. Otherwise the escape character is used. If escaping and\n" "double-quoting are disabled, writing a field with embedded quote\n" "character will raise an exception.\n" ; More...
 
bool standardEscapes
 "Flag indicating whether standard escape sequences should be handled.\n" "If false, then the character sequence '\\C', where C is any character,\n" "is mapped to C (assuming '\\' is the escape character). If true,\n" "the following special cases are handled differently:\n" "\n" "- '\\b' is mapped to BS - backspace (ASCII 8)\n" "- '\\f' is mapped to FF - form feed (ASCII 12)\n" "- '\\n' is mapped to NL - newline (ASCII 10)\n" "- '\\r' is mapped to CR - carriage return (ASCII 13)\n" "- '\\t' is mapped to TAB - horizontal tab (ASCII 9)\n" "- '\\v' is mapped to VT - vertical tab (ASCII 11)\n" "- '\\xD' and '\\xDD', where D is a hexadecimal digit, is mapped to\n" " the character with that numeric code.\n" "- A field value of exactly '\\N' (no quotes, whitespace, or other\n" " content) is treated as a NULL.\n" ; More...
 
bool trailingDelimiter
 "If true, then a trailing delimiter character is expected and written\n" "at end of every record, immediately preceding the line terminator.\n" ; More...
 
bool nonfiniteAsNull
 "If true, then non-finite (NaN, Inf, -Inf) floating point values are\n" "written out as NULL field values.\n" ; More...
 

Detailed Description

Parameters that define a Character-Separated-Value dialect.

These are intended to cover variations on the ubiquitous but often inconsistently defined comma-separated-value and tab-separated-value formats, and largely follow the parameters for dialect specification in the python csv module. One important goal is to allow the CSV output of various RDBMSes to be read and written. Accordingly, there are parameters that allow database NULLs to be recognized.

Definition at line 48 of file CsvControl.h.

Member Enumeration Documentation

Enumerator
QUOTE_NONE 

Never quote fields.

QUOTE_ALL 

Always quote fields.

QUOTE_MINIMAL 

Only quote fields when necessary.

Definition at line 49 of file CsvControl.h.

49  {
50  QUOTE_NONE = 0,
51  QUOTE_ALL,
53  };
Only quote fields when necessary.
Definition: CsvControl.h:52

Constructor & Destructor Documentation

lsst::ap::utils::CsvControl::CsvControl ( )

Definition at line 39 of file CsvControl.cc.

39  :
40  null(),
41  hasNull(false),
42  quoting("QUOTE_MINIMAL"),
43  delimiter(","),
44  escapeChar("\\"),
45  quoteChar("\""),
46  skipInitialSpace(false),
47  doubleQuote(false),
48  standardEscapes(true),
49  trailingDelimiter(false),
50  nonfiniteAsNull(false)
51 {
52  validate();
53 }
bool nonfiniteAsNull
&quot;If true, then non-finite (NaN, Inf, -Inf) floating point values are\n&quot; &quot;written out as NULL field va...
Definition: CsvControl.h:131
std::string delimiter
&quot;A one character string containing the field delimiter character.\n&quot; &quot;Values of &#39;\\0&#39;...
Definition: CsvControl.h:81
std::string null
&quot;String representation of NULL field values. Never quoted on output.\n&quot; &quot;If specified, the representation may not contain any delimiter,\n&quot; &quot;quote, escape or line terminator characters (&#39;\\n&#39;/&#39;\\r&#39;).\n&quot; ;
Definition: CsvControl.h:61
std::string escapeChar
&quot;A one character string containing the escape character. An empty\n&quot; &quot;string is mapped to an escap...
Definition: CsvControl.h:88
bool skipInitialSpace
&quot;If true, whitespace immediately following the delimiter is ignored.&quot; ;
Definition: CsvControl.h:100
std::string quoting
&quot;Field quoting style for CSV input/output. Legal values are:\n&quot; &quot;\n&quot; &quot;&#39;QUOTE_MINIMAL&#39;: Only quot...
Definition: CsvControl.h:77
bool hasNull
&quot;Indicates whether the null string is valid. If set to false, the only\n&quot; &quot;way NULLs can be recogn...
Definition: CsvControl.h:67
bool standardEscapes
&quot;Flag indicating whether standard escape sequences should be handled.\n&quot; &quot;If false, then the character sequence &#39;\\C&#39;, where C is any character,\n&quot; &quot;is mapped to C (assuming &#39;\\&#39; is the escape character). If true,\n&quot; &quot;the following special cases are handled differently:\n&quot; &quot;\n&quot; &quot;- &#39;\\b&#39; is mapped to BS - backspace (ASCII 8)\n&quot; &quot;- &#39;\\f&#39; is mapped to FF - form feed (ASCII 12)\n&quot; &quot;- &#39;\\n&#39; is mapped to NL - newline (ASCII 10)\n&quot; &quot;- &#39;\\r&#39; is mapped to CR - carriage return (ASCII 13)\n&quot; &quot;- &#39;\\t&#39; is mapped to TAB - horizontal tab (ASCII 9)\n&quot; &quot;- &#39;\\v&#39; is mapped to VT - vertical tab (ASCII 11)\n&quot; &quot;- &#39;\\xD&#39; and &#39;\\xDD&#39;, where D is a hexadecimal digit, is mapped to\n&quot; &quot; the character with that numeric code.\n&quot; &quot;- A field value of exactly &#39;\\N&#39; (no quotes, whitespace, or other\n&quot; &quot; content) is treated as a NULL.\n&quot; ;
Definition: CsvControl.h:123
bool trailingDelimiter
&quot;If true, then a trailing delimiter character is expected and written\n&quot; &quot;at end of every record...
Definition: CsvControl.h:127
bool doubleQuote
&quot;If true, embedded quote characters are escaped with a leading quote\n&quot; &quot;character. Otherwise the escape character is used. If escaping and\n&quot; &quot;double-quoting are disabled, writing a field with embedded quote\n&quot; &quot;character will raise an exception.\n&quot; ;
Definition: CsvControl.h:106
std::string quoteChar
&quot;A one character string containing the character used to quote fields\n&quot; &quot;when quoting is set to e...
Definition: CsvControl.h:97
lsst::ap::utils::CsvControl::~CsvControl ( )

Definition at line 55 of file CsvControl.cc.

55 { }

Member Function Documentation

char lsst::ap::utils::CsvControl::getDelimiter ( ) const
inline

Definition at line 155 of file CsvControl.h.

155  {
156  return delimiter.c_str()[0];
157  }
std::string delimiter
&quot;A one character string containing the field delimiter character.\n&quot; &quot;Values of &#39;\\0&#39;...
Definition: CsvControl.h:81
char lsst::ap::utils::CsvControl::getEscapeChar ( ) const
inline

Definition at line 158 of file CsvControl.h.

158  {
159  return escapeChar.c_str()[0];
160  }
std::string escapeChar
&quot;A one character string containing the escape character. An empty\n&quot; &quot;string is mapped to an escap...
Definition: CsvControl.h:88
char lsst::ap::utils::CsvControl::getQuoteChar ( ) const
inline

Definition at line 161 of file CsvControl.h.

161  {
162  return quoteChar.c_str()[0];
163  }
std::string quoteChar
&quot;A one character string containing the character used to quote fields\n&quot; &quot;when quoting is set to e...
Definition: CsvControl.h:97
Quoting lsst::ap::utils::CsvControl::getQuoting ( ) const
inline

Returns the dialects quoting style. Note that if this is equal to QUOTE_NONE, no special handling of quote characters on reading is performed.

Definition at line 146 of file CsvControl.h.

146  {
147  if (quoting == "QUOTE_MINIMAL") {
148  return QUOTE_MINIMAL;
149  } else if (quoting == "QUOTE_ALL") {
150  return QUOTE_ALL;
151  }
152  return QUOTE_NONE;
153  }
Only quote fields when necessary.
Definition: CsvControl.h:52
std::string quoting
&quot;Field quoting style for CSV input/output. Legal values are:\n&quot; &quot;\n&quot; &quot;&#39;QUOTE_MINIMAL&#39;: Only quot...
Definition: CsvControl.h:77
bool lsst::ap::utils::CsvControl::isNullRecognizable ( ) const
inline

Returns true if database NULLs are recognizable in this dialect. This is the case when hasNull is true, or when escapeChar is not '\0' and standardEscapes is true (in which case "\N" is recognized as a NULL).

Definition at line 138 of file CsvControl.h.

138  {
139  return hasNull || standardEscapes;
140  }
bool hasNull
&quot;Indicates whether the null string is valid. If set to false, the only\n&quot; &quot;way NULLs can be recogn...
Definition: CsvControl.h:67
bool standardEscapes
&quot;Flag indicating whether standard escape sequences should be handled.\n&quot; &quot;If false, then the character sequence &#39;\\C&#39;, where C is any character,\n&quot; &quot;is mapped to C (assuming &#39;\\&#39; is the escape character). If true,\n&quot; &quot;the following special cases are handled differently:\n&quot; &quot;\n&quot; &quot;- &#39;\\b&#39; is mapped to BS - backspace (ASCII 8)\n&quot; &quot;- &#39;\\f&#39; is mapped to FF - form feed (ASCII 12)\n&quot; &quot;- &#39;\\n&#39; is mapped to NL - newline (ASCII 10)\n&quot; &quot;- &#39;\\r&#39; is mapped to CR - carriage return (ASCII 13)\n&quot; &quot;- &#39;\\t&#39; is mapped to TAB - horizontal tab (ASCII 9)\n&quot; &quot;- &#39;\\v&#39; is mapped to VT - vertical tab (ASCII 11)\n&quot; &quot;- &#39;\\xD&#39; and &#39;\\xDD&#39;, where D is a hexadecimal digit, is mapped to\n&quot; &quot; the character with that numeric code.\n&quot; &quot;- A field value of exactly &#39;\\N&#39; (no quotes, whitespace, or other\n&quot; &quot; content) is treated as a NULL.\n&quot; ;
Definition: CsvControl.h:123
void lsst::ap::utils::CsvControl::validate ( ) const

Definition at line 57 of file CsvControl.cc.

57  {
58  if (delimiter.size() != 1) {
59  throw LSST_EXCEPT(InvalidParameterError,
60  "delimiter must consist of a single character");
61  }
62  if (delimiter[0] == '\0' || delimiter[0] == '\n' || delimiter[0] == '\r') {
63  throw LSST_EXCEPT(InvalidParameterError,
64  "delimiter equal to '\\[0nr]'");
65 
66  }
67  if (escapeChar.size() > 1) {
68  throw LSST_EXCEPT(InvalidParameterError,
69  "escapeChar string contains more than one character");
70 
71  }
72  if (escapeChar == delimiter ||
73  getEscapeChar() == '\n' || getEscapeChar() == '\r') {
74  throw LSST_EXCEPT(InvalidParameterError,
75  "escapeChar equal to delimiter or '\\[nr]'.");
76  }
77  if (quoteChar.size() > 1) {
78  throw LSST_EXCEPT(InvalidParameterError,
79  "quoteChar string contains more than one character");
80  }
81  if (quoteChar == delimiter ||
82  getQuoteChar() == '\n' || getQuoteChar() == '\r') {
83  throw LSST_EXCEPT(InvalidParameterError,
84  "quoteChar equal to delimiter or '\\[nr]'.");
85  }
86  if (escapeChar == quoteChar && getEscapeChar() != '\0') {
87  throw LSST_EXCEPT(InvalidParameterError,
88  "escapeChar equal to quoteChar. Did you mean to use "
89  "the doubleQuote option instead?");
90  }
91  if (getEscapeChar() == '\0' && standardEscapes) {
92  throw LSST_EXCEPT(InvalidParameterError,
93  "escapeChar set to '\\0', but standardEscapes = true");
94  }
95  if (quoting != "QUOTE_MINIMAL" && quoting != "QUOTE_ALL" &&
96  quoting != "QUOTE_NONE") {
97  throw LSST_EXCEPT(InvalidParameterError,
98  "quoting must be one of 'QUOTE_MINIMAL', 'QUOTE_ALL' "
99  "or 'QUOTE_NONE'");
100  }
101  if (getQuoteChar() == '\0' && quoting != "QUOTE_NONE") {
102  throw LSST_EXCEPT(InvalidParameterError,
103  "quoteChar set to '\\0', but quoting is not "
104  "'QUOTE_NONE'");
105  }
106  if (null.find('\n') != string::npos ||
107  null.find('\r') != string::npos ||
108  null.find(getDelimiter()) != string::npos ||
109  null.find(getEscapeChar()) != string::npos ||
110  null.find(getQuoteChar()) != string::npos) {
111  throw LSST_EXCEPT(InvalidParameterError,
112  "null string contains '\\n', '\\r', delimiter, "
113  "escapeChar, or quoteChar.");
114  }
115 }
char getDelimiter() const
Definition: CsvControl.h:155
char getEscapeChar() const
Definition: CsvControl.h:158
char getQuoteChar() const
Definition: CsvControl.h:161
std::string delimiter
&quot;A one character string containing the field delimiter character.\n&quot; &quot;Values of &#39;\\0&#39;...
Definition: CsvControl.h:81
std::string null
&quot;String representation of NULL field values. Never quoted on output.\n&quot; &quot;If specified, the representation may not contain any delimiter,\n&quot; &quot;quote, escape or line terminator characters (&#39;\\n&#39;/&#39;\\r&#39;).\n&quot; ;
Definition: CsvControl.h:61
std::string escapeChar
&quot;A one character string containing the escape character. An empty\n&quot; &quot;string is mapped to an escap...
Definition: CsvControl.h:88
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::string quoting
&quot;Field quoting style for CSV input/output. Legal values are:\n&quot; &quot;\n&quot; &quot;&#39;QUOTE_MINIMAL&#39;: Only quot...
Definition: CsvControl.h:77
bool standardEscapes
&quot;Flag indicating whether standard escape sequences should be handled.\n&quot; &quot;If false, then the character sequence &#39;\\C&#39;, where C is any character,\n&quot; &quot;is mapped to C (assuming &#39;\\&#39; is the escape character). If true,\n&quot; &quot;the following special cases are handled differently:\n&quot; &quot;\n&quot; &quot;- &#39;\\b&#39; is mapped to BS - backspace (ASCII 8)\n&quot; &quot;- &#39;\\f&#39; is mapped to FF - form feed (ASCII 12)\n&quot; &quot;- &#39;\\n&#39; is mapped to NL - newline (ASCII 10)\n&quot; &quot;- &#39;\\r&#39; is mapped to CR - carriage return (ASCII 13)\n&quot; &quot;- &#39;\\t&#39; is mapped to TAB - horizontal tab (ASCII 9)\n&quot; &quot;- &#39;\\v&#39; is mapped to VT - vertical tab (ASCII 11)\n&quot; &quot;- &#39;\\xD&#39; and &#39;\\xDD&#39;, where D is a hexadecimal digit, is mapped to\n&quot; &quot; the character with that numeric code.\n&quot; &quot;- A field value of exactly &#39;\\N&#39; (no quotes, whitespace, or other\n&quot; &quot; content) is treated as a NULL.\n&quot; ;
Definition: CsvControl.h:123
std::string quoteChar
&quot;A one character string containing the character used to quote fields\n&quot; &quot;when quoting is set to e...
Definition: CsvControl.h:97

Member Data Documentation

std::string lsst::ap::utils::CsvControl::delimiter

"A one character string containing the field delimiter character.\n" "Values of '\\0', '\\n', or '\\r' are illegal.\n" ;

Definition at line 81 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::doubleQuote

"If true, embedded quote characters are escaped with a leading quote\n" "character. Otherwise the escape character is used. If escaping and\n" "double-quoting are disabled, writing a field with embedded quote\n" "character will raise an exception.\n" ;

Definition at line 106 of file CsvControl.h.

std::string lsst::ap::utils::CsvControl::escapeChar

"A one character string containing the escape character. An empty\n" "string is mapped to an escape character of '\\0', which disables\n" "escaping. A value equal to the delimiter or quote character is\n" "illegal, with one exception: both the escape and quote characters\n" "can be '\\0'. The '\\n' and '\\r' characters are also illegal.\n" ;

Definition at line 88 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::hasNull

"Indicates whether the null string is valid. If set to false, the only\n" "way NULLs can be recognized/written is if standardEscapes is set to\n" "true (in which case '\\N' is mapped to NULL, assuming that '\\' is\n" "the escape character).\n" ;

Definition at line 67 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::nonfiniteAsNull

"If true, then non-finite (NaN, Inf, -Inf) floating point values are\n" "written out as NULL field values.\n" ;

Definition at line 131 of file CsvControl.h.

std::string lsst::ap::utils::CsvControl::null

"String representation of NULL field values. Never quoted on output.\n" "If specified, the representation may not contain any delimiter,\n" "quote, escape or line terminator characters ('\\n'/'\\r').\n" ;

Definition at line 61 of file CsvControl.h.

std::string lsst::ap::utils::CsvControl::quoteChar

"A one character string containing the character used to quote fields\n" "when quoting is set to either 'QUOTE_ALL' or 'QUOTE_MINIMAL'. An\n" "empty string is mapped to a quote character of '\\0', which disables\n" "quoting (and is only legal when quoting is set to 'QUOTE_NONE'). A\n" "value equal to the delimiter or quote character is illegal, with one\n" "exception: both the escape and quote characters can be '\\0'. The\n" "'\\n' and '\\r' characters are also illegal.\n" ;

Definition at line 97 of file CsvControl.h.

std::string lsst::ap::utils::CsvControl::quoting

"Field quoting style for CSV input/output. Legal values are:\n" "\n" "'QUOTE_MINIMAL': Only quote fields when necessary - for instance,\n" " when a field value contains a delimiter character.\n" "\n" "'QUOTE_NONE': Never quote fields.\n" "\n" "'QUOTE_ALL': Always quote fields.\n" ;

Definition at line 77 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::skipInitialSpace

"If true, whitespace immediately following the delimiter is ignored." ;

Definition at line 100 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::standardEscapes

"Flag indicating whether standard escape sequences should be handled.\n" "If false, then the character sequence '\\C', where C is any character,\n" "is mapped to C (assuming '\\' is the escape character). If true,\n" "the following special cases are handled differently:\n" "\n" "- '\\b' is mapped to BS - backspace (ASCII 8)\n" "- '\\f' is mapped to FF - form feed (ASCII 12)\n" "- '\\n' is mapped to NL - newline (ASCII 10)\n" "- '\\r' is mapped to CR - carriage return (ASCII 13)\n" "- '\\t' is mapped to TAB - horizontal tab (ASCII 9)\n" "- '\\v' is mapped to VT - vertical tab (ASCII 11)\n" "- '\\xD' and '\\xDD', where D is a hexadecimal digit, is mapped to\n" " the character with that numeric code.\n" "- A field value of exactly '\\N' (no quotes, whitespace, or other\n" " content) is treated as a NULL.\n" ;

Definition at line 123 of file CsvControl.h.

bool lsst::ap::utils::CsvControl::trailingDelimiter

"If true, then a trailing delimiter character is expected and written\n" "at end of every record, immediately preceding the line terminator.\n" ;

Definition at line 127 of file CsvControl.h.


The documentation for this struct was generated from the following files: