Value.h
1/* Copyright (C) 2006-2026 by Tommi Maekitalo
2 Copyright (C) 2006-2026 by Marc Boris Duerner
3 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
4*/
5
6#ifndef PT_DB_VALUE_H
7#define PT_DB_VALUE_H
8
9#include <Pt/Db/Api.h>
10#include <Pt/Db/IValue.h>
11#include <Pt/Db/Blob.h>
12#include <Pt/Date.h>
13#include <Pt/Time.h>
14#include <Pt/DateTime.h>
15#include <Pt/SmartPtr.h>
16
17namespace Pt {
18
19namespace Db {
20
34 class PT_DB_API Value
35 {
36 public:
37 typedef std::size_t size_type;
38
39 private:
41
42 public:
45 explicit Value(IValue* value = 0)
46 : _value(value)
47 { }
48
51 bool isNull() const { return !_value || _value->isNull(); }
52
57 bool getBool() const { return _value->getBool(); }
58
63 int getInt() const { return _value->getInt(); }
64
69 unsigned getUnsigned() const { return _value->getUnsigned(); }
70
75 float getFloat() const { return _value->getFloat(); }
76
81 double getDouble() const { return _value->getDouble(); }
82
89 char getChar() const { return _value->getChar(); }
90
95 std::string getString() const { return _value->getString(); }
96
101 Date getDate() const { return _value->getDate(); }
102
107 Time getTime() const { return _value->getTime(); }
108
113 DateTime getDateTime() const { return _value->getDateTime(); }
114
117 bool operator!() const { return !_value; }
118
121 const IValue* getImpl() const { return &*_value; }
122
127 void getBlob(Blob& blobdata) const
128 { return _value->getBlob(blobdata); }
129 };
130
131} // namespace Db
132
133} // namespace Pt
134
135#endif // PT_DB_VALUE_H
Combined Date and Time value.
Definition DateTime.h:66
Date expressed in year, month, and day.
Definition Date.h:104
Copy-on-write binary large object.
Definition Blob.h:144
Database-value backend.
Definition IValue.h:27
unsigned getUnsigned() const
Returns the value as unsigned.
Definition Value.h:69
Time getTime() const
Returns the value as time.
Definition Value.h:107
Date getDate() const
Returns the value as date.
Definition Value.h:101
const IValue * getImpl() const
Returns the backend implementation.
Definition Value.h:121
std::string getString() const
Returns the value as string.
Definition Value.h:95
bool getBool() const
Returns the value as bool.
Definition Value.h:57
Value(IValue *value=0)
Takes ownership of the backend value.
Definition Value.h:45
bool operator!() const
Returns true if this object is not bound to a value.
Definition Value.h:117
double getDouble() const
Returns the value as double.
Definition Value.h:81
void getBlob(Blob &blobdata) const
Writes the value as binary data into blobdata.
Definition Value.h:127
DateTime getDateTime() const
Returns the value as date-time.
Definition Value.h:113
int getInt() const
Returns the value as int.
Definition Value.h:63
bool isNull() const
Returns true if the value is unbound or SQL NULL.
Definition Value.h:51
float getFloat() const
Returns the value as float.
Definition Value.h:75
char getChar() const
Returns the value as char.
Definition Value.h:89
Policy based smart pointer.
Definition SmartPtr.h:462
Time expressed in hours, minutes, seconds and milliseconds.
Definition Time.h:98
Portable SQL database access.
Core module.
Definition Allocator.h:33