Qore FixedLengthUtil Module Reference  1.2.1
FixedLengthAbstractIterator.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* FixedLengthAbstractIterator Copyright 2015 - 2019 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 
27 namespace FixedLengthUtil {
30 
31 public:
32 protected:
33  // rules keyed by field length then by record name
34  hash<string, hash<string, list<hash<auto>>>> m_resolve_by_rule;
35  // all rules; keyed by record name
36  hash<string, list<hash<auto>>> m_resolve_by_rule_all;
37  string m_state;
40  AbstractLineIterator lineIterator;
41 
42 public:
43 
45 
52  constructor(AbstractLineIterator li, hash<auto> spec, *hash<auto> opts)
53  ;
54 
55 
56  bool valid();
57 
58 
60 
65  bool next();
66 
67 
68  string getLine();
69 
70 
72 
81  *hash<auto> getValue();
82 
83 
84  int index();
85 
86 
88  auto transform(auto value, hash<auto> type);
89 
90 
92 
95 protected:
96  static *hash<auto> checkOptions(*hash<auto> opts);
97 public:
98 
99 
101 
108  string identifyType(string input_line);
109 
110 
112 
120  *string identifyTypeImpl(string input_line);
121 
122 
124  bool identifyRecord(list<auto> rec_rule, string input_line);
125 
126 
128 
132  bool checkTransition(*string from, *string to);
133 
134 };
135 };
Structured line iterator for abstract data allowing efficient "pipelined" processing.
Definition: FixedLengthAbstractIterator.qc.dox.h:29
Base class for fixed-length readers and writers.
Definition: FixedLengthBase.qc.dox.h:29
auto transform(auto value, hash< auto > type)
parses the input value based on global configuration and the current field definition ...
static *hash< auto > checkOptions(*hash< auto > opts)
Validate and prepare global fixed-length options.
string identifyType(string input_line)
Identify a fixed-length line type using identifyTypeImpl(), that may be overridden if necessary...
bool checkTransition(*string from, *string to)
A verification function to be called for each line. This method can be overridden to achieve a begin-...
*string identifyTypeImpl(string input_line)
Identify a fixed-length line type, given the raw line string. This method performs a lookup to a prec...
bool identifyRecord(list< auto > rec_rule, string input_line)
Attempts to identify a single record.
bool next()
Moves the current line / record position to the next line / record; returns False if there are no mor...
hash m_resolve_by_length
hash of type without rule, i.e.potentially conflicting records; key = record length, value = list of no-rule type names
Definition: FixedLengthAbstractIterator.qc.dox.h:39
*hash< auto > getValue()
Returns the current record as a hash.
The FixedLengthUtil namespace contains all the definitions in the FixedLengthUtil module...
Definition: FixedLengthAbstractIterator.qc.dox.h:27
constructor(AbstractLineIterator li, hash< auto > spec, *hash< auto > opts)
Instantiates the FixedLengthAbstractIterator object.
string type(auto arg)
hash< auto > hash(object obj)