godot/thirdparty/icu4c/common/uiter.cpp

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
*   Copyright (C) 2002-2012, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
*******************************************************************************
*   file name:  uiter.cpp
*   encoding:   UTF-8
*   tab size:   8 (not used)
*   indentation:4
*
*   created on: 2002jan18
*   created by: Markus W. Scherer
*/

#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "unicode/chariter.h"
#include "unicode/rep.h"
#include "unicode/uiter.h"
#include "unicode/utf.h"
#include "unicode/utf8.h"
#include "unicode/utf16.h"
#include "cstring.h"

U_NAMESPACE_USE

#define IS_EVEN(n)
#define IS_POINTER_EVEN(p)

U_CDECL_BEGIN

/* No-Op UCharIterator implementation for illegal input --------------------- */

static int32_t U_CALLCONV
noopGetIndex(UCharIterator * /*iter*/, UCharIteratorOrigin /*origin*/) {}

static int32_t U_CALLCONV
noopMove(UCharIterator * /*iter*/, int32_t /*delta*/, UCharIteratorOrigin /*origin*/) {}

static UBool U_CALLCONV
noopHasNext(UCharIterator * /*iter*/) {}

static UChar32 U_CALLCONV
noopCurrent(UCharIterator * /*iter*/) {}

static uint32_t U_CALLCONV
noopGetState(const UCharIterator * /*iter*/) {}

static void U_CALLCONV
noopSetState(UCharIterator * /*iter*/, uint32_t /*state*/, UErrorCode *pErrorCode) {}

static const UCharIterator noopIterator=;

/* UCharIterator implementation for simple strings -------------------------- */

/*
 * This is an implementation of a code unit (char16_t) iterator
 * for char16_t * strings.
 *
 * The UCharIterator.context field holds a pointer to the string.
 */

static int32_t U_CALLCONV
stringIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static int32_t U_CALLCONV
stringIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static UBool U_CALLCONV
stringIteratorHasNext(UCharIterator *iter) {}

static UBool U_CALLCONV
stringIteratorHasPrevious(UCharIterator *iter) {}

static UChar32 U_CALLCONV
stringIteratorCurrent(UCharIterator *iter) {}

static UChar32 U_CALLCONV
stringIteratorNext(UCharIterator *iter) {}

static UChar32 U_CALLCONV
stringIteratorPrevious(UCharIterator *iter) {}

static uint32_t U_CALLCONV
stringIteratorGetState(const UCharIterator *iter) {}

static void U_CALLCONV
stringIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {}

static const UCharIterator stringIterator=;

U_CAPI void U_EXPORT2
uiter_setString(UCharIterator *iter, const char16_t *s, int32_t length) {}

/* UCharIterator implementation for UTF-16BE strings ------------------------ */

/*
 * This is an implementation of a code unit (char16_t) iterator
 * for UTF-16BE strings, i.e., strings in byte-vectors where
 * each char16_t is stored as a big-endian pair of bytes.
 *
 * The UCharIterator.context field holds a pointer to the string.
 * Everything works just like with a normal char16_t iterator (uiter_setString),
 * except that UChars are assembled from byte pairs.
 */

/* internal helper function */
static inline UChar32
utf16BEIteratorGet(UCharIterator *iter, int32_t index) {}

static UChar32 U_CALLCONV
utf16BEIteratorCurrent(UCharIterator *iter) {}

static UChar32 U_CALLCONV
utf16BEIteratorNext(UCharIterator *iter) {}

static UChar32 U_CALLCONV
utf16BEIteratorPrevious(UCharIterator *iter) {}

static const UCharIterator utf16BEIterator=;

/*
 * Count the number of UChars in a UTF-16BE string before a terminating char16_t NUL,
 * i.e., before a pair of 0 bytes where the first 0 byte is at an even
 * offset from s.
 */
static int32_t
utf16BE_strlen(const char *s) {}

U_CAPI void U_EXPORT2
uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length) {}

/* UCharIterator wrapper around CharacterIterator --------------------------- */

/*
 * This is wrapper code around a C++ CharacterIterator to
 * look like a C UCharIterator.
 *
 * The UCharIterator.context field holds a pointer to the CharacterIterator.
 */

static int32_t U_CALLCONV
characterIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static int32_t U_CALLCONV
characterIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static UBool U_CALLCONV
characterIteratorHasNext(UCharIterator *iter) {}

