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