icinga2/lib/db_ido/dbvalue.hpp

53 lines
888 B
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2013-07-23 11:02:47 +02:00
#ifndef DBVALUE_H
#define DBVALUE_H
2014-05-25 16:23:35 +02:00
#include "db_ido/i2-db_ido.hpp"
#include "base/object.hpp"
#include "base/value.hpp"
2013-07-23 11:02:47 +02:00
namespace icinga
{
enum DbValueType
{
DbValueTimestamp,
DbValueObjectInsertID
2013-07-23 11:02:47 +02:00
};
/**
* A database value.
*
* @ingroup ido
*/
2018-01-04 06:11:04 +01:00
struct DbValue final : public Object
2013-07-23 11:02:47 +02:00
{
public:
DECLARE_PTR_TYPEDEFS(DbValue);
2013-07-23 11:02:47 +02:00
DbValue(DbValueType type, Value value);
2013-09-01 06:01:27 +02:00
2013-07-23 11:02:47 +02:00
static Value FromTimestamp(const Value& ts);
static Value FromValue(const Value& value);
static Value FromObjectInsertID(const Value& value);
2013-07-23 11:02:47 +02:00
static bool IsTimestamp(const Value& value);
static bool IsObjectInsertID(const Value& value);
2013-07-23 11:02:47 +02:00
static Value ExtractValue(const Value& value);
DbValueType GetType() const;
Value GetValue() const;
void SetValue(const Value& value);
2013-07-23 11:02:47 +02:00
private:
DbValueType m_Type;
Value m_Value;
};
}
#endif /* DBVALUE_H */