]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/cpputils.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 1997-2011, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 ******************************************************************************
10 * file name: cpputils.h
12 * tab size: 8 (not used)
19 #include "unicode/utypes.h"
20 #include "unicode/unistr.h"
23 /*==========================================================================*/
24 /* Array copy utility functions */
25 /*==========================================================================*/
28 inline void uprv_arrayCopy(const double* src
, double* dst
, int32_t count
)
29 { uprv_memcpy(dst
, src
, (size_t)count
* sizeof(*src
)); }
32 inline void uprv_arrayCopy(const double* src
, int32_t srcStart
,
33 double* dst
, int32_t dstStart
, int32_t count
)
34 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)count
* sizeof(*src
)); }
37 inline void uprv_arrayCopy(const int8_t* src
, int8_t* dst
, int32_t count
)
38 { uprv_memcpy(dst
, src
, (size_t)count
* sizeof(*src
)); }
41 inline void uprv_arrayCopy(const int8_t* src
, int32_t srcStart
,
42 int8_t* dst
, int32_t dstStart
, int32_t count
)
43 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)count
* sizeof(*src
)); }
46 inline void uprv_arrayCopy(const int16_t* src
, int16_t* dst
, int32_t count
)
47 { uprv_memcpy(dst
, src
, (size_t)count
* sizeof(*src
)); }
50 inline void uprv_arrayCopy(const int16_t* src
, int32_t srcStart
,
51 int16_t* dst
, int32_t dstStart
, int32_t count
)
52 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)count
* sizeof(*src
)); }
55 inline void uprv_arrayCopy(const int32_t* src
, int32_t* dst
, int32_t count
)
56 { uprv_memcpy(dst
, src
, (size_t)count
* sizeof(*src
)); }
59 inline void uprv_arrayCopy(const int32_t* src
, int32_t srcStart
,
60 int32_t* dst
, int32_t dstStart
, int32_t count
)
61 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)count
* sizeof(*src
)); }
65 uprv_arrayCopy(const UChar
*src
, int32_t srcStart
,
66 UChar
*dst
, int32_t dstStart
, int32_t count
)
67 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)count
* sizeof(*src
)); }
70 * Copy an array of UnicodeString OBJECTS (not pointers).
74 uprv_arrayCopy(const icu::UnicodeString
*src
, icu::UnicodeString
*dst
, int32_t count
)
75 { while(count
-- > 0) *dst
++ = *src
++; }
78 * Copy an array of UnicodeString OBJECTS (not pointers).
82 uprv_arrayCopy(const icu::UnicodeString
*src
, int32_t srcStart
,
83 icu::UnicodeString
*dst
, int32_t dstStart
, int32_t count
)
84 { uprv_arrayCopy(src
+srcStart
, dst
+dstStart
, count
); }
87 * Checks that the string is readable and writable.
88 * Sets U_ILLEGAL_ARGUMENT_ERROR if the string isBogus() or has an open getBuffer().
91 uprv_checkCanGetBuffer(const icu::UnicodeString
&s
, UErrorCode
&errorCode
) {
92 if(U_SUCCESS(errorCode
) && s
.isBogus()) {
93 errorCode
=U_ILLEGAL_ARGUMENT_ERROR
;
97 #endif /* _CPPUTILS */