1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*
*/
#ifndef BIOMETRYD_VARIANT_H_
#define BIOMETRYD_VARIANT_H_
#include <biometry/geometry.h>
#include <biometry/visibility.h>
#include <cstdint>
#include <iosfwd>
#include <memory>
#include <string>
#include <vector>
namespace biometry
{
class BIOMETRY_DLL_PUBLIC Variant
{
public:
/// @brief None models the unset value.
struct None {};
enum class Type
{
none,
boolean,
integer,
floating_point,
rectangle,
string,
blob,
vector
};
static Variant b(bool value);
static Variant i(std::int64_t value);
static Variant d(double value);
static Variant r(const biometry::Rectangle& value);
static Variant s(const std::string& value);
static Variant bl(const std::vector<std::uint8_t>& value);
static Variant v(const std::vector<Variant>& value);
Variant();
Variant(const Variant&);
explicit Variant(bool b);
explicit Variant(std::int64_t i);
explicit Variant(double d);
explicit Variant(const biometry::Rectangle& value);
explicit Variant(const std::string& s);
explicit Variant(const std::vector<std::uint8_t>& b);
explicit Variant(const std::vector<Variant>& b);
~Variant();
Variant& operator=(const Variant&);
bool operator==(const Variant&) const;
std::ostream& print(std::ostream&) const;
Type type() const;
const bool& boolean() const;
void boolean(bool value);
std::int64_t integer() const;
void integer(std::int64_t value);
double floating_point() const;
void floating_point(double value);
const biometry::Rectangle& rectangle() const;
void rectangle(const biometry::Rectangle& rectangle);
const std::string& string() const;
void string(const std::string& value);
const std::vector<std::uint8_t>& blob() const;
void blob(const std::vector<std::uint8_t>& value);
const std::vector<Variant>& vector() const;
void vector(const std::vector<Variant>& vector);
private:
struct Private;
std::unique_ptr<Private> p;
};
BIOMETRY_DLL_PUBLIC bool operator==(const Variant::None&, const Variant::None&);
BIOMETRY_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Variant::None&);
BIOMETRY_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Variant& v);
}
#endif // UTIL_VARIANT_H_
|