summaryrefslogtreecommitdiff
path: root/deps/node/deps/icu-small/source/common/bytesinkutil.h
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-04-03 15:43:32 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-04-03 15:45:57 +0200
commit71e285b94c7edaa43aa8115965cf5a36b8e0f80a (patch)
tree7d4aa9d0d5aff686b106cd5da72ba77960c4af43 /deps/node/deps/icu-small/source/common/bytesinkutil.h
parent7dadf9356b4f3f4137ce982ea5bb960283116e9a (diff)
downloadakono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.tar.gz
akono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.tar.bz2
akono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.zip
Node.js v11.13.0
Diffstat (limited to 'deps/node/deps/icu-small/source/common/bytesinkutil.h')
-rw-r--r--deps/node/deps/icu-small/source/common/bytesinkutil.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/deps/node/deps/icu-small/source/common/bytesinkutil.h b/deps/node/deps/icu-small/source/common/bytesinkutil.h
new file mode 100644
index 00000000..69e4cbcd
--- /dev/null
+++ b/deps/node/deps/icu-small/source/common/bytesinkutil.h
@@ -0,0 +1,83 @@
+// © 2017 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+// bytesinkutil.h
+// created: 2017sep14 Markus W. Scherer
+
+#include "unicode/utypes.h"
+#include "unicode/bytestream.h"
+#include "unicode/edits.h"
+#include "cmemory.h"
+#include "uassert.h"
+
+U_NAMESPACE_BEGIN
+
+class ByteSink;
+class CharString;
+class Edits;
+
+class U_COMMON_API ByteSinkUtil {
+public:
+ ByteSinkUtil() = delete; // all static
+
+ /** (length) bytes were mapped to valid (s16, s16Length). */
+ static UBool appendChange(int32_t length,
+ const char16_t *s16, int32_t s16Length,
+ ByteSink &sink, Edits *edits, UErrorCode &errorCode);
+
+ /** The bytes at [s, limit[ were mapped to valid (s16, s16Length). */
+ static UBool appendChange(const uint8_t *s, const uint8_t *limit,
+ const char16_t *s16, int32_t s16Length,
+ ByteSink &sink, Edits *edits, UErrorCode &errorCode);
+
+ /** (length) bytes were mapped/changed to valid code point c. */
+ static void appendCodePoint(int32_t length, UChar32 c, ByteSink &sink, Edits *edits = nullptr);
+
+ /** The few bytes at [src, nextSrc[ were mapped/changed to valid code point c. */
+ static inline void appendCodePoint(const uint8_t *src, const uint8_t *nextSrc, UChar32 c,
+ ByteSink &sink, Edits *edits = nullptr) {
+ appendCodePoint((int32_t)(nextSrc - src), c, sink, edits);
+ }
+
+ /** Append the two-byte character (U+0080..U+07FF). */
+ static void appendTwoBytes(UChar32 c, ByteSink &sink);
+
+ static UBool appendUnchanged(const uint8_t *s, int32_t length,
+ ByteSink &sink, uint32_t options, Edits *edits,
+ UErrorCode &errorCode) {
+ if (U_FAILURE(errorCode)) { return FALSE; }
+ if (length > 0) { appendNonEmptyUnchanged(s, length, sink, options, edits); }
+ return TRUE;
+ }
+
+ static UBool appendUnchanged(const uint8_t *s, const uint8_t *limit,
+ ByteSink &sink, uint32_t options, Edits *edits,
+ UErrorCode &errorCode);
+
+private:
+ static void appendNonEmptyUnchanged(const uint8_t *s, int32_t length,
+ ByteSink &sink, uint32_t options, Edits *edits);
+};
+
+class CharStringByteSink : public ByteSink {
+public:
+ CharStringByteSink(CharString* dest);
+ ~CharStringByteSink() override;
+
+ CharStringByteSink() = delete;
+ CharStringByteSink(const CharStringByteSink&) = delete;
+ CharStringByteSink& operator=(const CharStringByteSink&) = delete;
+
+ void Append(const char* bytes, int32_t n) override;
+
+ char* GetAppendBuffer(int32_t min_capacity,
+ int32_t desired_capacity_hint,
+ char* scratch,
+ int32_t scratch_capacity,
+ int32_t* result_capacity) override;
+
+private:
+ CharString& dest_;
+};
+
+U_NAMESPACE_END