MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / toBeQuoted

Method toBeQuoted

src/csvtable.cpp:1161–1175  ·  view source on GitHub ↗

returns true if field has to be quoted

Source from the content-addressed store, hash-verified

1159
1160// returns true if field has to be quoted
1161bool CsvTable::toBeQuoted(std::string field, CsvDefinition definition) {
1162 if( definition.quoteStyle == CsvDefinition::QUOTE_STYLE_ALL ) {
1163 return true;
1164 }
1165 if( definition.quoteStyle == CsvDefinition::QUOTE_STYLE_STRING && !Helper::isNumber(field) && field != "" ) {
1166 return true;
1167 }
1168 for( char& c : field ) {
1169 // Line breaks, Field enclosures (double quotes) and Field separators (comma, semicolon, tab, bar) lead to quotation
1170 if( c == '\n' || c == definition.quote || c == definition.delimiter ) {
1171 return true;
1172 }
1173 }
1174 return false;
1175}
1176
1177
1178//

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected