Loading...
Searching...
No Matches
FixedLengthWriteDataProvider.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// Qore FixedLengthWriteDataProvider class definition
/* FixedLengthWriteDataProvider.qc Copyright 2012 - 2022 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
namespace FixedLengthUtil {
class FixedLengthWriteDataProvider : public DataProvider::AbstractDataProvider {
public:
const ProviderInfo = <DataProviderInfo>{
"type": "FixedLengthWriteDataProvider",
"supports_create": True,
"has_record": True,
"constructor_options": ConstructorOptions,
};
const ConstructorOptions = {
"path": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "the path to the fixed-length data; mutually exclusive with \"stream\"; the output location "
"is handled by a call to FileLocationHandler::getOutputStreamForLocation()",
},
"stream": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(new Type("OutputStream")),
"desc": "an output stream for fixed-length data; mutually exclusive with \"path\"",
},
"spec": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(AutoHashType),
"desc": "the fixed-length record specification hash",
"required": True,
},
"date_format": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "the default global date format for `date` fields",
},
"encoding": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "the encoding for strings",
},
"eol": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "the end of line characters",
},
"file_flags": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(SoftIntType),
"desc": "additional writer file open flags; `O_WRONLY | O_CREAT` is used by default; use `O_EXCL` to "
"ensure not to overwrite the target or `O_TRUNC` to replace any existing file or `O_APPEND` to "
"append to an existing file",
},
"ignore_empty": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(SoftBoolType),
"desc": "if `true` then empty lines are ignored",
},
"number_format": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "the default global number format for `float` or `number` fields",
},
"timezone": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "a string giving a time zone region name or an integer offset in seconds east of UTC",
},
"truncate": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(SoftBoolType),
"desc": "controls whether to truncate an output field value if its bigger than its specified "
"`length`; the default is `false`",
},
"tab2space": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(SoftIntType),
"desc": "Controls whether to replace tabs with spaces and its value determines how many spaces to "
"output in place of one tab character",
},
};
const FixedLengthWriteOptionList = keys (ConstructorOptions - ("path", "stream", "spec"));
protected:
FixedLengthAbstractWriter writer;
public:
constructor(string path, hash<auto> specs, *hash<auto> opts);
constructor(OutputStream stream, hash<auto> specs, *hash<auto> opts);
string getName();
constructor(*hash<auto> options);
protected:
*hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
public:
protected:
*hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
public:
protected:
hash<DataProviderInfo> getStaticInfoImpl();
public:
};
}; // FixedLengthUtil namespace
FixedLengthUtil::FixedLengthAbstractWriter
Structured abstract writer for fixed-length lines.
Definition: FixedLengthAbstractWriter.qc.dox.h:29
FixedLengthUtil::FixedLengthWriteDataProvider
Provides a data provider for reading fixed-length files.
Definition: FixedLengthWriteDataProvider.qc.dox.h:30
FixedLengthUtil::FixedLengthWriteDataProvider::FixedLengthWriteOptionList
const FixedLengthWriteOptionList
write option list
Definition: FixedLengthWriteDataProvider.qc.dox.h:100
FixedLengthUtil::FixedLengthWriteDataProvider::constructor
constructor(*hash< auto > options)
Creates the object from constructor options.
FixedLengthUtil::FixedLengthWriteDataProvider::ProviderInfo
const ProviderInfo
Provider info.
Definition: FixedLengthWriteDataProvider.qc.dox.h:34
FixedLengthUtil::FixedLengthWriteDataProvider::constructor
constructor(OutputStream stream, hash< auto > specs, *hash< auto > opts)
Creates the FixedLengthWriteDataProvider with the output data stream where data will be writeen and a...
FixedLengthUtil::FixedLengthWriteDataProvider::constructor
constructor(string path, hash< auto > specs, *hash< auto > opts)
Creates the FixedLengthWriteDataProvider with the output path and optionally an option hash.
FixedLengthUtil::FixedLengthWriteDataProvider::getName
string getName()
Returns the object name.
FixedLengthUtil::FixedLengthWriteDataProvider::ConstructorOptions
const ConstructorOptions
Constructor options.
Definition: FixedLengthWriteDataProvider.qc.dox.h:42
FixedLengthUtil::FixedLengthWriteDataProvider::createRecordImpl
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Creates the given record to the data provider.
FixedLengthUtil::FixedLengthWriteDataProvider::getStaticInfoImpl
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
FixedLengthUtil::FixedLengthWriteDataProvider::getRecordTypeImpl
*hash< string, AbstractDataField > getRecordTypeImpl(*hash< auto > search_options)
Returns the description of the record type, if any.
FixedLengthUtil::FixedLengthWriteDataProvider::writer
FixedLengthAbstractWriter writer
the writer object
Definition: FixedLengthWriteDataProvider.qc.dox.h:104
FixedLengthUtil
The FixedLengthUtil namespace contains all the definitions in the FixedLengthUtil module.
Definition: FixedLengthAbstractIterator.qc.dox.h:27