src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Tue, 13 Dec 2022 02:07:00 +0100
branchv_0
changeset 3 202ce847990c
parent 2 8a30971d285f
permissions -rw-r--r--
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast

/**
 * Relational pipes
 * Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

#include <vector>
#include <iostream>
#include <regex>

#include <relpipe/common/type/typedefs.h>
#include <relpipe/reader/typedefs.h>


namespace relpipe {
namespace out {
namespace sql {

class Configuration {
public:

	enum class InsertMode {
		DEFAULT,
		SINGLE,
		MULTI,
	};

	class TypeCastRule {
	public:

		std::wregex attribute = std::wregex(L".*");
		std::wregex type = std::wregex(L".*");
		relpipe::common::type::StringX sqlType;
	};

	class RelationConfiguration {
	public:
		relpipe::common::type::StringX relation;
		std::wregex relationPattern;
		relpipe::common::type::Boolean writeDDL = true;
		relpipe::common::type::Boolean writeDML = true;
		relpipe::common::type::Boolean writeColumnNames = true;
		std::vector<TypeCastRule> typeCastRules;
		InsertMode insertMode = InsertMode::DEFAULT;
	};

	std::vector<RelationConfiguration> relationConfigurations;

	virtual ~Configuration() {
	}
};

}
}
}