Loading...
Searching...
No Matches
CsvHelper.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// Qore CsvHelper class definition
/* CsvHelper.qm Copyright 2012 - 2024 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// assume local var scope, do not use "$" for vars, members, and method calls
class CsvHelper {
public:
protected:
const C_OPT1 = 0x1;
const C_OPT2 = 0x2;
const Types = ...;
const FieldAttrs = ("type", "format", "timezone", "code", "header");
bool tolwr = False;
string date_format;
string number_format;
hash m_specs;
string errname;
// reorder data according headers set by options.headers or read from CsvHeader
bool headerReorder = True;
public:
constructor (string n_errname);
*hash<string, AbstractDataField> getRecordType();
protected:
bool isMultiType();
public:
protected:
checkType(string fld_errs, string key, string value);
public:
// get spec from options.fields for old Csv. Check spec param for new Csv
protected:
hash getSpec(*hash fields, string fld_errs, int C_OPTx);
public:
protected:
hash getSpec1(*hash fields);
public:
protected:
hash getSpec2(hash spec);
public:
protected:
list<string> adjustFieldsFromHeaders(string type, *list<auto> headers, bool check = False);
public:
}; // class CsvHelper