src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Tue, 22 Oct 2019 22:03:24 +0200
branchv_0
changeset 26 421608ecc12a
parent 23 6ee7a9e311e9
permissions -rw-r--r--
fix license version: GNU GPLv3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
4062b8436838 CLI parser: first version (only single relation is supported)
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
26
421608ecc12a fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents: 23
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <vector>
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <tuple>
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <relpipe/writer/AttributeMetadata.h>
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
#include <relpipe/writer/typedefs.h>
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace relpipe {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace tr {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
namespace guile {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
class DefinitionRecipe {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
public:
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	virtual ~DefinitionRecipe() {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	}
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	relpipe::writer::string_t name;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	relpipe::writer::string_t type;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	relpipe::writer::string_t value;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
};
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
class RelationConfiguration {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
public:
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	virtual ~RelationConfiguration() {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	}
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
	relpipe::writer::string_t relation;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	relpipe::writer::string_t guileBeforeRecords;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
	relpipe::writer::string_t guileAfterRecords;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	relpipe::writer::string_t guileForEach;
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
	relpipe::writer::string_t guileWhere;
16
2dcc22b7a424 add --has-more-records and allow adding more records dynamically in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    51
	relpipe::writer::string_t guileHasMoreRecords;
23
6ee7a9e311e9 add option: --debug-variable-mapping + different variables for attributes with ambiguous names
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    52
	
6ee7a9e311e9 add option: --debug-variable-mapping + different variables for attributes with ambiguous names
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    53
	/**
6ee7a9e311e9 add option: --debug-variable-mapping + different variables for attributes with ambiguous names
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    54
	 * If true, additional relation will be generated: mapping between relpipe attribute names and Guile variable names
6ee7a9e311e9 add option: --debug-variable-mapping + different variables for attributes with ambiguous names
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    55
	 */
6ee7a9e311e9 add option: --debug-variable-mapping + different variables for attributes with ambiguous names
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    56
	bool debugVariableMapping = false;
15
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    57
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
	/**
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	 * If true, Guile code will be executed, but no output will be generated.
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	 */
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	bool drop = false;
15
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    62
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
	/**
11
9603e64324bc add --define for passing parameters from the outside environment
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    64
	 * Variable definitions for this relation.
9603e64324bc add --define for passing parameters from the outside environment
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    65
	 * Can be used as a safe way for passing parameters from the outside environment.
13
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    66
	 * See also Configuration::definitions (can be overridden by relation's definitions)
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
	 */
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
	std::vector<DefinitionRecipe> definitions;
15
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    69
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
	/**
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
	 * If empty, output relation will have same metadata as the input relation.
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
	 */
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
	std::vector<relpipe::writer::AttributeMetadata> writerMetadata;
15
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    74
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    75
	/**
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    76
	 * Whether original attributes should be appended to those specified using --output-attribute
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    77
	 */
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    78
	bool inputAttributesAppend = false;
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    79
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    80
	/**
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    81
	 * Whether original attributes should be prepended to those specified using --output-attribute
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    82
	 */
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    83
	bool inputAttributesPrepend = false;
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
};
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
class Configuration {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
public:
15
051e58022783 add --input-attributes-append and --input-attributes-prepend for adding attributes using --output-attribute instead of replacing whole attribute list
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    88
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    89
	vector<RelationConfiguration> relationConfigurations;
13
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    90
	/**
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    91
	 * Global definitions for all relations.
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    92
	 * Can be used as a safe way for passing parameters from the outside environment.
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    93
	 * See also RelationConfiguration::definitions
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    94
	 */
c9fece435aa2 add --define for global variables (can be overridden by relation's ones)
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    95
	std::vector<DefinitionRecipe> definitions;
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
11
9603e64324bc add --define for passing parameters from the outside environment
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    97
	// TODO: --create t2 3 a integer b boolean '…guile…' – allow creating new relations? Or allow calling startRelation() and attribute() from Guile?
16
2dcc22b7a424 add --has-more-records and allow adding more records dynamically in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    98
	// TODO: --has-more-relations '…guile…' – called after all relations … ?
2dcc22b7a424 add --has-more-records and allow adding more records dynamically in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    99
	// TODO: --dynamic-output-attributes '…guile…' – used instead or together with --output-attribute
11
9603e64324bc add --define for passing parameters from the outside environment
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
   100
6
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   101
	virtual ~Configuration() {
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   102
	}
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   103
};
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   104
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   105
}
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   106
}
4062b8436838 CLI parser: first version (only single relation is supported)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
}