30#ifdef ONIXS_ICEBOE_CXX17
44 template<
typename U, Timestamp (U::*)() const>
struct SFINAE {};
47#if ONIXS_ICEBOE_CXX17_NOEXCEPT
48 template<
typename U, Timestamp (U::*)() const noexcept>
struct SFINAE_1 {};
49 template<
typename U>
static char test(SFINAE_1<U, &U::transactTime>*);
52 template<
typename U>
static int test(...);
53 static constexpr bool value =
sizeof(
test<T>(
nullptr)) ==
sizeof(
char);
59 template<
typename U, OrderExecID (U::*)() const noexcept>
struct SFINAE {};
61 template<
typename U>
static int test(...);
62 static constexpr bool value =
sizeof(
test<T>(
nullptr)) ==
sizeof(
char);
68 template<
typename U,
typename V, V (U::*)() const noexcept>
struct SFINAE {};
69 template<
typename U>
static char test(
SFINAE<U,
decltype(std::declval<const U&>().execType()), &U::execType>*);
70 template<
typename U>
static int test(...);
71 static constexpr bool value =
sizeof(
test<T>(
nullptr)) ==
sizeof(
char);
78 template<
typename U,
typename V, V (U::*)() const noexcept>
struct SFINAE {};
79 template<
typename U>
static char test(
SFINAE<U,
decltype(std::declval<const U&>().leavesQty()), &U::leavesQty>*);
80 template<
typename U>
static int test(...);
81 static constexpr bool value =
sizeof(
test<T>(
nullptr)) ==
sizeof(
char);
91template <
typename MsgType>
94 return msg.transactTime();
97template <
typename MsgType>
100 return msg.execId().transactTime();
103template <
typename MsgType>
109template <
typename MsgType>
112 return msg.execType();
115template <
typename MsgType>
121template <
typename MsgType>
127template <
typename MsgType>
133template <
typename MsgType>
138 return quantize(value, -9).mantissa();
142T
parseUserInput(
const std::string& userInput,
typename std::enable_if<std::is_integral<T>::value,
void*>::type =
nullptr)
144 std::istringstream ss{userInput};
147 using Wide =
typename std::conditional<std::is_signed<T>::value,
long long,
unsigned long long>::type;
150 if (!(ss >> converted))
151 throw std::invalid_argument(
"Invalid user input: '" + userInput +
"'");
153 return static_cast<T
>(converted);
157T
parseUserInput(
const std::string& userInput,
typename std::enable_if<isScopedEnum<T>::value,
void*>::type =
nullptr)
159 std::istringstream ss{userInput};
163 typename std::conditional<
164 std::is_same<typename underlyingType<T>::type,
char>::value,
166 typename std::conditional<std::is_signed<T>::value,
168 unsigned long long>::type>::type;
172 if (!(ss >> converted))
173 throw std::invalid_argument(
"Invalid user input: '" + userInput +
"'");
175 const auto enumerated =
static_cast<T
>(
static_cast<typename underlyingType<T>::type
>(converted));
177 if(ONIXS_ICEBOE_MESSAGING_NAMESPACE::toStr(enumerated).find(
"UNKNOWN_VALUE") != std::string::npos)
178 throw std::invalid_argument(
"Invalid user input: '" + userInput +
"'");
184Decimal parseUserInput(
const std::string& userInput,
typename std::enable_if<std::is_floating_point<T>::value,
void*>::type =
nullptr)
191 throw std::invalid_argument(
"Invalid user input: '" + userInput +
"'");
195T
parseUserInput(
const std::string& userInput,
typename std::enable_if<std::is_same<T, std::string>::value,
void*>::type =
nullptr)
202auto toValueNamePair(T v,
typename std::enable_if<isScopedEnum<T>::value,
void*>::type=
nullptr)
204 return toStr(toUnderlying(v)) +
"-" +
toStr(v);
207template <
typename It>
208inline auto join(It first, It last,
char delim,
typename std::enable_if<isScopedEnum<typename It::value_type>::value,
void*>::type=
nullptr)
211 return std::string{};
213 std::ostringstream oss;
216 for (; first != last; ++first)
223#ifdef ONIXS_ICEBOE_CXX17
224template<
typename T>
using OptionalRef = std::optional<std::shared_ptr<T>>;
229 using Ref = std::shared_ptr<T>;
237 ::new (&storage_) Ref(t);
243 if (has_) ::new (&storage_) Ref(*o.refptr());
249 if (has_) ::new (&storage_) Ref(std::move(*o.refptr()));
254 explicit operator bool()
const noexcept {
return has_; }
256 Ref& operator*() {
return value(); }
257 const Ref& operator*()
const {
return value(); }
259 Ref* operator->() {
return &value(); }
260 const Ref* operator->()
const {
return &value(); }
263 Ref* refptr() {
return reinterpret_cast<Ref*
>(&storage_); }
264 const Ref* refptr()
const {
return reinterpret_cast<const Ref*
>(&storage_); }
268 using Storage =
typename std::aligned_storage<
sizeof(Ref),
alignof(Ref)>::type;
#define ONIXS_ICEBOE_NAMESPACE
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE
The time point without the time-zone information.
FloatingPointDecimal< Int64, Int32 > Decimal
Universal decimal type.
void throwBadOptionalAccess()
ExecTypeEnum
ExecTypeEnum type.
Int64 Decimal9
Quantity, Price with constant exponent -9.
bool quantize(const Decimal &operand, Int32 exponent, Decimal &quantized)
Quantize so its exponent is the same as that of provided value.
void setOrdStatus(Order &order, MsgType &&msg, ExecTypeEnum defaultValue)
typename details::hasTransactTimeImpl< cleanType< T > > hasTransactTime
ExecTypeEnum getOrdStatus(MsgType &&msg, ExecTypeEnum, typename std::enable_if< hasExecType< MsgType >::value, void * >::type=nullptr)
T parseUserInput(const std::string &userInput, typename std::enable_if< std::is_integral< T >::value, void * >::type=nullptr)
auto join(It first, It last, char delim, typename std::enable_if< isScopedEnum< typename It::value_type >::value, void * >::type=nullptr)
std::optional< std::shared_ptr< T > > OptionalRef
Manages an optional contained reference.
auto toValueNamePair(T v, typename std::enable_if< isScopedEnum< T >::value, void * >::type=nullptr)
typename details::hasExecIdImpl< cleanType< T > > hasExecId
std::string toStr(Order::PriceOptional value)
Timestamp getTransactTime(MsgType &&msg, typename std::enable_if< hasTransactTime< MsgType >::value, void * >::type=nullptr)
typename details::hasExecTypeImpl< cleanType< T > > hasExecType
typename details::hasLeavesQtyImpl< cleanType< T > > hasLeavesQty
void setLeavesQty(Order &order, MsgType &&msg, typename std::enable_if< hasLeavesQty< MsgType >::value, void * >::type=nullptr)
Decimal9 toPriceMantissa(Decimal value)
T fromStr(const std::string &s)
ExecTypeEnum orderStatus_
static constexpr bool value
static char test(SFINAE< U, &U::execId > *)
static constexpr bool value
static char test(SFINAE< U, decltype(std::declval< const U & >().execType()), &U::execType > *)
static char test(SFINAE< U, decltype(std::declval< const U & >().leavesQty()), &U::leavesQty > *)
static constexpr bool value
static constexpr bool value
static char test(SFINAE< U, &U::transactTime > *)