]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/cpputils.h
2 ******************************************************************************
4 * Copyright (C) 1997-2011, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 * file name: cpputils.h
10 * tab size: 8 (not used)
17 #include "unicode/utypes.h"
18 #include "unicode/unistr.h"
21 /*==========================================================================*/
22 /* Array copy utility functions */
23 /*==========================================================================*/
26 inline void uprv_arrayCopy(const double* src
, double* dst
, int32_t count
)
27 { uprv_memcpy(dst
, src
, (size_t)(count
* sizeof(*src
))); }
30 inline void uprv_arrayCopy(const double* src
, int32_t srcStart
,
31 double* dst
, int32_t dstStart
, int32_t count
)
32 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)(count
* sizeof(*src
))); }
35 inline void uprv_arrayCopy(const int8_t* src
, int8_t* dst
, int32_t count
)
36 { uprv_memcpy(dst
, src
, (size_t)(count
* sizeof(*src
))); }
39 inline void uprv_arrayCopy(const int8_t* src
, int32_t srcStart
,
40 int8_t* dst
, int32_t dstStart
, int32_t count
)
41 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)(count
* sizeof(*src
))); }
44 inline void uprv_arrayCopy(const int16_t* src
, int16_t* dst
, int32_t count
)
45 { uprv_memcpy(dst
, src
, (size_t)(count
* sizeof(*src
))); }
48 inline void uprv_arrayCopy(const int16_t* src
, int32_t srcStart
,
49 int16_t* dst
, int32_t dstStart
, int32_t count
)
50 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)(count
* sizeof(*src
))); }
53 inline void uprv_arrayCopy(const int32_t* src
, int32_t* dst
, int32_t count
)
54 { uprv_memcpy(dst
, src
, (size_t)(count
* sizeof(*src
))); }
57 inline void uprv_arrayCopy(const int32_t* src
, int32_t srcStart
,
58 int32_t* dst
, int32_t dstStart
, int32_t count
)
59 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)(count
* sizeof(*src
))); }
63 uprv_arrayCopy(const UChar
*src
, int32_t srcStart
,
64 UChar
*dst
, int32_t dstStart
, int32_t count
)
65 { uprv_memcpy(dst
+dstStart
, src
+srcStart
, (size_t)(count
* sizeof(*src
))); }
68 * Copy an array of UnicodeString OBJECTS (not pointers).
72 uprv_arrayCopy(const icu::UnicodeString
*src
, icu::UnicodeString
*dst
, int32_t count
)
73 { while(count
-- > 0) *dst
++ = *src
++; }
76 * Copy an array of UnicodeString OBJECTS (not pointers).
80 uprv_arrayCopy(const icu::UnicodeString
*src
, int32_t srcStart
,
81 icu::UnicodeString
*dst
, int32_t dstStart
, int32_t count
)
82 { uprv_arrayCopy(src
+srcStart
, dst
+dstStart
, count
); }
85 * Checks that the string is readable and writable.
86 * Sets U_ILLEGAL_ARGUMENT_ERROR if the string isBogus() or has an open getBuffer().
89 uprv_checkCanGetBuffer(const icu::UnicodeString
&s
, UErrorCode
&errorCode
) {
90 if(U_SUCCESS(errorCode
) && s
.isBogus()) {
91 errorCode
=U_ILLEGAL_ARGUMENT_ERROR
;
95 #endif /* _CPPUTILS */