EVL

Table of Contents


Products, services and company names referenced in this document may be either trademarks or registered trademarks of their respective owners.

Copyright © 2017–2020 EVL Tool, s.r.o.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.

Lookup tables

Declaration and load

static table some_dimension("dim.csv", "dim.evd", "id", table::text_read);

where the third parameter is the comma separated list of key fields, i.e. the field(s) according to which it will look up.

Important: File has to be sorted according to key field!

Important:static’ is compulsory if you don’t want to load lookup before processing each record.

The forth parameter is not mandatory and it may contain these flags:

table::binary_read

the file is binary, default flag.

table::text_read

the file is a text.

table::unique_key

without this flag, it suppose there might be several keys and it will try to look for the first one. As it slows down looking up the data, if you know the lookup key is unique, use this flag.

table::ignore_case

ignore case for strings.

More complex example:

static table some_lookup("input.csv", "input.evd", "key1, key2",
                  table::text_read | table::unique_key);

Methods

These methods looking up data in defined and loaded ‘table’:

lookup_char
lookup_uchar
lookup_short
lookup_ushort
lookup_int
lookup_uint
lookup_long
lookup_ulong
lookup_float
lookup_double
lookup_decimal
lookup_date
lookup_timestamp
lookup_string

They are distinguished according to return value data type. They return the pointer to the value. For example ‘lookup_char’ returns pointer to ‘std::int8_t’ etc.

Methods return ‘nullptr’ if there is no record found in the lookup table.

All methods have two or more parameters: first one is the name of the field to be returned and other parameters are values of the key fields defined by ‘table’.

Example: Let’s have lookup (sorted) file lookup_file.csv:

1|2017-06-04|value1
1|2017-06-05|value2
2|2017-06-05|value3

with lookup_file.evd:

key1   int    sep="|"
key2   date   sep="|"
field3 string sep="\n"

Then in mapping (evm file):

static table lookup_file("lookup_file.csv", "lookup_file.evd", "key1, key2",
                  table::text_read | table::unique_key);

string* s = lookup_file.lookup_string("field3", 1, date("2017-06-05"));
// -> value2