63 template <
class StringRef>
68 if (
convert(converted, container))
70 ref = StringRef(converted);
203 str.assign(ref.data(), ref.size());
208 return container.get<
StrRef>();
213 ref = container.get<
StrRef>();
228 else if (str.empty())
328 str.append(1, container.
get<
Char>());
352 return charToDigit(
value, container.get<
Char>());
357 return charToDigit(
value, container.get<
Char>());
362 return charToDigit(
value, container.get<
Char>());
367 return charToDigit(
value, container.get<
Char>());
372 return charToDigit(
value, container.get<
Char>());
377 return charToDigit(
value, container.get<
Char>());
382 return charToDigit(
value, container.get<
Char>());
387 return charToDigit(
value, container.get<
Char>());
394 if (charToDigit(mantissa, container.get<
Char>()))
409 template <class Integer>
410 static
bool charToDigit(Integer& converted,
Char original) noexcept
412 if (
'0' <= original &&
'9' >= original)
414 converted =
static_cast<Integer
>(original -
'0');
424template <
class Integer,
class Descendant =
void>
427 template <
class Integral,
bool IsSigned>
430 bool operator()(Integral
value)
const noexcept
436 template <
class Integral>
437 struct FitsToChar<Integral, false>
439 bool operator()(Integral
value)
const noexcept
445 typedef FitsToChar<Integer, !(static_cast<Integer>(-1) >
static_cast<Integer
>(0))> CanFitToChar;
452 ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(str, container.
get<Integer>());
459 const size_t converted = ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(container.
get<Integer>(), buf, size);
461 assert(converted < size);
462 assert(converted != 0);
464 return StrRef(buf, converted);
469 const Integer actual = container.get<Integer>();
471 if (CanFitToChar()(actual))
483 value = numericCast<Int8>(container.get<Integer>());
490 value = numericCast<UInt8>(container.get<Integer>());
497 value = numericCast<Int16>(container.get<Integer>());
504 value = numericCast<UInt16>(container.get<Integer>());
511 value = numericCast<Int32>(container.get<Integer>());
518 value = numericCast<UInt32>(container.get<Integer>());
525 value = numericCast<Int64>(container.get<Integer>());
532 value = numericCast<UInt64>(container.get<Integer>());
539 value =
Decimal(numericCast<Decimal::Mantissa>(container.get<Integer>()), 0);
670 ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(str, container.
get<
Decimal>());
677 const size_t converted = ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(container.
get<
Decimal>(), buf, size);
679 assert(converted != 0);
680 assert(converted < size);
682 return StrRef(buf, converted);
711 ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(str, container.
get<
Timestamp>());
718 const size_t converted = ONIXS_CMEMDH_MESSAGING_NAMESPACE::toStr(container.
get<
Timestamp>(), buf, size);
720 assert(converted < size);
721 assert(converted != 0);
723 return StrRef(buf, converted);
760 return "MaturityMonthYear";
792template <
class Value>
795 typedef char Ordinary[1];
797 typedef char Enumeration[2];
799 typedef char Bits[3];
801 template <
class Other>
802 static Bits& kind(
typename Other::Bits*);
804 template <
class Other>
805 static Enumeration& kind(
typename Other::Enum*);
807 template <
class Other>
808 static Ordinary& kind(...);
815 (
sizeof(Bits) ==
sizeof(kind<Value>(
nullptr))
823template <
class Value,
int>
839 if (!converter.
convert(result, container))
841 throwBadConversion(converter.
typeName());
855 return converter.
convert(result, container);
862template <
class Enumeration>
866 typedef typename Enumeration::Enum
Result;
874 typename Enumeration::Base result;
876 if (!converter.
convert(result, container))
878 throwBadConversion(converter.
typeName());
881 return static_cast<Result>(result);
890 typename Enumeration::Base base;
892 if (converter.
convert(base, container))
894 result =
static_cast<Result>(base);
907template <
class BitSet>
919 typename BitSet::Bits bits;
921 if (!converter.
convert(bits, container))
923 throwBadConversion(converter.
typeName());
935 typename BitSet::Bits bits;
937 if (converter.
convert(bits, container))
939 result = BitSet(bits);
950template <
class Value>
#define ONIXS_CMEMDH_MESSAGING_TAGBASED_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_MESSAGING_TAGBASED_NAMESPACE_END
#define ONIXS_CMEMDH_EXPORTED
#define ONIXS_CMEMDH_NODISCARD
Implements the value conversion for integer fields.
bool convert(UInt64 &value, const ValueContainer &container) const noexcept override
~IntegerConverter()=default
bool convert(UInt16 &value, const ValueContainer &container) const noexcept override
void toStr(std::string &str, const ValueContainer &container) const override
StrRef toStr(Char *buf, size_t size, const ValueContainer &container) const override
bool convert(Int16 &value, const ValueContainer &container) const noexcept override
bool convert(Timestamp &value, const ValueContainer &container) const noexcept override
bool convert(Char &value, const ValueContainer &container) const noexcept override
bool convert(UInt8 &value, const ValueContainer &container) const noexcept override
bool convert(Int32 &value, const ValueContainer &container) const noexcept override
bool convert(Int8 &value, const ValueContainer &container) const noexcept override
bool convert(Int64 &value, const ValueContainer &container) const noexcept override
bool convert(UInt32 &value, const ValueContainer &container) const noexcept override
bool convert(Decimal &value, const ValueContainer &container) const noexcept override
Traits class used to identify a field value.
@ Kind
The kind of the given field value by its type.
The time point without the time-zone information.
Ticks sinceEpoch() const noexcept
bool value(Number &number, const MultiContainer &container, Tag tag)
Timestamp makeTimestamp(Timestamp::Ticks ticks) noexcept
Make Timestamp helper.
bool fromStr(Int8 &, const Char *, size_t)
std::uint32_t UInt32
uInt32.
char Char
Character type alias.
std::uint16_t UInt16
uInt16.
std::basic_string_view< Char > StrRef
FloatingPointDecimal< DecimalMantissa, DecimalExponent > Decimal
Universal decimal type.
std::uint64_t UInt64
uInt64.
bool convert(UInt64 &value, const ValueContainer &container) const noexcept override
bool convert(StrRef &ref, const ValueContainer &container) const noexcept override
bool convert(UInt16 &value, const ValueContainer &container) const noexcept override
void toStr(std::string &str, const ValueContainer &container) const override
static const ValueConverter & self() noexcept
bool convert(Int16 &value, const ValueContainer &container) const noexcept override
StrRef toStr(Char *, size_t, const ValueContainer &container) const noexcept override
bool convert(Char &value, const ValueContainer &container) const noexcept override
const Char * typeName() const noexcept override
bool convert(UInt8 &value, const ValueContainer &container) const noexcept override
bool convert(Int32 &value, const ValueContainer &container) const noexcept override
bool convert(Int8 &value, const ValueContainer &container) const noexcept override
bool convert(Int64 &value, const ValueContainer &container) const noexcept override
bool convert(UInt32 &value, const ValueContainer &container) const noexcept override
bool convert(Decimal &value, const ValueContainer &container) const noexcept override
Implements the value conversion the Decimal fields.
void toStr(std::string &str, const ValueContainer &container) const override
StrRef toStr(Char *buf, size_t size, const ValueContainer &container) const override
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
bool convert(Decimal &value, const ValueContainer &container) const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for month-year fields.
void toStr(std::string &str, const ValueContainer &container) const override
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
bool convert(MaturityMonthYear &value, const ValueContainer &container) const noexcept override
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for text fields.
bool convert(UInt64 &value, const ValueContainer &container) const noexcept override
bool convert(StrRef &ref, const ValueContainer &container) const noexcept override
bool convert(UInt16 &value, const ValueContainer &container) const noexcept override
void toStr(std::string &str, const ValueContainer &container) const override
bool convert(Timestamp &value, const ValueContainer &container) const override
static const ValueConverter & self() noexcept
bool convert(Int16 &value, const ValueContainer &container) const noexcept override
StrRef toStr(Char *, size_t, const ValueContainer &container) const noexcept override
bool convert(Char &value, const ValueContainer &container) const noexcept override
const Char * typeName() const noexcept override
bool convert(UInt8 &value, const ValueContainer &container) const noexcept override
bool convert(Int32 &value, const ValueContainer &container) const noexcept override
bool convert(Int8 &value, const ValueContainer &container) const noexcept override
bool convert(Int64 &value, const ValueContainer &container) const noexcept override
bool convert(UInt32 &value, const ValueContainer &container) const noexcept override
bool convert(Decimal &value, const ValueContainer &container) const noexcept override
Implements the value conversion for Timestamp fields.
bool convert(UInt64 &value, const ValueContainer &container) const noexcept override
void toStr(std::string &str, const ValueContainer &container) const override
StrRef toStr(Char *buf, size_t size, const ValueContainer &container) const override
static const ValueConverter & self() noexcept
bool convert(Timestamp &value, const ValueContainer &container) const noexcept override
const Char * typeName() const noexcept override
bool convert(Int64 &value, const ValueContainer &container) const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
Implements the value conversion for integer fields.
static const ValueConverter & self() noexcept
const Char * typeName() const noexcept override
static BitSet convert(const ValueConverter &converter, const ValueContainer &container)
static bool convert(BitSet &result, const ValueConverter &converter, const ValueContainer &container)
BitSet Result
Type of the conversion output.
Enumeration::Enum Result
Type of the conversion output.
static Result convert(const ValueConverter &converter, const ValueContainer &container)
static bool convert(Result &result, const ValueConverter &converter, const ValueContainer &container)
Field value traits used in conversion operations.
static Result convert(const ValueConverter &converter, const ValueContainer &container)
Value Result
Type of the conversion output.
static bool convert(Result &result, const ValueConverter &converter, const ValueContainer &container)
bool operator()(typename Traits::Result &result, const ValueConverter &converter, const ValueContainer &container) const
Traits::Result Result
Conversion output type.
ValueConversionTraits< Value, ValueKind< Value >::Kind > Traits
Conversion traits.
Traits::Result operator()(const ValueConverter &converter, const ValueContainer &container) const
virtual bool convert(UInt16 &, const ValueContainer &) const noexcept
virtual bool convert(MaturityMonthYear &, const ValueContainer &) const noexcept
virtual bool convert(UInt8 &, const ValueContainer &) const noexcept
virtual bool convert(UInt32 &, const ValueContainer &) const noexcept
virtual void toStr(std::string &, const ValueContainer &) const
virtual bool convert(Timestamp &, const ValueContainer &) const
virtual bool convert(UInt64 &, const ValueContainer &) const noexcept
virtual StrRef toStr(Char *, size_t, const ValueContainer &) const
virtual bool convert(Char &, const ValueContainer &) const noexcept
virtual bool convert(Int8 &, const ValueContainer &) const noexcept
virtual const Char * typeName() const noexcept=0
bool convert(StringRef &ref, const ValueContainer &container) const
virtual bool convert(StrRef &, const ValueContainer &) const noexcept
virtual bool convert(Decimal &, const ValueContainer &) const noexcept
virtual bool convert(Int32 &, const ValueContainer &) const noexcept
virtual bool convert(Int64 &, const ValueContainer &) const noexcept
virtual bool convert(Int16 &, const ValueContainer &) const noexcept
Identifies the kind of the field value.