 |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Go to the documentation of this file.
7 #ifndef LLU_WSTP_ENCODINGTRAITS_HPP_
8 #define LLU_WSTP_ENCODINGTRAITS_HPP_
12 #include <type_traits>
39 static_assert(E !=
Encoding::Undefined,
"Trying to deduce character type for undefined encoding");
53 struct CharTypeStruct<
Encoding::Byte> {
54 using type =
unsigned char;
57 struct CharTypeStruct<
Encoding::UTF8> {
58 using type =
unsigned char;
62 using type =
unsigned short;
66 using type =
unsigned short;
70 using type =
unsigned int;
91 template<Encoding E,
typename T>
103 using type = std::basic_string<CharType<E>>;
149 template<Encoding E, typename T, bool = std::is_lvalue_reference<T>::value>
156 template<Encoding E,
typename T>
157 struct PutAs<E, T, true> {
163 explicit PutAs(
const T& o) : obj(o) {}
172 template<Encoding E,
typename T>
173 struct PutAs<E, T, false> {
179 explicit PutAs(T&& o) : obj(std::move(o)) {}
191 template<Encoding E,
typename T>
213 template<Encoding E,
typename T>
231 template<Encoding E,
typename T>
@ Native
Use WSGetString for reading and WSPutString for writing strings.
@ Undefined
Undefined, can be used to denote that certain function is not supposed to deal with strings.
typename CharTypeStruct< E >::type CharType
Specializations of CharTypeStruct, encoding E has assigned type T iff WSPutEString takes const T* as ...
Definition: EncodingTraits.hpp:81
@ Byte
Use WSGetByteString for reading and WSPutByteString for writing strings.
GetAs< E, T > getAs(T &obj)
This is a helper function to facilitate constructing WS::GetAs wrapper.
Definition: EncodingTraits.hpp:232
Utility structure used to enforce receiving given value via WSStream with encoding E.
Definition: EncodingTraits.hpp:214
Encoding
Definition: EncodingTraits.hpp:21
@ UTF8
Use WSGetUTF8String for reading and WSPutUTF8String for writing strings.
char type
static_assert will trigger compilation error, we add a dummy type to prevent further compiler errors
Definition: EncodingTraits.hpp:41
T & obj
A reference to which later a resulting value from WSTP function will be assigned.
Definition: EncodingTraits.hpp:223
std::basic_string< CharType< E > > type
Alias for the basic_string specialization which naturally corresponds to encoding E.
Definition: EncodingTraits.hpp:103
typename StringTypeStruct< E >::type StringType
Definition: EncodingTraits.hpp:113
@ UTF32
Use WSGetUTF32String for reading and WSPutUTF32String for writing strings.
@ UTF16
Use WSGetUTF16String for reading and WSPutUTF16String for writing strings.
Definition: EncodingTraits.hpp:38
constexpr bool CharacterTypesCompatible
Check whether character type T is compatible with encoding E (i.e.
Definition: EncodingTraits.hpp:92
GetAs(T &o)
Constructor that takes a reference to value of type T and stores it.
Definition: EncodingTraits.hpp:220
constexpr const char * getEncodingName(Encoding e)
Get the name of encoding.
Definition: EncodingTraits.hpp:120
Contains definitions related to WSTP functionality in LLU.
Definition: EncodingTraits.hpp:15
Definition: EncodingTraits.hpp:101
Utility structure used to enforce sending given value with encoding E via WSStream.
Definition: EncodingTraits.hpp:150
PutAs< E, T > putAs(T &&obj)
This is a helper function to facilitate constructing WS::PutAs wrapper.
Definition: EncodingTraits.hpp:192
@ UCS2
Use WSGetUCS2String for reading and WSPutUCS2String for writing strings.