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")
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) {
94 U_ALIASING_BARRIER(t);
95 return reinterpret_cast<char16_t *
>(t);
108 #ifdef U_ALIASING_BARRIER
110 Char16Ptr::Char16Ptr(char16_t *p) : p_(p) {}
111 #if !U_CHAR16_IS_TYPEDEF
112 Char16Ptr::Char16Ptr(uint16_t *p) : p_(cast(p)) {}
114 #if U_SIZEOF_WCHAR_T==2
115 Char16Ptr::Char16Ptr(
wchar_t *p) : p_(cast(p)) {}
117 Char16Ptr::Char16Ptr(std::nullptr_t p) : p_(p) {}
119 U_ALIASING_BARRIER(p_);
126 Char16Ptr::Char16Ptr(char16_t *p) { u_.cp = p; }
127 #if !U_CHAR16_IS_TYPEDEF
128 Char16Ptr::Char16Ptr(uint16_t *p) { u_.up = p; }
130 #if U_SIZEOF_WCHAR_T==2
131 Char16Ptr::Char16Ptr(
wchar_t *p) { u_.wp = p; }
133 Char16Ptr::Char16Ptr(std::nullptr_t p) { u_.cp = p; }
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) {
202 U_ALIASING_BARRIER(t);
203 return reinterpret_cast<const char16_t *
>(t);
216 #ifdef U_ALIASING_BARRIER
218 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) : p_(p) {}
219 #if !U_CHAR16_IS_TYPEDEF
220 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) : p_(cast(p)) {}
222 #if U_SIZEOF_WCHAR_T==2
223 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) : p_(cast(p)) {}
225 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) : p_(p) {}
227 U_ALIASING_BARRIER(p_);
234 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) { u_.cp = p; }
235 #if !U_CHAR16_IS_TYPEDEF
236 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) { u_.up = p; }
238 #if U_SIZEOF_WCHAR_T==2
239 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) { u_.wp = p; }
241 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) { u_.cp = p; }
256 #ifdef U_ALIASING_BARRIER
257 U_ALIASING_BARRIER(p);
259 return reinterpret_cast<const UChar *
>(p);
270 #ifdef U_ALIASING_BARRIER
271 U_ALIASING_BARRIER(p);
273 return reinterpret_cast<UChar *
>(p);
284 #ifdef U_ALIASING_BARRIER
285 U_ALIASING_BARRIER(p);
287 return reinterpret_cast<const OldUChar *
>(p);
298 #ifdef U_ALIASING_BARRIER
299 U_ALIASING_BARRIER(p);
301 return reinterpret_cast<OldUChar *
>(p);
306 #endif // __CHAR16PTR_H__
uint16_t OldUChar
Default ICU 58 definition of UChar.
const OldUChar * toOldUCharPtr(const char16_t *p)
Converts from const char16_t * to const OldUChar *.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
const char16_t * get() const
Pointer access.
~ConstChar16Ptr()
Destructor.
const UChar * toUCharPtr(const char16_t *p)
Converts from const char16_t * to const 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...
Basic definitions for ICU, for both C and C++ APIs.
char16_t * get() const
Pointer access.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...