OnixS C++ ICE Binary Order Entry Handler
1.2.3
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 <exception>
27
#include <string>
28
29
ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
30
31
ONIXS_ICEBOE_EXPORTED
32
ONIXS_ICEBOE_NODISCARD
33
std::string
format
(
Int32
index,
StrRef
input);
34
35
inline
StrRef
unwrap
(
SbeOptionalStr
value)
36
{
37
return
value ? *value :
StrRef
{};
38
}
39
40
inline
StrRef
unwrap
(
StrRef
value)
41
{
42
return
value;
43
}
44
55
template
<
typename
Message>
56
ONIXS_ICEBOE_NODISCARD
57
std::string
format
(
const
Message message)
58
{
59
const
auto
code = message.exchangeCode();
60
61
if
(!code)
62
return
{};
63
64
try
65
{
66
return
format
(*code,
unwrap
(message.text()));
67
}
68
catch
(
const
std::exception& e)
69
{
70
return
std::string(
"Exception while description formatting: "
) + e.what();
71
}
72
}
73
74
namespace
details
{
79
template
<
typename
T>
80
struct
hasText
81
{
82
template
<
typename
U>
static
auto
test
(
int
) ->
typename
std::enable_if<noexcept(std::declval<const U&>().text()),
char
>::type;
83
template
<
typename
U>
static
int
test
(...);
84
static
constexpr
bool
value
=
sizeof
(
test<T>
(0)) ==
sizeof
(
char
);
85
};
86
87
template
<
typename
T>
88
struct
hasExchangeCode
89
{
90
template
<
typename
U>
static
auto
test
(
int
) ->
typename
std::enable_if<noexcept(std::declval<const U&>().exchangeCode()),
char
>::type;
91
template
<
typename
U>
static
int
test
(...);
92
static
constexpr
bool
value
=
sizeof
(
test<T>
(0)) ==
sizeof
(
char
);
93
};
94
95
template
<
typename
T>
96
struct
isFormattableMsgImpl
97
: std::integral_constant<bool, std::is_base_of<BinaryBlockBase, T>::value && hasText<T>::value && hasExchangeCode<T>::value> {};
98
}
99
100
template
<
typename
T>
struct
isFormattableMsg
:
public
details::isFormattableMsgImpl
<cleanType<T>> {};
101
102
template
<
typename
Message>
103
ONIXS_ICEBOE_NODISCARD
104
std::string
formatMsg
(
const
Message message,
typename
std::enable_if<
isFormattableMsg<Message>::value
,
void
*>::type =
nullptr
)
105
{
106
return
format
(message);
107
}
108
109
template
<
typename
Message>
110
ONIXS_ICEBOE_NODISCARD
111
std::string
formatMsg
(
const
Message,
typename
std::enable_if<!
isFormattableMsg<Message>::value
,
void
*>::type =
nullptr
)
112
{
113
return
""
;
114
}
115
116
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:154
ONIXS_ICEBOE_NODISCARD
#define ONIXS_ICEBOE_NODISCARD
Definition
Compiler.h:155
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:104
OnixS::ICE::BOE::Messaging::Int32
int32_t Int32
Definition
Integral.h:38
OnixS::ICE::BOE::Messaging::unwrap
StrRef unwrap(SbeOptionalStr value)
Definition
Formatting.h:35
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
Definition
Formatting.h:89
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::value
static constexpr bool value
Definition
Formatting.h:92
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::test
static auto test(int) -> typename std::enable_if< noexcept(std::declval< const U & >().exchangeCode()), char >::type
OnixS::ICE::BOE::Messaging::details::hasExchangeCode::test
static int test(...)
OnixS::ICE::BOE::Messaging::details::hasText
Both getters can be inherited rather than declared by T itself - MessageHolder hands out a HeldAdapte...
Definition
Formatting.h:81
OnixS::ICE::BOE::Messaging::details::hasText::value
static constexpr bool value
Definition
Formatting.h:84
OnixS::ICE::BOE::Messaging::details::hasText::test
static auto test(int) -> typename std::enable_if< noexcept(std::declval< const U & >().text()), char >::type
OnixS::ICE::BOE::Messaging::details::hasText::test
static int test(...)
OnixS::ICE::BOE::Messaging::details::isFormattableMsgImpl
Definition
Formatting.h:97
OnixS::ICE::BOE::Messaging::isFormattableMsg
Definition
Formatting.h:100
OnixS
ICE
BOE
messaging
Formatting.h
Technical Support:
support@onixs.biz
Copyright © 2026 OnixS. All Rights Reserved.