static UBool U_CALLCONV
characterIteratorHasPrevious(UCharIterator *iter) {}

static UChar32 U_CALLCONV
characterIteratorCurrent(UCharIterator *iter) {}

static UChar32 U_CALLCONV
characterIteratorNext(UCharIterator *iter) {}

static UChar32 U_CALLCONV
characterIteratorPrevious(UCharIterator *iter) {}

static uint32_t U_CALLCONV
characterIteratorGetState(const UCharIterator *iter) {}

static void U_CALLCONV
characterIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {}

static const UCharIterator characterIteratorWrapper=;

U_CAPI void U_EXPORT2
uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter) {}

/* UCharIterator wrapper around Replaceable --------------------------------- */

/*
 * This is an implementation of a code unit (char16_t) iterator
 * based on a Replaceable object.
 *
 * The UCharIterator.context field holds a pointer to the Replaceable.
 * UCharIterator.length and UCharIterator.index hold Replaceable.length()
 * and the iteration index.
 */

static UChar32 U_CALLCONV
replaceableIteratorCurrent(UCharIterator *iter) {}

static UChar32 U_CALLCONV
replaceableIteratorNext(UCharIterator *iter) {}

static UChar32 U_CALLCONV
replaceableIteratorPrevious(UCharIterator *iter) {}

static const UCharIterator replaceableIterator=;

U_CAPI void U_EXPORT2
uiter_setReplaceable(UCharIterator *iter, const Replaceable *rep) {}

/* UCharIterator implementation for UTF-8 strings --------------------------- */

/*
 * Possible, probably necessary only for an implementation for arbitrary
 * converters:
 * Maintain a buffer (ring buffer?) for a piece of converted 16-bit text.
 * This would require to turn reservedFn into a close function and
 * to introduce a uiter_close(iter).
 */

#define UITER_CNV_CAPACITY

/*
 * Minimal implementation:
 * Maintain a single-char16_t buffer for an additional surrogate.
 * The caller must not modify start and limit because they are used internally.
 *
 * Use UCharIterator fields as follows:
 *   context        pointer to UTF-8 string
 *   length         UTF-16 length of the string; -1 until lazy evaluation
 *   start          current UTF-8 index
 *   index          current UTF-16 index; may be -1="unknown" after setState()
 *   limit          UTF-8 length of the string
 *   reservedField  supplementary code point
 *
 * Since UCharIterator delivers 16-bit code units, the iteration can be
 * currently in the middle of the byte sequence for a supplementary code point.
 * In this case, reservedField will contain that code point and start will
 * point to after the corresponding byte sequence. The UTF-16 index will be
 * one less than what it would otherwise be corresponding to the UTF-8 index.
 * Otherwise, reservedField will be 0.
 */

/*
 * Possible optimization for NUL-terminated UTF-8 and UTF-16 strings:
 * Add implementations that do not call strlen() for iteration but check for NUL.
 */

static int32_t U_CALLCONV
utf8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static int32_t U_CALLCONV
utf8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) UPRV_NO_SANITIZE_UNDEFINED {}

static UBool U_CALLCONV
utf8IteratorHasNext(UCharIterator *iter) {}

static UBool U_CALLCONV
utf8IteratorHasPrevious(UCharIterator *iter) {}

static UChar32 U_CALLCONV
utf8IteratorCurrent(UCharIterator *iter) {}

static UChar32 U_CALLCONV
utf8IteratorNext(UCharIterator *iter) {}

static UChar32 U_CALLCONV
utf8IteratorPrevious(UCharIterator *iter) {}

static uint32_t U_CALLCONV
utf8IteratorGetState(const UCharIterator *iter) {}

static void U_CALLCONV
utf8IteratorSetState(UCharIterator *iter,
                     uint32_t state,
                     UErrorCode *pErrorCode)
{}

static const UCharIterator utf8Iterator=;

U_CAPI void U_EXPORT2
uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length) {}

/* Helper functions --------------------------------------------------------- */

U_CAPI UChar32 U_EXPORT2
uiter_current32(UCharIterator *iter) {}

U_CAPI UChar32 U_EXPORT2
uiter_next32(UCharIterator *iter) {}

U_CAPI UChar32 U_EXPORT2
uiter_previous32(UCharIterator *iter) {}

U_CAPI uint32_t U_EXPORT2
uiter_getState(const UCharIterator *iter) {}

U_CAPI void U_EXPORT2
uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {}

U_CDECL_END