author | František Kučera <franta-hg@frantovo.cz> |
Sat, 24 Apr 2021 20:03:39 +0200 | |
branch | v_0 |
changeset 86 | 3caa19520689 |
child 87 | d846da24dd35 |
permissions | -rw-r--r-- |
86
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
3caa19520689
streamlet examples: QR: first version
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 |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
#include <unistd.h> |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <Magick++.h> |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#include <zbar.h> |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <relpipe/xmlwriter/XMLWriter.h> |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
#include "streamlet-common.h" |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
/** |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
* This streamlet extracts QR codes from image files. |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
* |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
* It provides two attributes: |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
* - qr: first QR code found (if any) |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
* - qr_xml: XML containing all QR cpdes found an additional metadata |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
* |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
*/ |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
class QRStreamlet : public Streamlet { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
private: |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
const wstring XMLNS = L"tag:globalcode.info,2018:qr:FIXME:final-xmlns"; // FIXME: correct xmlns URI |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
class Symbol { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
public: |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
int id; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
std::wstring value; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
std::wstring type; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
int x; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
int y; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
int width; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
int height; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
}; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
std::vector<Symbol> findSymbols(std::wstring fileName) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
std::vector<Symbol> result; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
Magick::Image magick(toBytes(fileName)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
int width = magick.columns(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
int height = magick.rows(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
Magick::Blob blob; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
magick.modifyImage(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
magick.write(&blob, "GRAY", 8); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
const void *raw = blob.data(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
zbar::Image image(width, height, "Y800", raw, width * height); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
zbar::ImageScanner scanner; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
scanner.scan(image); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
int id = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol, id++) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
Symbol s; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
s.id = id; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
s.type = fromBytes(symbol->get_type_name()); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
s.value = fromBytes(symbol->get_data()); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
int minX = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
int minY = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
int maxX = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
int maxY = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
// TODO: return original polygon in XML |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
for (int i = 0, locationSize = symbol->get_location_size(); i < locationSize; i++) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
int x = symbol->get_location_x(i); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
int y = symbol->get_location_y(i); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
minX = minX ? std::min(minX, x) : x; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
minY = minY ? std::min(minY, y) : y; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
maxX = std::max(maxX, x); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
maxY = std::max(maxY, y); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
91 |
s.x = minX; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
s.y = minY; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
s.width = maxX - minX; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
s.height = maxY - minY; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
result.push_back(s); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
100 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
101 |
return result; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
protected: |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
std::vector<AttributeMetadata> getOutputAttributesMetadata() override { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
std::vector<AttributeMetadata> oam; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
108 |
int i = 0; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
oam.push_back({getAlias(i++, L"qr"), STRING}); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
oam.push_back({getAlias(i++, L"qr_xml"), STRING}); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
111 |
return oam; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
112 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
std::vector<OutputAttribute> getOutputAttributes() override { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
bool validInput = false; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
bool hasSymbols = false; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
std::wstring first; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
std::stringstream xml; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
std::vector<Symbol> symbols; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
121 |
try { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
122 |
symbols = findSymbols(getCurrentFile()); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
123 |
validInput = true; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
124 |
} catch (...) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
125 |
// just ignore the errors; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
126 |
// the file is probably not an image or we do not have read permissions |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
validInput = false; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
129 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
130 |
for (Symbol s : symbols) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
131 |
// TODO: match against pattern (if any) |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
132 |
first = s.value; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
133 |
hasSymbols = true; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
134 |
break; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
135 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
136 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
137 |
relpipe::xmlwriter::XMLWriter xmlWriter(xml); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
xmlWriter.writeStartElement(L"qr",{L"xmlns", XMLNS}); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
140 |
// TODO: common metadata |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
141 |
// xmlWriter.writeStartElement(L"source"); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
142 |
// xmlWriter.writeTextElement(L"height",{}, std::to_wstring(...)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
143 |
// xmlWriter.writeTextElement(L"width",{}, std::to_wstring(...)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
144 |
// xmlWriter.writeEndElement(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
145 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
146 |
for (Symbol s : symbols) { |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
147 |
xmlWriter.writeStartElement(L"symbol"); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
148 |
xmlWriter.writeTextElement(L"value",{}, s.value); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
149 |
xmlWriter.writeTextElement(L"x",{}, std::to_wstring(s.x)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
150 |
xmlWriter.writeTextElement(L"y",{}, std::to_wstring(s.y)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
151 |
xmlWriter.writeTextElement(L"height",{}, std::to_wstring(s.height)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
152 |
xmlWriter.writeTextElement(L"width",{}, std::to_wstring(s.width)); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
153 |
// TODO: polygon |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
154 |
xmlWriter.writeEndElement(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
155 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
156 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
157 |
xmlWriter.writeEndElement(); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
158 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
159 |
std::vector<OutputAttribute> oa; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
160 |
// TODO: report also validInput (distinguish it from hasSymbols) |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
161 |
oa.push_back({first, !hasSymbols}); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
162 |
oa.push_back({fromBytes(xml.str()), false}); |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
163 |
return oa; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
164 |
} |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
165 |
}; |
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
166 |
|
3caa19520689
streamlet examples: QR: first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
167 |
STREAMLET_RUN(QRStreamlet) |