29#include <sptk5/Field.h>
30#include <sptk5/wsdl/WSFieldIndex.h>
31#include <sptk5/wsdl/WSType.h>
32#include <sptk5/xdoc/Node.h>
55 , m_optional(optional)
67 m_value = other.m_value;
68 m_optional = other.m_optional;
72 WSBasicType& operator=(WSBasicType&& other)
noexcept
74 m_value = std::move(other.m_value);
75 m_optional = other.m_optional;
102 m_value.setNull(defaultDataType());
109 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override
111 if (nullLargeData && attr->getString().length() > 256)
127 m_value.setString(attr);
136 m_value = *
static_cast<const Variant*
>(&field);
144 return m_value.asString();
152 return m_value.asString();
155 auto asInteger()
const
157 return value().asInteger();
162 return value().asInt64();
167 return value().asFloat();
172 return m_value.asBool();
175 void setInteger(int32_t _value)
177 m_value.setInteger(_value);
180 void setInt64(int64_t _value)
182 m_value.setInt64(_value);
185 void setFloat(
bool _value)
187 m_value.setFloat(_value);
190 void setBool(
bool _value)
192 m_value.setBool(_value);
195 void setBuffer(
const char* buffer,
size_t size)
197 m_value.setBuffer((
const uint8_t*) buffer, size);
200 bool isNull()
const override
202 return m_value.isNull();
211 size_t dataSize()
const
213 return m_value.dataSize();
218 return m_value.dataType();
223 m_value.setNull(defaultDataType());
231 const Variant& value()
const
241 void exportTo(
const xdoc::SNode& parent,
const char* name =
nullptr)
const override;
246 m_value.setNull(dataType);
261 bool m_optional {
false};
296 value().setString(_value);
322 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
341 value().setString(_value);
368 value().setInteger(_value);
377 value().setInt64(_value);
386 return value().asString();
389 const char* getString()
const
391 return value().getString();
428 value().setBool(_value);
454 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
473 value().setBool(_value);
480 operator bool()
const
482 return value().asBool();
518 value().setDateTime(_value,
true);
544 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
563 value().setDateTime(_value,
true);
572 return value().asDate();
580 return value().asDateTime();
588 return value().asDate();
624 value().setDateTime(_value);
650 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
674 return value().asDate();
682 return value().asDateTime();
690 value().setDateTime(_value);
699 return value().asDateTime();
731 value().setFloat(_value);
757 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
776 value().setFloat(_value);
783 operator double()
const
785 return value().asFloat();
821 value().setInteger(_value);
847 void load(
const xdoc::SNode& attr,
bool nullLargeData)
override;
866 value().setInt64(_value);
875 value().setInteger(_value);
882 operator int32_t()
const
884 return value().asInteger();
890 operator int64_t()
const
892 return value().asInt64();
898 operator uint64_t()
const
900 return (uint64_t) value().asInt64();
909String SP_EXPORT wsTypeIdToName(
const String& typeIdName);
size_t bytes() const
Definition: BufferStorage.h:213
uint8_t * data()
Definition: BufferStorage.h:106
Definition: DateTime.h:86
Definition: Variant.h:372
Definition: WSBasicTypes.h:41
virtual VariantDataType defaultDataType() const
Default data type.
Definition: WSBasicTypes.h:254
bool optional() const
Definition: WSBasicTypes.h:83
virtual void load(const String &attr)
Definition: WSBasicTypes.h:125
virtual void load(const Field &field)
Definition: WSBasicTypes.h:134
WSBasicType(const char *name, bool optional)
Definition: WSBasicTypes.h:53
void exportTo(const xdoc::SNode &parent, const char *name=nullptr) const override
void optional(bool opt)
Definition: WSBasicTypes.h:92
void load(const xdoc::SNode &attr, bool nullLargeData) override
Definition: WSBasicTypes.h:109
void clear() override
Definition: WSBasicTypes.h:100
void throwIfNull(const String &parentTypeName) const
String asString() const override
Definition: WSBasicTypes.h:150
Definition: WSBasicTypes.h:400
void load(const xdoc::SNode &attr, bool nullLargeData) override
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:444
WSBool()
Definition: WSBasicTypes.h:405
String className() const override
Definition: WSBasicTypes.h:434
WSBool(const String &name, bool optional)
Definition: WSBasicTypes.h:415
void load(const Field &field) override
void load(const String &attr) override
virtual WSBool & operator=(bool _value)
Definition: WSBasicTypes.h:471
WSBool(bool _value)
Definition: WSBasicTypes.h:426
Definition: WSBasicTypes.h:597
void load(const xdoc::SNode &attr, bool nullLargeData) override
String className() const override
Definition: WSBasicTypes.h:630
void load(const Field &field) override
String asString() const override
WSDateTime(const String &name, bool optional)
Definition: WSBasicTypes.h:612
void load(const String &attr) override
auto asDateTime() const
Definition: WSBasicTypes.h:680
WSDateTime(const DateTime &_value)
Definition: WSBasicTypes.h:622
WSDateTime & operator=(DateTime _value)
Definition: WSBasicTypes.h:688
WSDateTime()
Definition: WSBasicTypes.h:602
auto asDate() const
Definition: WSBasicTypes.h:672
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:640
Definition: WSBasicTypes.h:491
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:534
WSDate(const DateTime &_value)
Definition: WSBasicTypes.h:516
void load(const Field &field) override
WSDate()
Definition: WSBasicTypes.h:496
String className() const override
Definition: WSBasicTypes.h:524
void load(const String &attr) override
auto asDate() const
Definition: WSBasicTypes.h:570
WSDate(const String &name, bool optional)
Definition: WSBasicTypes.h:506
auto asDateTime() const
Definition: WSBasicTypes.h:578
WSDate & operator=(DateTime _value)
Definition: WSBasicTypes.h:561
void load(const xdoc::SNode &attr, bool nullLargeData) override
Definition: WSBasicTypes.h:708
String className() const override
Definition: WSBasicTypes.h:737
WSDouble(const String &name, bool optional)
Definition: WSBasicTypes.h:723
void load(const String &attr) override
void load(const xdoc::SNode &attr, bool nullLargeData) override
void load(const Field &field) override
WSDouble()
Definition: WSBasicTypes.h:713
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:747
WSDouble & operator=(double _value)
Definition: WSBasicTypes.h:774
Definition: WSBasicTypes.h:794
WSInteger & operator=(int64_t _value)
Definition: WSBasicTypes.h:864
WSInteger(int _value)
Definition: WSBasicTypes.h:819
String className() const override
Definition: WSBasicTypes.h:827
WSInteger(const String &name, bool optional)
Definition: WSBasicTypes.h:809
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:837
WSInteger & operator=(int _value)
Definition: WSBasicTypes.h:873
void load(const Field &field) override
void load(const xdoc::SNode &attr, bool nullLargeData) override
void load(const String &attr) override
WSInteger()
Definition: WSBasicTypes.h:799
Definition: WSBasicTypes.h:269
WSString(const String &name, bool optional)
Definition: WSBasicTypes.h:284
WSString & operator=(const char *_value)
Definition: WSBasicTypes.h:339
WSString & operator=(const Buffer &_value)
Definition: WSBasicTypes.h:357
WSString()
Definition: WSBasicTypes.h:274
void load(const String &attr) override
void load(const Field &field) override
WSString & operator=(const String &_value)
Definition: WSBasicTypes.h:348
WSString(const String &_value)
Definition: WSBasicTypes.h:294
WSString & operator=(int32_t _value)
Definition: WSBasicTypes.h:366
void load(const xdoc::SNode &attr, bool nullLargeData) override
VariantDataType defaultDataType() const override
Default data type.
Definition: WSBasicTypes.h:312
WSString & operator=(int64_t _value)
Definition: WSBasicTypes.h:375
String className() const override
Definition: WSBasicTypes.h:302
VariantDataType
Definition: VariantData.h:44
@ VAR_DATE
DateTime (double)
@ VAR_FLOAT
Floating-point (double)
@ VAR_STRING
String pointer.
@ VAR_DATE_TIME
DateTime (double)
@ VAR_BUFFER
Data pointer, corresponding to BLOBS in database.