Structured line iterator for abstract data allowing efficient "pipelined" processing.
More...
#include <FixedLengthAbstractIterator.qc.dox.h>
|
bool | checkTransition (*string from, *string to) |
| A verification function to be called for each line. This method can be overridden to achieve a begin-to-end validation of the whole input file. More...
|
|
| constructor (AbstractLineIterator li, hash< auto > spec, *hash< auto > opts) |
| Instantiates the FixedLengthAbstractIterator object. More...
|
|
*hash< auto > | getValue () |
| Returns the current record as a hash. More...
|
|
bool | identifyRecord (list< auto > rec_rule, string input_line) |
| Attempts to identify a single record.
|
|
string | identifyType (string input_line) |
| Identify a fixed-length line type using identifyTypeImpl(), that may be overridden if necessary. More...
|
|
*string | identifyTypeImpl (string input_line) |
| Identify a fixed-length line type, given the raw line string. This method performs a lookup to a precalculated table based on line lengths (see constructor()). In case different criteria are needed, eg. when two line types in a spec have the same length and no unique resolving rule are specified, this method needs to be overridden, and will throw an exception, because the precalculated mapping will be empty. More...
|
|
bool | next () |
| Moves the current line / record position to the next line / record; returns False if there are no more lines to iterate. More...
|
|
auto | transform (auto value, hash< auto > type) |
| parses the input value based on global configuration and the current field definition
|
|
| constructor (hash< auto > m_specs, *hash< auto > m_opts) |
| Creates the object from the record specifications.
|
|
*hash< string, AbstractDataField > | getRecordType () |
| Returns the description of the record type, if any.
|
|
|
static *hash< auto > | checkOptions (*hash< auto > opts) |
| Validate and prepare global fixed-length options. More...
|
|
|
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
|
|
const | GlobalOptionMap |
| Translates from global options to data provider options.
|
|
*hash< auto > | m_opts |
| Global input or output options.
|
|
hash< auto > | m_specs |
| The record specifications.
|
|
Structured line iterator for abstract data allowing efficient "pipelined" processing.
◆ checkOptions()
static *hash< auto > FixedLengthUtil::FixedLengthAbstractIterator::checkOptions |
( |
*hash< auto > |
opts | ) |
|
|
staticprivate |
Validate and prepare global fixed-length options.
- Parameters
-
opts | Options passed during class instantiation. |
◆ checkTransition()
bool FixedLengthUtil::FixedLengthAbstractIterator::checkTransition |
( |
*string |
from, |
|
|
*string |
to |
|
) |
| |
A verification function to be called for each line. This method can be overridden to achieve a begin-to-end validation of the whole input file.
- Parameters
-
from | Type of previous line being processed |
to | Type of the current line being processed |
◆ constructor()
FixedLengthUtil::FixedLengthAbstractIterator::constructor |
( |
AbstractLineIterator |
li, |
|
|
hash< auto > |
spec, |
|
|
*hash< auto > |
opts |
|
) |
| |
Instantiates the FixedLengthAbstractIterator object.
- Parameters
-
li | source line iterator |
spec | Fixed-length line specification; see Specification Hash for more information |
opts | Global options; see Global Options for more information |
- Exceptions
-
FIXED-LENGTH-UTIL-INVALID-SPEC | invalid record specification; invalid type or missing field length |
◆ getValue()
*hash< auto > FixedLengthUtil::FixedLengthAbstractIterator::getValue |
( |
| ) |
|
|
virtual |
Returns the current record as a hash.
- Example:
my hash $h = $i.getValue();
- Returns
- The current record as a hash with the following keys:
"type"
: a string giving the record type name
"record"
: a hash giving the parsed record data
Implements Qore::AbstractIterator.
◆ identifyType()
string FixedLengthUtil::FixedLengthAbstractIterator::identifyType |
( |
string |
input_line | ) |
|
Identify a fixed-length line type using identifyTypeImpl(), that may be overridden if necessary.
- Parameters
-
input_line | Input line to be identified |
- Returns
- the name of the record corresponding to the input line
- Exceptions
-
FIXED-LENGTH-UTIL-NON-MATCHING-TYPE | input line cannot be matched to a known record |
◆ identifyTypeImpl()
*string FixedLengthUtil::FixedLengthAbstractIterator::identifyTypeImpl |
( |
string |
input_line | ) |
|
Identify a fixed-length line type, given the raw line string. This method performs a lookup to a precalculated table based on line lengths (see constructor()). In case different criteria are needed, eg. when two line types in a spec have the same length and no unique resolving rule are specified, this method needs to be overridden, and will throw an exception, because the precalculated mapping will be empty.
- Parameters
-
input_line | Input line to be identified |
- Returns
- the record name or NOTHING if the input cannot be matched
- Exceptions
-
FIXED-LENGTH-UTIL-NON-MATCHING-TYPE | input line cannot be matched to a known record or the input line's length does not match the expected length |
◆ next()
bool FixedLengthUtil::FixedLengthAbstractIterator::next |
( |
| ) |
|
|
virtual |
Moves the current line / record position to the next line / record; returns False if there are no more lines to iterate.
This method will return True again after it returns False once if the file being iterated has data that can be iterated, otherwise it will always return False. The iterator object should not be used to retrieve a value after this method returns False.
- Returns
- False if there are no lines / records to iterate (in which case the iterator object is invalid and should not be used); True if successful (meaning that the iterator object is valid)
- Note
- that empty lines are ignored if "ignore_empty" option is in effect
Implements Qore::AbstractIterator.