src/YAMLCommand.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 05 Dec 2020 19:32:05 +0100
branchv_0
changeset 4 c176766462c5
parent 3 64f8f8792470
child 5 399380ea9750
permissions -rw-r--r--
simplify FOR cycles
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
     3
 * Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
66a454290286 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
66a454290286 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
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <cstdlib>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <iostream>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <memory>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <vector>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    24
#include <yaml.h>
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    25
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
#include <relpipe/writer/RelationalWriter.h>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
#include <relpipe/writer/typedefs.h>
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
namespace relpipe {
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
namespace in {
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
namespace yaml {
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
class YAMLCommand {
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
private:
2
d68192f0e960 convert YAML to relations
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    35
	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // YAML strings are in UTF-8
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    37
	class YAMLEvent {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    38
	private:
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    39
		yaml_event_t event;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    40
	public:
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    41
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
		YAMLEvent(yaml_event_t event) : event(event) {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    43
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    44
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    45
		virtual ~YAMLEvent() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    46
			yaml_event_delete(&event);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    47
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    48
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    49
		const yaml_event_type_t getType() const {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    50
			return event.type;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    51
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    52
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    53
		const relpipe::writer::string_t getTypeName() const {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    54
			return findTypeName(event.type);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    55
		}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    56
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    57
		/** Just for debugging and error handling */
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    58
		static const relpipe::writer::string_t findTypeName(const yaml_event_type_t eventType) {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    59
			if (eventType == YAML_NO_EVENT) return L"NO";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    60
			else if (eventType == YAML_STREAM_START_EVENT) return L"STREAM_START";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    61
			else if (eventType == YAML_STREAM_END_EVENT) return L"STREAM_END";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    62
			else if (eventType == YAML_DOCUMENT_START_EVENT) return L"DOCUMENT_START";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    63
			else if (eventType == YAML_DOCUMENT_END_EVENT) return L"DOCUMENT_END";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    64
			else if (eventType == YAML_ALIAS_EVENT) return L"ALIAS";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    65
			else if (eventType == YAML_SCALAR_EVENT) return L"SCALAR";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    66
			else if (eventType == YAML_SEQUENCE_START_EVENT) return L"SEQUENCE_START";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    67
			else if (eventType == YAML_SEQUENCE_END_EVENT) return L"SEQUENCE_END";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    68
			else if (eventType == YAML_MAPPING_START_EVENT) return L"MAPPING_START";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    69
			else if (eventType == YAML_MAPPING_END_EVENT) return L"MAPPING_END";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    70
			else return L"UNKNOWN";
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    71
		}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    72
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    73
		const yaml_event_t* getEvent() const {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    74
			return &event;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    75
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    76
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    77
		YAMLEvent(const YAMLEvent&) = delete;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    78
		YAMLEvent& operator=(const YAMLEvent&) = delete;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    79
	};
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    80
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    81
	class YAMLParser {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    82
	private:
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    83
		yaml_parser_t yamlParser;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    84
		std::istream* input = nullptr;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    85
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    86
		static int readFromInput(void* instance, unsigned char* buffer, size_t size, size_t* length) {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    87
			std::istream* input = ((YAMLParser*) instance)->input;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    88
			input->read((char*) buffer, size);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    89
			*length = input->gcount();
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    90
			return (input->good() || input->eof()) ? 1 : 0;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    91
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    92
	public:
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    93
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    94
		YAMLParser() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    95
			yaml_parser_initialize(&yamlParser);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    96
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    97
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    98
		virtual ~YAMLParser() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    99
			yaml_parser_delete(&yamlParser);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   100
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   101
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   102
		YAMLParser(const YAMLParser&) = delete;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   103
		YAMLParser& operator=(const YAMLParser&) = delete;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   104
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   105
		void setInput(std::istream* input) {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   106
			this->input = input;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   107
			yaml_parser_set_input(&yamlParser, readFromInput, (void*) this);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   108
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   109
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   110
		YAMLEvent* next() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   111
			yaml_event_t event;
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   112
			int result = yaml_parser_parse(&yamlParser, &event);
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   113
			return result == 1 && event.type != yaml_event_type_e::YAML_NO_EVENT ? new YAMLEvent(event) : nullptr; // 1 = OK in yaml.h; YAML_NO_EVENT = end
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   114
		}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   115
	};
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   116
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   117
	using YAMLEvent_p = std::shared_ptr<YAMLEvent>;
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   118
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   119
	YAMLParser parser;
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   120
	std::shared_ptr<relpipe::writer::RelationalWriter> writer;
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   121
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   122
	relpipe::writer::string_t relationName;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   123
	std::vector<relpipe::writer::string_t> record;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   124
	std::vector<relpipe::writer::AttributeMetadata> attributesMetadata;
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   125
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   126
	relpipe::writer::string_t y2s(const yaml_char_t* value) {
2
d68192f0e960 convert YAML to relations
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   127
		return value ? convertor.from_bytes((const char*) value) : L"";
d68192f0e960 convert YAML to relations
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   128
	}
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   129
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   130
	relpipe::writer::string_t fetchScalarValue(YAMLEvent_p event) {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   131
		if (event->getType() == YAML_SCALAR_EVENT) return y2s(event->getEvent()->data.scalar.value);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   132
		else throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected SCALAR but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   133
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   134
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   135
	void consumeEvent(const yaml_event_type_t expectedEventType, relpipe::writer::string_t expectedScalarValue = L"") {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   136
		YAMLEvent_p event = YAMLEvent_p(parser.next());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   137
		if (!event) throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: missing event: " + YAMLEvent::findTypeName(expectedEventType));
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   138
		if (event->getType() != expectedEventType) throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected event: " + YAMLEvent::findTypeName(expectedEventType) + L", but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   139
		if (expectedEventType == YAML_SCALAR_EVENT && expectedScalarValue.size() && expectedScalarValue != fetchScalarValue(event)) throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected scalar value: " + expectedScalarValue + L", but got " + fetchScalarValue(event));
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   140
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   141
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   142
	relpipe::writer::string_t consumeScalarEvent() {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   143
		YAMLEvent_p event = YAMLEvent_p(parser.next());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   144
		if (event && event->getType() == YAML_SCALAR_EVENT) return fetchScalarValue(event);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   145
		else throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected SCALAR, but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   146
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   147
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   148
	bool until(const yaml_event_type_t until, YAMLEvent_p& event) {
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   149
		event = YAMLEvent_p(parser.next());
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   150
		return event && event->getType() != until;
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   151
	}
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   152
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   153
	void processRelation() {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   154
		YAMLEvent_p event = YAMLEvent_p(parser.next());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   155
		if (event->getType() == YAML_MAPPING_START_EVENT) processRelationWithMetadata();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   156
		else if (event->getType() == YAML_SEQUENCE_START_EVENT)processRelationWithoutMetadata();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   157
		else throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected MAPPING or SEQUENCE, but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   158
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   159
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   160
	void processRelationWithMetadata() {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   161
		consumeEvent(YAML_SCALAR_EVENT, L"attribute-metadata");
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   162
		consumeEvent(YAML_SEQUENCE_START_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   163
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   164
		for (YAMLEvent_p event; until(YAML_SEQUENCE_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   165
			if (event->getType() != YAML_MAPPING_START_EVENT) throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected MAPPING (attribute-metadata), but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   166
			relpipe::writer::string_t name;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   167
			relpipe::writer::string_t type = L"string";
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   168
			for (YAMLEvent_p event; until(YAML_MAPPING_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   169
				auto key = fetchScalarValue(event);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   170
				auto value = consumeScalarEvent();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   171
				if (key == L"name") name = value;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   172
				else if (key == L"type") type = value;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   173
				else; // unsupported metadata, later there might be something useful
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   174
			}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   175
			attributesMetadata.push_back({name, writer->toTypeId(type)});
2
d68192f0e960 convert YAML to relations
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   176
		}
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   177
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   178
		writer->startRelation(relationName, attributesMetadata, true);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   179
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   180
		YAMLEvent_p event = YAMLEvent_p(parser.next());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   181
		if (event->getType() == YAML_SCALAR_EVENT && fetchScalarValue(event) == L"record") {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   182
			consumeEvent(YAML_SEQUENCE_START_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   183
			processRecords();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   184
			consumeEvent(YAML_MAPPING_END_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   185
		} else if (event->getType() == YAML_MAPPING_END_EVENT) {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   186
			// empty relation, no records
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   187
		} else {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   188
			relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected 'record' or MAPPING_END, but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   189
		}
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   190
	}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   191
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   192
	void processRelationWithoutMetadata() {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   193
		// First record:
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   194
		consumeEvent(YAML_MAPPING_START_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   195
		record.clear();
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   196
		for (YAMLEvent_p event; until(YAML_MAPPING_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   197
			auto name = fetchScalarValue(event);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   198
			auto value = consumeScalarEvent();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   199
			attributesMetadata.push_back({name, relpipe::writer::TypeId::STRING});
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   200
			record.push_back(value);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   201
		}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   202
		writer->startRelation(relationName, attributesMetadata, true);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   203
		for (auto value : record) writer->writeAttribute(value);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   204
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   205
		// Following records:
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   206
		processRecords();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   207
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   208
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   209
	void processRecords() {
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   210
		for (YAMLEvent_p event; until(YAML_SEQUENCE_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   211
			if (event->getType() != YAML_MAPPING_START_EVENT) throw relpipe::writer::RelpipeWriterException(L"Invalid YAML structure: expected MAPPING (record), but got: " + event->getTypeName());
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   212
			record.clear();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   213
			record.resize(attributesMetadata.size());
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   214
			for (YAMLEvent_p event; until(YAML_MAPPING_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   215
				auto name = fetchScalarValue(event);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   216
				auto value = consumeScalarEvent();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   217
				for (int i = 0; i < attributesMetadata.size(); i++) {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   218
					if (name == attributesMetadata[i].attributeName) {
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   219
						record[i] = value;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   220
						break;
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   221
					}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   222
				}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   223
			}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   224
			for (auto value : record) writer->writeAttribute(value);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   225
		}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   226
	}
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   227
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   228
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   229
public:
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   230
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   231
	YAMLCommand() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   232
	}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   233
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   234
	virtual ~YAMLCommand() {
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   235
	}
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   236
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   237
	void process(std::istream& input, std::shared_ptr<relpipe::writer::RelationalWriter> writer) {
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   238
		parser.setInput(&input);
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   239
		this->writer = writer;
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   240
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   241
		consumeEvent(YAML_STREAM_START_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   242
		consumeEvent(YAML_DOCUMENT_START_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   243
		consumeEvent(YAML_MAPPING_START_EVENT);
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   244
4
c176766462c5 simplify FOR cycles
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   245
		for (YAMLEvent_p event; until(YAML_MAPPING_END_EVENT, event);) {
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   246
			relationName = fetchScalarValue(event);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   247
			attributesMetadata.clear();
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   248
			processRelation();
1
8d2d8f4077af OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   249
		}
3
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   250
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   251
		consumeEvent(YAML_DOCUMENT_END_EVENT);
64f8f8792470 support also attribute metadata (i.e. also different attribute types than mere strings) and empty relations (no records)
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   252
		consumeEvent(YAML_STREAM_END_EVENT);
0
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   253
	}
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   254
};
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   255
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   256
}
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   257
}
66a454290286 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   258
}