7 #ifndef __CHAR16PTR_H__ 8 #define __CHAR16PTR_H__ 12 #if U_SHOW_CPLUSPLUS_API 30 #ifdef U_ALIASING_BARRIER 32 #elif (defined(__clang__) || defined(__GNUC__)) && U_PLATFORM != U_PF_BROWSER_NATIVE_CLIENT 33 # define U_ALIASING_BARRIER(ptr) asm volatile("" : : "rm"(ptr) : "memory") 34 #elif defined(U_IN_DOXYGEN) 35 # define U_ALIASING_BARRIER(ptr) 50 #if !U_CHAR16_IS_TYPEDEF 58 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 84 inline char16_t *
get()
const;
90 inline operator char16_t *()
const {
return get(); }
95 #ifdef U_ALIASING_BARRIER 96 template<
typename T>
static char16_t *cast(T *t) {
98 return reinterpret_cast<char16_t *
>(t);
112 #ifdef U_ALIASING_BARRIER 114 Char16Ptr::Char16Ptr(char16_t *p) : p_(p) {}
115 #if !U_CHAR16_IS_TYPEDEF 116 Char16Ptr::Char16Ptr(uint16_t *p) : p_(cast(p)) {}
118 #if U_SIZEOF_WCHAR_T==2 119 Char16Ptr::Char16Ptr(
wchar_t *p) : p_(cast(p)) {}
121 Char16Ptr::Char16Ptr(std::nullptr_t p) : p_(p) {}
122 Char16Ptr::~Char16Ptr() {
126 char16_t *Char16Ptr::get()
const {
return p_; }
130 Char16Ptr::Char16Ptr(char16_t *p) { u_.cp = p; }
131 #if !U_CHAR16_IS_TYPEDEF 132 Char16Ptr::Char16Ptr(uint16_t *p) { u_.up = p; }
134 #if U_SIZEOF_WCHAR_T==2 135 Char16Ptr::Char16Ptr(
wchar_t *p) { u_.wp = p; }
137 Char16Ptr::Char16Ptr(std::nullptr_t p) { u_.cp = p; }
138 Char16Ptr::~Char16Ptr() {}
140 char16_t *Char16Ptr::get()
const {
return u_.cp; }
157 #if !U_CHAR16_IS_TYPEDEF 165 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 192 inline const char16_t *
get()
const;
198 inline operator const char16_t *()
const {
return get(); }
203 #ifdef U_ALIASING_BARRIER 204 template<
typename T>
static const char16_t *cast(
const T *t) {
206 return reinterpret_cast<const char16_t *
>(t);
220 #ifdef U_ALIASING_BARRIER 222 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) : p_(p) {}
223 #if !U_CHAR16_IS_TYPEDEF 224 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) : p_(cast(p)) {}
226 #if U_SIZEOF_WCHAR_T==2 227 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) : p_(cast(p)) {}
229 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) : p_(p) {}
230 ConstChar16Ptr::~ConstChar16Ptr() {
234 const char16_t *ConstChar16Ptr::get()
const {
return p_; }
238 ConstChar16Ptr::ConstChar16Ptr(
const char16_t *p) { u_.cp = p; }
239 #if !U_CHAR16_IS_TYPEDEF 240 ConstChar16Ptr::ConstChar16Ptr(
const uint16_t *p) { u_.up = p; }
242 #if U_SIZEOF_WCHAR_T==2 243 ConstChar16Ptr::ConstChar16Ptr(
const wchar_t *p) { u_.wp = p; }
245 ConstChar16Ptr::ConstChar16Ptr(
const std::nullptr_t p) { u_.cp = p; }
246 ConstChar16Ptr::~ConstChar16Ptr() {}
248 const char16_t *ConstChar16Ptr::get()
const {
return u_.cp; }
261 #ifdef U_ALIASING_BARRIER 264 return reinterpret_cast<const UChar *
>(p);
275 #ifdef U_ALIASING_BARRIER 278 return reinterpret_cast<UChar *
>(p);
289 #ifdef U_ALIASING_BARRIER 292 return reinterpret_cast<const OldUChar *
>(p);
303 #ifdef U_ALIASING_BARRIER 306 return reinterpret_cast<OldUChar *
>(p);
313 #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.
UChar * toUCharPtr(char16_t *p)
Converts from char16_t * to UChar *.
uint16_t UChar
The base type for UTF-16 code units and pointers.
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...