-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdvalue.cpp
More file actions
113 lines (94 loc) · 1.9 KB
/
dvalue.cpp
File metadata and controls
113 lines (94 loc) · 1.9 KB
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
109
110
111
112
113
#include "dvalue.hpp"
#include "dobject.hpp"
#include "dexception.hpp"
namespace Destruct
{
BaseValue* FinalValue::clone(DObject *) const
{
return (clone());
}
DValue FinalValue::getFinal() const
{
return (*this);
}
FinalValue::FinalValue()
{
}
FinalValue::FinalValue(FinalValue const& rhs) : BaseValue(rhs)
{
}
FinalValue& FinalValue::operator=(FinalValue const &rhs)
{
BaseValue::operator =(rhs);
return (*this);
}
/**
* DValue
*/
DValue::DValue(FinalValue const& fv) : __value(fv.clone())
{
}
DValue::DValue(DValue const& rhs) : __value(rhs.__value ? rhs.__value->clone() : NULL)
{
}
DValue::DValue(FinalValue *fv) : __value(fv)
{
}
DValue::~DValue()
{
delete this->__value;
}
DValue& DValue::replace(const DValue& rhs)
{
if (this->__value)
delete this->__value;
this->__value = rhs.__value->clone();
return (*this);
}
DValue& DValue::operator=(const DValue& rhs)
{
if(this->__value)
{
if (rhs.__value)
{
this->__value->set(rhs);
}
else
{
delete this->__value;
this->__value = NULL;
}
}
else
{
this->__value = (rhs.__value ? rhs.__value->clone() : NULL);
}
return (*this);
}
DUnicodeString DValue::asUnicodeString() const
{
if (this->__value)
return (this->__value->asUnicodeString());
return (DUnicodeString());
}
DBuffer DValue::asDBuffer() const
{
if (this->__value)
return (this->__value->asDBuffer());
throw DException("Can't convert void DValue to DBuffer");
}
//DStreamBase& operator<<(DStreamBase& os, DValue& value) //asRaw() ? //from raw //python binding ? Value.serialize() Value.dserialize(stream)
//{
//if (value.__value)
//return (value.__value->serialize(os));
//os.write(0, sizeof(uint8_t));
//// return os << 0; //XXX ?
//return os;
//}
//DStreamBase& operator>>(DStreamBase& is, DValue& value)
//{
//if (value.__value)
//return (value.__value->unserialize(is));
//return (is);
//}
}