$darkmode

| Qore FixedLengthUtil Module Reference 1.5

FixedLengthWriteDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
2// Qore FixedLengthWriteDataProvider class definition
3
4/* FixedLengthWriteDataProvider.qc Copyright 2012 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// assume local var scope, do not use "$" for vars, members, and method calls
26
28 namespace FixedLengthUtil {
30 class FixedLengthWriteDataProvider : public DataProvider::AbstractDataProvider {
31
32 public:
34 const ProviderInfo = <DataProviderInfo>{
35 "type": "FixedLengthWriteDataProvider",
36 "supports_create": True,
37 "has_record": True,
38 "constructor_options": ConstructorOptions,
39 };
40
42 const ConstructorOptions = {
43 "path": <DataProviderOptionInfo>{
44 "type": AbstractDataProviderType::get(StringType),
45 "desc": "the path to the fixed-length data; mutually exclusive with \"stream\"; the output location "
46 "is handled by a call to FileLocationHandler::getOutputStreamForLocation()",
47 },
48 "stream": <DataProviderOptionInfo>{
49 "type": AbstractDataProviderType::get(new Type("OutputStream")),
50 "desc": "an output stream for fixed-length data; mutually exclusive with \"path\"",
51 },
52 "spec": <DataProviderOptionInfo>{
53 "type": AbstractDataProviderType::get(AutoHashType),
54 "desc": "the fixed-length record specification hash",
55 "required": True,
56 },
57 "date_format": <DataProviderOptionInfo>{
58 "type": AbstractDataProviderType::get(StringType),
59 "desc": "the default global date format for `date` fields",
60 },
61 "encoding": <DataProviderOptionInfo>{
62 "type": AbstractDataProviderType::get(StringType),
63 "desc": "the encoding for strings",
64 },
65 "eol": <DataProviderOptionInfo>{
66 "type": AbstractDataProviderType::get(StringType),
67 "desc": "the end of line characters",
68 },
69 "file_flags": <DataProviderOptionInfo>{
70 "type": AbstractDataProviderType::get(SoftIntType),
71 "desc": "additional writer file open flags; `O_WRONLY | O_CREAT` is used by default; use `O_EXCL` to "
72 "ensure not to overwrite the target or `O_TRUNC` to replace any existing file or `O_APPEND` to "
73 "append to an existing file",
74 },
75 "ignore_empty": <DataProviderOptionInfo>{
76 "type": AbstractDataProviderType::get(SoftBoolType),
77 "desc": "if `true` then empty lines are ignored",
78 },
79 "number_format": <DataProviderOptionInfo>{
80 "type": AbstractDataProviderType::get(StringType),
81 "desc": "the default global number format for `float` or `number` fields",
82 },
83 "timezone": <DataProviderOptionInfo>{
84 "type": AbstractDataProviderType::get(StringType),
85 "desc": "a string giving a time zone region name or an integer offset in seconds east of UTC",
86 },
87 "truncate": <DataProviderOptionInfo>{
88 "type": AbstractDataProviderType::get(SoftBoolType),
89 "desc": "controls whether to truncate an output field value if its bigger than its specified "
90 "`length`; the default is `false`",
91 },
92 "tab2space": <DataProviderOptionInfo>{
93 "type": AbstractDataProviderType::get(SoftIntType),
94 "desc": "Controls whether to replace tabs with spaces and its value determines how many spaces to "
95 "output in place of one tab character",
96 },
97 };
98
100 const FixedLengthWriteOptionList = keys (ConstructorOptions - ("path", "stream", "spec"));
101
102 protected:
104 FixedLengthAbstractWriter writer;
105
106 public:
107
109
115 constructor(string path, hash<auto> specs, *hash<auto> opts);
116
117
119
125 constructor(OutputStream stream, hash<auto> specs, *hash<auto> opts);
126
127
129 string getName();
130
131
133 constructor(*hash<auto> options);
134
135
137 protected:
138 *hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
139 public:
140
141
143
148 protected:
149 *hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
150 public:
151
152
154 protected:
155 hash<DataProviderInfo> getStaticInfoImpl();
156 public:
157
158};
159}; // 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
True
const True
FixedLengthUtil
The FixedLengthUtil namespace contains all the definitions in the FixedLengthUtil module.
Definition: FixedLengthAbstractIterator.qc.dox.h:27