OnixS C++ ICE Binary Order Entry Handler 1.0.0
API Documentation
Loading...
Searching...
No Matches
String.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <string>
24#include <cstring>
25
26#include <OnixS/ICE/BOE/ABI.h>
27
29
31typedef char Char;
32
35void toStr(std::string& str, Char character);
36
38inline
39void toStr(std::string& str, const std::string& value)
40{
41 str.append(value);
42}
43
46inline std::string toStr(Char character)
47{
48 std::string res;
49 toStr(res, character);
50 return res;
51}
52
53namespace details {
54 template <size_t From, size_t To>
55 struct Strnlen
56 {
57 static constexpr size_t compute(const char* s) noexcept
58 {
59 return (s[From] == '\0') ? From : Strnlen<From + 1, To>::compute(s);
60 }
61 };
62
63 template <size_t To>
64 struct Strnlen<To, To>
65 {
66 static constexpr size_t compute(const char*) noexcept { return To; }
67 };
68}
69
70template <size_t MaxLen>
71ONIXS_ICEBOE_FORCEINLINE
72typename std::enable_if<(MaxLen <= 16), size_t>::type
73 stringLen(const Char* s) noexcept
74{
76}
77
78template <size_t MaxLen>
79ONIXS_ICEBOE_FORCEINLINE
80typename std::enable_if<(MaxLen > 16), size_t>::type
81 stringLen(const Char* s) noexcept
82{
83 return ::strnlen(s, MaxLen);
84}
85
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:102
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
Definition ABI.h:106
#define ONIXS_ICEBOE_EXPORTED
Definition Compiler.h:153
#define ONIXS_ICEBOE_NODISCARD
Definition Compiler.h:154
char Char
Character type alias.
Definition String.h:31
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &)
Serializes a fixed-point decimal into a string.
ONIXS_ICEBOE_FORCEINLINE std::enable_if<(MaxLen<=16), size_t >::type stringLen(const Char *s) noexcept
Definition String.h:73
static constexpr size_t compute(const char *) noexcept
Definition String.h:66
static constexpr size_t compute(const char *s) noexcept
Definition String.h:57