src/QRCommand.h
author František Kučera <franta-hg@frantovo.cz>
Wed, 14 Apr 2021 19:01:54 +0200
branchv_0
changeset 0 0a0cb749c10f
child 1 79d699ed88ab
permissions -rw-r--r--
projekt skeleton
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info)
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
0a0cb749c10f projekt 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
0a0cb749c10f projekt 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
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
0a0cb749c10f projekt 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,
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
0a0cb749c10f projekt 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
0a0cb749c10f projekt 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/>.
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <codecvt>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <memory>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <algorithm>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <iostream>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
#include <stdexcept>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
#include <zbar.h>
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
#include "Configuration.h"
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
namespace relpipe {
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
namespace in {
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
namespace qr {
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
class QRCommand {
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: use platform encoding as default
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
public:
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	void process(Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
		zbar::Image image;
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		zbar::ImageScanner scanner;
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
		writer->startRelation(L"qr",{
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
			{L"value", relpipe::writer::TypeId::STRING}
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		}, true);
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
		writer->writeAttribute(L"some");
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
		writer->writeAttribute(L"qr");
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
		writer->writeAttribute(L"codes");
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
	}
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
};
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
}
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
}
0a0cb749c10f projekt skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
}