src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Tue, 22 Sep 2020 21:00:30 +0200
branchv_0
changeset 43 3c8ea5dcf793
child 44 dd7094457e44
permissions -rw-r--r--
change CLI interface: options: --relation --attribute --record --records --records-from-stdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
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
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <vector>
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <iostream>
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <relpipe/writer/typedefs.h>
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace relpipe {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace in {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
namespace cli {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
class AttributeRecipe {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
public:
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	virtual ~AttributeRecipe() {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	}
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	relpipe::writer::string_t name;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	relpipe::writer::TypeId type;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
};
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
class RelationConfiguration {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
public:
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	virtual ~RelationConfiguration() {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	}
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
	relpipe::writer::string_t relation;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	std::vector<AttributeRecipe> attributes;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
	std::vector<relpipe::writer::string_t> values;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	std::istream* valueStream = nullptr;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
};
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
class Configuration {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
public:
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
	std::vector<RelationConfiguration> relationConfigurations;
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	virtual ~Configuration() {
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	}
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
};
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
}
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
}
3c8ea5dcf793 change CLI interface: options: --relation --attribute --record --records --records-from-stdin
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
}