]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ****************************************************************************** | |
3 | * | |
4388f060 | 4 | * Copyright (C) 1997-2011, International Business Machines |
b75a7d8f A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ****************************************************************************** | |
8 | * file name: cpputils.h | |
9 | * encoding: US-ASCII | |
10 | * tab size: 8 (not used) | |
11 | * indentation:4 | |
12 | */ | |
13 | ||
14 | #ifndef CPPUTILS_H | |
15 | #define CPPUTILS_H | |
16 | ||
17 | #include "unicode/utypes.h" | |
73c04bcf | 18 | #include "unicode/unistr.h" |
b75a7d8f A |
19 | #include "cmemory.h" |
20 | ||
21 | /*==========================================================================*/ | |
22 | /* Array copy utility functions */ | |
23 | /*==========================================================================*/ | |
24 | ||
25 | static | |
26 | inline void uprv_arrayCopy(const double* src, double* dst, int32_t count) | |
a62d09fc | 27 | { uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
28 | |
29 | static | |
30 | inline void uprv_arrayCopy(const double* src, int32_t srcStart, | |
31 | double* dst, int32_t dstStart, int32_t count) | |
a62d09fc | 32 | { uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
33 | |
34 | static | |
35 | inline void uprv_arrayCopy(const int8_t* src, int8_t* dst, int32_t count) | |
a62d09fc | 36 | { uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
37 | |
38 | static | |
39 | inline void uprv_arrayCopy(const int8_t* src, int32_t srcStart, | |
40 | int8_t* dst, int32_t dstStart, int32_t count) | |
a62d09fc | 41 | { uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
42 | |
43 | static | |
44 | inline void uprv_arrayCopy(const int16_t* src, int16_t* dst, int32_t count) | |
a62d09fc | 45 | { uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
46 | |
47 | static | |
48 | inline void uprv_arrayCopy(const int16_t* src, int32_t srcStart, | |
49 | int16_t* dst, int32_t dstStart, int32_t count) | |
a62d09fc | 50 | { uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
51 | |
52 | static | |
53 | inline void uprv_arrayCopy(const int32_t* src, int32_t* dst, int32_t count) | |
a62d09fc | 54 | { uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
55 | |
56 | static | |
57 | inline void uprv_arrayCopy(const int32_t* src, int32_t srcStart, | |
58 | int32_t* dst, int32_t dstStart, int32_t count) | |
a62d09fc | 59 | { uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); } |
b75a7d8f A |
60 | |
61 | static | |
62 | inline void | |
63 | uprv_arrayCopy(const UChar *src, int32_t srcStart, | |
64 | UChar *dst, int32_t dstStart, int32_t count) | |
a62d09fc | 65 | { uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); } |
b75a7d8f | 66 | |
73c04bcf A |
67 | /** |
68 | * Copy an array of UnicodeString OBJECTS (not pointers). | |
69 | * @internal | |
70 | */ | |
71 | static inline void | |
4388f060 | 72 | uprv_arrayCopy(const icu::UnicodeString *src, icu::UnicodeString *dst, int32_t count) |
73c04bcf A |
73 | { while(count-- > 0) *dst++ = *src++; } |
74 | ||
75 | /** | |
76 | * Copy an array of UnicodeString OBJECTS (not pointers). | |
77 | * @internal | |
78 | */ | |
79 | static inline void | |
4388f060 A |
80 | uprv_arrayCopy(const icu::UnicodeString *src, int32_t srcStart, |
81 | icu::UnicodeString *dst, int32_t dstStart, int32_t count) | |
73c04bcf A |
82 | { uprv_arrayCopy(src+srcStart, dst+dstStart, count); } |
83 | ||
729e4ab9 A |
84 | /** |
85 | * Checks that the string is readable and writable. | |
86 | * Sets U_ILLEGAL_ARGUMENT_ERROR if the string isBogus() or has an open getBuffer(). | |
87 | */ | |
88 | inline void | |
4388f060 | 89 | uprv_checkCanGetBuffer(const icu::UnicodeString &s, UErrorCode &errorCode) { |
729e4ab9 A |
90 | if(U_SUCCESS(errorCode) && s.isBogus()) { |
91 | errorCode=U_ILLEGAL_ARGUMENT_ERROR; | |
92 | } | |
93 | } | |
94 | ||
b75a7d8f | 95 | #endif /* _CPPUTILS */ |