Nui
Loading...
Searching...
No Matches
type_encodings.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "mac_includes.hpp"
4
5#include <string>
6#include <vector>
7#include <tuple>
8
9namespace Nui::MacOs
10{
11 template <typename T>
13
14#define NUI_TYPE_ENCODING_SPECIALIZATION(type, encodingString) \
15 template <> \
16 struct TypeEncoding<type> \
17 { \
18 static std::string encoding() noexcept \
19 { \
20 return encodingString; \
21 } \
22 };
23
25 NUI_TYPE_ENCODING_SPECIALIZATION(unsigned char, "C")
27 NUI_TYPE_ENCODING_SPECIALIZATION(unsigned short, "S")
29 NUI_TYPE_ENCODING_SPECIALIZATION(unsigned int, "I")
31 NUI_TYPE_ENCODING_SPECIALIZATION(unsigned long, "L")
33 NUI_TYPE_ENCODING_SPECIALIZATION(unsigned long long, "Q")
38 NUI_TYPE_ENCODING_SPECIALIZATION(const char*, "*")
40
41 template <typename T>
42 struct TypeEncoding<T*>
43 {
44 static std::string encoding()
45 {
46 return "^" + TypeEncoding<T>::encoding();
47 }
48 };
49
50 template <>
51 struct TypeEncoding<id>
52 {
53 static std::string encoding()
54 {
55 return "@";
56 }
57 };
58
59 template <>
60 struct TypeEncoding<Class>
61 {
62 static std::string encoding()
63 {
64 return "#";
65 }
66 };
67
68 template <>
69 struct TypeEncoding<SEL>
70 {
71 static std::string encoding()
72 {
73 return ":";
74 }
75 };
76
77 template <typename T>
78 struct TypeEncoding<std::vector<T>>
79 {
80 static std::string encoding()
81 {
82 return "[" + TypeEncoding<T>::encoding() + "]";
83 }
84 };
85
86 template <typename... T>
87 struct TypeEncoding<std::tuple<T...>>
88 {
89 static std::string encoding()
90 {
91 return "(" + (TypeEncoding<T>::encoding() + ...) + ")";
92 }
93 };
94
95 template <typename ReturnT, typename... Args>
96 struct TypeEncoding<ReturnT(Args...)>
97 {
98 static std::string encoding()
99 {
101 }
102 };
103 template <typename ReturnT, typename... Args>
104 struct TypeEncoding<ReturnT (*)(Args...)>
105 {
106 static std::string encoding()
107 {
108 return TypeEncoding<ReturnT(Args...)>::encoding();
109 }
110 };
111
112 template <typename T>
114 {
116 }
117}
Definition class.hpp:7
auto encodeType()
Definition type_encodings.hpp:113
static std::string encoding()
Definition type_encodings.hpp:62
static std::string encoding()
Definition type_encodings.hpp:98
static std::string encoding()
Definition type_encodings.hpp:106
static std::string encoding()
Definition type_encodings.hpp:71
static std::string encoding()
Definition type_encodings.hpp:44
static std::string encoding()
Definition type_encodings.hpp:53
static std::string encoding()
Definition type_encodings.hpp:89
static std::string encoding()
Definition type_encodings.hpp:80
Definition type_encodings.hpp:12
#define NUI_TYPE_ENCODING_SPECIALIZATION(type, encodingString)
Definition type_encodings.hpp:14