src/XMLCommand.h
author František Kučera <franta-hg@frantovo.cz>
Thu, 10 Jan 2019 19:50:21 +0100
branchv_0
changeset 0 751260846c40
child 1 9aed8c2ea97d
permissions -rw-r--r--
project skeleton
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
751260846c40 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
751260846c40 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
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
 */
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <cstdlib>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <iostream>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <string>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
#include <vector>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
#include <algorithm>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
#include <relpipe/writer/typedefs.h>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
namespace relpipe {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
namespace in {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
namespace xml {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
class XMLCommand {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
public:
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	void process(std::istream& input, std::ostream& output) {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
		using namespace relpipe::writer;
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
		std::shared_ptr<RelationalWriter> writer(Factory::create(output));
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
		// TODO: remove demo
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
		// Various data types passed as strings
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
		writer->startRelation(L"xml",{
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
			{L"s", TypeId::STRING},
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
			{L"i", TypeId::INTEGER},
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
			{L"b", TypeId::BOOLEAN}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
		}, true);
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
		writer->writeAttribute(L"a");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
		writer->writeAttribute(L"1");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
		writer->writeAttribute(L"true");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
		
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
	}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
};
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
}