src/XMLCommand.h
author František Kučera <franta-hg@frantovo.cz>
Thu, 10 Jan 2019 20:05:13 +0100
branchv_0
changeset 1 9aed8c2ea97d
parent 0 751260846c40
child 2 3ab78bf63467
permissions -rw-r--r--
add Xerces-C++ dependency
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
1
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    26
#include <xercesc/sax2/SAX2XMLReader.hpp>
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    27
#include <xercesc/sax2/XMLReaderFactory.hpp>
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    28
#include <xercesc/sax2/DefaultHandler.hpp>
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    29
#include <xercesc/util/XMLString.hpp>
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    30
0
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
#include <relpipe/writer/typedefs.h>
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
namespace relpipe {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
namespace in {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
namespace xml {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
class XMLCommand {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
public:
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	void process(std::istream& input, std::ostream& output) {
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
		using namespace relpipe::writer;
1
9aed8c2ea97d add Xerces-C++ dependency
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
		using namespace xercesc;
0
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
		std::shared_ptr<RelationalWriter> writer(Factory::create(output));
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
		// TODO: remove demo
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		// Various data types passed as strings
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
		writer->startRelation(L"xml",{
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
			{L"s", TypeId::STRING},
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
			{L"i", TypeId::INTEGER},
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
			{L"b", TypeId::BOOLEAN}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
		}, true);
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
		writer->writeAttribute(L"a");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
		writer->writeAttribute(L"1");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
		writer->writeAttribute(L"true");
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
		
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
};
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
}
751260846c40 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
}