author | František Kučera <franta-hg@frantovo.cz> |
Fri, 07 Dec 2018 12:49:39 +0100 | |
branch | v_0 |
changeset 0 | 2f3c9e508827 |
child 2 | 3e73d4ae8b49 |
permissions | -rw-r--r-- |
0
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info) |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
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 |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
#pragma once |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <string> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#include <vector> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
#include <iostream> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <sstream> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <locale> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
#include <codecvt> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
#include <regex> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
#include <relpipe/reader/typedefs.h> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
#include <relpipe/reader/TypeId.h> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
#include <relpipe/reader/handlers/RelationalReaderStringHandler.h> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
#include <relpipe/reader/handlers/AttributeMetadata.h> |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
namespace relpipe { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
namespace out { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
namespace ods { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
using namespace relpipe::reader; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
class OdsHandler : public handlers::RelationalReaderStringHadler { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
private: |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // XML output will be always in UTF-8 |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
const char* INDENT = "\t"; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
std::ostream &output; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
std::vector<TypeId> columnTypes; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
std::vector<string_t> columnTypeCodes; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
std::vector<string_t> columnNames; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
integer_t valueCount = 0; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
integer_t columnCount = 0; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
integer_t relationCount = 0; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
const std::string escapeXmlText(const string_t &value) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
std::wstringstream result; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
for (auto & ch : value) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
switch (ch) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
case L'&': result << L"&"; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
break; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
case L'<': result << L"<"; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
break; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
case L'>': result << L">"; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
break; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
case L'\'': result << L"'"; // TODO: escape ' and " only in attributes |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
break; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
case L'"': result << L"""; // TODO: escape ' and " only in attributes |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
break; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
default: result << ch; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
return convertor.to_bytes(result.str()); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
public: |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
OdsHandler(std::ostream& output) : output(output) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
void startRelation(string_t name, std::vector<handlers::AttributeMetadata> attributes) override { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
// TODO: refactor and move common XML functions to relpipe-lib-xml |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
valueCount = 0; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
columnCount = 0; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
if (relationCount == 0) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
output << "<pipe TODO=\"ods\">" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
// TODO: xmlns |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
} else { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
91 |
output << INDENT << INDENT << "</record>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
output << INDENT << "</relation>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
relationCount++; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
output << INDENT << "<relation>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
output << INDENT << INDENT << "<name>" << escapeXmlText(name) << "</name>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
100 |
columnCount = attributes.size(); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
101 |
columnTypes.resize(columnCount); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
columnTypeCodes.resize(columnCount); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
columnNames.resize(columnCount); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
for (int i = 0; i < attributes.size(); i++) { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
columnNames[i] = attributes[i].getAttributeName(); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
columnTypes[i] = attributes[i].getTypeId(); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
columnTypeCodes[i] = attributes[i].getTypeName(); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
108 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
// TODO: print attribute metadata |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
111 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
112 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
void attribute(const string_t& value) override { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
integer_t i = valueCount % columnCount; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
if (i == 0 && valueCount) output << INDENT << INDENT << "</record>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
if (i == 0) output << INDENT << INDENT << "<record>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
valueCount++; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
121 |
// TODO: print attribute metadata (optional) |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
122 |
output << INDENT << INDENT << INDENT << "<attribute>"; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
123 |
output << escapeXmlText(value); |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
124 |
output << "</attribute>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
125 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
126 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
void endOfPipe() { |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
129 |
if (valueCount) output << INDENT << INDENT << "</record>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
130 |
if (relationCount) output << INDENT << "</relation>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
131 |
output << "</pipe>" << std::endl; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
132 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
133 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
134 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
135 |
}; |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
136 |
|
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
137 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
} |
2f3c9e508827
project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
} |