src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 27 Nov 2021 23:15:18 +0100
branchv_0
changeset 45 b6f2740617e4
parent 35 eafffeea6a3e
permissions -rw-r--r--
exception: fix typo: getMessge() → getMessage()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
35
eafffeea6a3e fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
0
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <relpipe/writer/AttributeMetadata.h>
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <relpipe/writer/typedefs.h>
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
namespace relpipe {
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
namespace tr {
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
namespace awk {
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
8
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    26
class DefinitionRecipe {
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    27
public:
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    28
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    29
	virtual ~DefinitionRecipe() {
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    30
	}
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    31
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    32
	relpipe::writer::string_t name;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    33
	relpipe::writer::string_t type;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    34
	relpipe::writer::string_t value;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    35
};
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    36
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    37
class RelationConfiguration {
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    38
public:
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    39
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    40
	virtual ~RelationConfiguration() {
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    41
	}
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    43
	relpipe::writer::string_t relation;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    44
	relpipe::writer::string_t awkBeforeRecords;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    45
	relpipe::writer::string_t awkAfterRecords;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    46
	relpipe::writer::string_t awkForEach;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    47
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    48
	/**
26
cf57e8c78492 add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    49
	 * If true, additional relation will be generated: mapping between relpipe attribute names and AWK variable names
cf57e8c78492 add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    50
	 */
cf57e8c78492 add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    51
	bool debugVariableMapping = false;
cf57e8c78492 add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    52
cf57e8c78492 add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    53
	/**
19
e4558df9ba2d drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    54
	 * If true, AWK code will be executed, but no output will be generated.
e4558df9ba2d drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    55
	 */
e4558df9ba2d drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    56
	bool drop = false;
e4558df9ba2d drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    57
e4558df9ba2d drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    58
	/**
8
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    59
	 * Variable definitions for this relation.
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    60
	 * Can be used as a safe way for passing parameters from the outside environment.
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    61
	 * See also Configuration::definitions (can be overridden by relation's definitions)
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    62
	 */
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    63
	std::vector<DefinitionRecipe> definitions;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    64
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    65
	/**
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    66
	 * If empty, output relation will have same metadata as the input relation.
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    67
	 */
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    68
	std::vector<relpipe::writer::AttributeMetadata> writerMetadata;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    69
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    70
	/**
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    71
	 * Whether original attributes should be appended to those specified using --output-attribute
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    72
	 */
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    73
	bool inputAttributesAppend = false;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    74
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    75
	/**
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    76
	 * Whether original attributes should be prepended to those specified using --output-attribute
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    77
	 */
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    78
	bool inputAttributesPrepend = false;
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    79
};
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    80
0
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
class Configuration {
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
public:
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
33
5288af2e4921 namespace, formatting
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    84
	std::vector<RelationConfiguration> relationConfigurations;
8
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    85
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    86
	/**
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    87
	 * Global definitions for all relations.
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    88
	 * Can be used as a safe way for passing parameters from the outside environment.
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    89
	 * See also RelationConfiguration::definitions
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    90
	 */
513ea30d2fa3 more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    91
	std::vector<DefinitionRecipe> definitions;
0
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
	virtual ~Configuration() {
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
	}
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    95
};
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    97
}
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    98
}
644fd2ce2580 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    99
}