summaryrefslogtreecommitdiffstats
path: root/lib/db_ido/dbvalue.hpp
blob: cb59e3ad4afb110f93d87ba51eecdee719162848 (plain)
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
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

#ifndef DBVALUE_H
#define DBVALUE_H

#include "db_ido/i2-db_ido.hpp"
#include "base/object.hpp"
#include "base/value.hpp"

namespace icinga
{

enum DbValueType
{
	DbValueTimestamp,
	DbValueObjectInsertID
};

/**
 * A database value.
 *
 * @ingroup ido
 */
struct DbValue final : public Object
{
public:
	DECLARE_PTR_TYPEDEFS(DbValue);

	DbValue(DbValueType type, Value value);

	static Value FromTimestamp(const Value& ts);
	static Value FromValue(const Value& value);
	static Value FromObjectInsertID(const Value& value);

	static bool IsTimestamp(const Value& value);
	static bool IsObjectInsertID(const Value& value);

	static Value ExtractValue(const Value& value);

	DbValueType GetType() const;

	Value GetValue() const;
	void SetValue(const Value& value);

private:
	DbValueType m_Type;
	Value m_Value;
};

}

#endif /* DBVALUE_H */