OnixS C++ ICE Binary Order Entry Handler
1.0.0
API Documentation
Loading...
Searching...
No Matches
Formatting.h
Go to the documentation of this file.
1
/*
2
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3
*
4
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5
* and international copyright treaties.
6
*
7
* Access to and use of the software is governed by the terms of the applicable OnixS Software
8
* Services Agreement (the Agreement) and Customer end user license agreements granting
9
* a non-assignable, non-transferable and non-exclusive license to use the software
10
* for it's own data processing purposes under the terms defined in the Agreement.
11
*
12
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13
* of this source code or associated reference material to any other location for further reproduction
14
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15
*
16
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17
* the terms of the Agreement is a violation of copyright law.
18
*/
19
#pragma once
20
21
#include <
OnixS/ICE/BOE/ABI.h
>
22
#include <
OnixS/ICE/BOE/messaging/Integral.h
>
23
#include <
OnixS/ICE/BOE/messaging/StrRef.h
>
24
#include <
OnixS/ICE/BOE/messaging/SbeMessage.h
>
25
26
#include <string>
27
28
ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
29
30
ONIXS_ICEBOE_EXPORTED
31
ONIXS_ICEBOE_NODISCARD
32
std::string
format
(
Int32
index,
StrRef
input);
33
34
inline
StrRef
unwrap
(
SbeOptionalStr
value)
35
{
36
return
value ? *value :
StrRef
{};
37
}
38
39
inline
StrRef
unwrap
(
StrRef
value)
40
{
41
return
value;
42
}
43
44
template
<
typename
Message>
45
ONIXS_ICEBOE_NODISCARD
46
std::string
format
(
const
Message message)
47
{
48
const
auto
code = message.exchangeCode();
49
const
auto
text = message.text();
50
51
if
(code)
52
return
format
(*code,
unwrap
(text));
53
54
return
""
;
55
}
56
57
namespace
details
{
58
template
<
typename
T>
59
struct
hasText
60
{
61
template
<
typename
U,
typename
V, V (U::*)() const noexcept>
struct
SFINAE
{};
62
template
<
typename
U>
static
char
test
(
SFINAE
<U,
decltype
(std::declval<const U&>().text()), &U::text>*);
63
template
<
typename
U>
static
int
test
(...);
64
static
constexpr
bool
value
=
sizeof
(
test<T>
(
nullptr
)) ==
sizeof
(
char
);
65
};
66
67
template
<
typename
T>
68
struct
hasExchangeCode
69
{
70
template
<
typename
U,
typename
V, V (U::*)() const noexcept>
struct
SFINAE
{};
71
template
<
typename
U>
static
char
test
(
SFINAE
<U,
decltype
(std::declval<const U&>().exchangeCode()), &U::exchangeCode>*);
72
template
<
typename
U>
static
int
test
(...);
73
static
constexpr
bool
value
=
sizeof
(
test<T>
(
nullptr
)) ==
sizeof
(
char
);
74
};
75
76
template
<
typename
T>
77
struct
isFormattableMsgImpl
78
: std::integral_constant<bool, std::is_base_of<BinaryBlockBase, T>::value && hasText<T>::value && hasExchangeCode<T>::value> {};
79
}
80
81
template
<
typename
T>
struct
isFormattableMsg
:
public
details::isFormattableMsgImpl
<cleanType<T>> {};
82
83
template
<
typename
Message>
84
ONIXS_ICEBOE_NODISCARD
85
std::string
formatMsg
(
const
Message message,
typename
std::enable_if<
isFormattableMsg<Message>::value
,
void
*>::type =
nullptr
)
86
{
87
return
format
(message);
88
}
89
90
template
<
typename
Message>
91
ONIXS_ICEBOE_NODISCARD
92
std::string
formatMsg
(
const
Message,
typename
std::enable_if<!
isFormattableMsg<Message>::value
,
void
*>::type =
nullptr
)
93
{
94
return
""
;
95
}
96
97
ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
ABI.h
ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
Definition
ABI.h:102
ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
Definition
ABI.h:106
ONIXS_ICEBOE_EXPORTED
#define ONIXS_ICEBOE_EXPORTED
Definition
Compiler.h:153
ONIXS_ICEBOE_NODISCARD
#define ONIXS_ICEBOE_NODISCARD
Definition
Compiler.h:154
Integral.h
SbeMessage.h
StrRef.h
OnixS::ICE::BOE::Messaging::SbeOptionalStr
StrRef.
Definition
SbeOptional.h:227
OnixS::ICE::BOE::Messaging::details
Definition
Bits.h:31
OnixS::ICE::BOE::Messaging::formatMsg
std::string formatMsg(const Message message, typename std::enable_if< isFormattableMsg< Message >::value, void * >::type=nullptr)
Definition
Formatting.h:85
OnixS::ICE::BOE::Messaging::Int32
int32_t Int32
Definition
Integral.h:36
OnixS::ICE::BOE::Messaging::unwrap
StrRef unwrap(SbeOptionalStr value)
Definition
Formatting.h:34
OnixS::ICE::BOE::Messaging::format
std::string format(Int32 index, StrRef input)
OnixS::ICE::BOE::Messaging::StrRef
std::basic_string_view< Char > StrRef
Definition
StrRef.h:46
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::SFINAE
Definition
Formatting.h:70
OnixS::ICE::BOE::Messaging::details::hasExchangeCode
Definition
Formatting.h:69
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::test
static char test(SFINAE< U, decltype(std::declval< const U & >().exchangeCode()), &U::exchangeCode > *)
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::value
static constexpr bool value
Definition
Formatting.h:73
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::test
static int test(...)
OnixS::ICE::BOE::Messaging::details::hasText::SFINAE
Definition
Formatting.h:61
OnixS::ICE::BOE::Messaging::details::hasText
Definition
Formatting.h:60
OnixS::ICE::BOE::Messaging::details::hasText::test
static char test(SFINAE< U, decltype(std::declval< const U & >().text()), &U::text > *)
OnixS::ICE::BOE::Messaging::details::hasText::value
static constexpr bool value
Definition
Formatting.h:64
OnixS::ICE::BOE::Messaging::details::hasText::test
static int test(...)
OnixS::ICE::BOE::Messaging::details::isFormattableMsgImpl
Definition
Formatting.h:78
OnixS::ICE::BOE::Messaging::isFormattableMsg
Definition
Formatting.h:81
OnixS
ICE
BOE
messaging
Formatting.h
Technical Support:
support@onixs.biz
Copyright © 2025 OnixS. All Rights Reserved.