7 #ifndef __CHAR16PTR_H__ 8 #define __CHAR16PTR_H__ 27 #ifdef U_ALIASING_BARRIER 29 #elif (defined(__clang__) || defined(__GNUC__)) && U_PLATFORM != U_PF_BROWSER_NATIVE_CLIENT 30 # define U_ALIASING_BARRIER(ptr) asm volatile("" : : "rm"(ptr) : "memory") 31 #elif defined(U_IN_DOXYGEN) 32 # define U_ALIASING_BARRIER(ptr) 47 #if !U_CHAR16_IS_TYPEDEF 55 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 81 inline char16_t *
get()
const;
87 inline operator char16_t *()
const {
return get(); }
92 #ifdef U_ALIASING_BARRIER 93 template<
typename T>
static char16_t *cast(T *t) {
95 return reinterpret_cast<char16_t *
>(t);
109 #ifdef U_ALIASING_BARRIER 111 Char16Ptr::Char16Ptr(char16_t *p) : p_(p) {}
112 #if !U_CHAR16_IS_TYPEDEF 113 Char16Ptr::Char16Ptr(uint16_t *p) : p_(cast(p)) {}
115 #if U_SIZEOF_WCHAR_T==2 116 Char16Ptr::Char16Ptr(
wchar_t *p) : p_(cast(p)) {}
118 Char16Ptr::Char16Ptr(std::nullptr_t p) : p_(p) {}
119 Char16Ptr::~Char16Ptr() {
123 char16_t *Char16Ptr::get()
const {
return p_; }
127 Char16Ptr::Char16Ptr(char16_t *p) { u_.cp = p; }
128 #if !U_CHAR16_IS_TYPEDEF 129 Char16Ptr::Char16Ptr(uint16_t *p) { u_.up = p; }
131 #if U_SIZEOF_WCHAR_T==2 132 Char16Ptr::Char16Ptr(
wchar_t *p) { u_.wp = p; }
134 Char16Ptr::Char16Ptr(std::nullptr_t p) { u_.cp = p; }
135 Char16Ptr::~Char16Ptr() {}
137 char16_t *Char16Ptr::get()
const {
return u_.cp; }
154 #if !U_CHAR16_IS_TYPEDEF 162 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 189 inline const char16_t *
get()
const;
195 inline operator const char16_t *()
const {
return get(); }
200 #ifdef U_ALIASING_BARRIER 201 template<
typename T>
static const char16_t *cast(
const T *t) {
203 return reinterpret_cast<const char16_t *
>(t);
217 #ifdef U_ALIASING_BARRIER 219 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) : p_(p) {}
220 #if !U_CHAR16_IS_TYPEDEF 221 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) : p_(cast(p)) {}
223 #if U_SIZEOF_WCHAR_T==2 224 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) : p_(cast(p)) {}
226 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) : p_(p) {}
227 ConstChar16Ptr::~ConstChar16Ptr() {
231 const char16_t *ConstChar16Ptr::get()
const {
return p_; }
235 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) { u_.cp = p; }
236 #if !U_CHAR16_IS_TYPEDEF 237 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) { u_.up = p; }
239 #if U_SIZEOF_WCHAR_T==2 240 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) { u_.wp = p; }
242 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) { u_.cp = p; }
243 ConstChar16Ptr::~ConstChar16Ptr() {}
245 const char16_t *ConstChar16Ptr::get()
const {
return u_.cp; }
258 #ifdef U_ALIASING_BARRIER 261 return reinterpret_cast<const UChar *
>(p);
272 #ifdef U_ALIASING_BARRIER 275 return reinterpret_cast<UChar *
>(p);
286 #ifdef U_ALIASING_BARRIER 289 return reinterpret_cast<const OldUChar *
>(p);
300 #ifdef U_ALIASING_BARRIER 303 return reinterpret_cast<OldUChar *
>(p);
308 #endif // __CHAR16PTR_H__ uint16_t OldUChar
Default ICU 58 definition of UChar.
OldUChar * toOldUCharPtr(char16_t *p)
Converts from char16_t * to OldUChar *.
#define U_ALIASING_BARRIER(ptr)
Barrier for pointer anti-aliasing optimizations even across function boundaries.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
UChar * toUCharPtr(char16_t *p)
Converts from char16_t * to UChar *.
uint16_t UChar
The base type for UTF-16 code units and pointers.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types...
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types...
#define U_FINAL
Defined to the C++11 "final" keyword if available.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...