aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/include/unicode/bytestream.h
diff options
context:
space:
mode:
authorneksard <neksard@yandex-team.ru>2022-02-10 16:45:23 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:23 +0300
commit8f7cf138264e0caa318144bf8a2c950e0b0a8593 (patch)
tree83bf5c8c8047c42d8475e6095df90ccdc3d1b57f /contrib/libs/icu/include/unicode/bytestream.h
parentd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (diff)
downloadydb-8f7cf138264e0caa318144bf8a2c950e0b0a8593.tar.gz
Restoring authorship annotation for <neksard@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/include/unicode/bytestream.h')
-rw-r--r--contrib/libs/icu/include/unicode/bytestream.h492
1 files changed, 246 insertions, 246 deletions
diff --git a/contrib/libs/icu/include/unicode/bytestream.h b/contrib/libs/icu/include/unicode/bytestream.h
index 7fe2406222..c8a1817d09 100644
--- a/contrib/libs/icu/include/unicode/bytestream.h
+++ b/contrib/libs/icu/include/unicode/bytestream.h
@@ -1,78 +1,78 @@
// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-// Copyright (C) 2009-2012, International Business Machines
-// Corporation and others. All Rights Reserved.
-//
-// Copyright 2007 Google Inc. All Rights Reserved.
-// Author: sanjay@google.com (Sanjay Ghemawat)
-//
-// Abstract interface that consumes a sequence of bytes (ByteSink).
-//
-// Used so that we can write a single piece of code that can operate
-// on a variety of output string types.
-//
-// Various implementations of this interface are provided:
-// ByteSink:
-// CheckedArrayByteSink Write to a flat array, with bounds checking
-// StringByteSink Write to an STL string
-
-// This code is a contribution of Google code, and the style used here is
-// a compromise between the original Google code and the ICU coding guidelines.
-// For example, data types are ICU-ified (size_t,int->int32_t),
-// and API comments doxygen-ified, but function names and behavior are
-// as in the original, if possible.
-// Assertion-style error handling, not available in ICU, was changed to
-// parameter "pinning" similar to UnicodeString.
-//
-// In addition, this is only a partial port of the original Google code,
-// limited to what was needed so far. The (nearly) complete original code
-// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib
-// (see ICU ticket 6765, r25517).
-
-#ifndef __BYTESTREAM_H__
-#define __BYTESTREAM_H__
-
-/**
- * \file
- * \brief C++ API: Interface for writing bytes, and implementation classes.
- */
-
-#include "unicode/utypes.h"
+// License & terms of use: http://www.unicode.org/copyright.html
+// Copyright (C) 2009-2012, International Business Machines
+// Corporation and others. All Rights Reserved.
+//
+// Copyright 2007 Google Inc. All Rights Reserved.
+// Author: sanjay@google.com (Sanjay Ghemawat)
+//
+// Abstract interface that consumes a sequence of bytes (ByteSink).
+//
+// Used so that we can write a single piece of code that can operate
+// on a variety of output string types.
+//
+// Various implementations of this interface are provided:
+// ByteSink:
+// CheckedArrayByteSink Write to a flat array, with bounds checking
+// StringByteSink Write to an STL string
+
+// This code is a contribution of Google code, and the style used here is
+// a compromise between the original Google code and the ICU coding guidelines.
+// For example, data types are ICU-ified (size_t,int->int32_t),
+// and API comments doxygen-ified, but function names and behavior are
+// as in the original, if possible.
+// Assertion-style error handling, not available in ICU, was changed to
+// parameter "pinning" similar to UnicodeString.
+//
+// In addition, this is only a partial port of the original Google code,
+// limited to what was needed so far. The (nearly) complete original code
+// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib
+// (see ICU ticket 6765, r25517).
+
+#ifndef __BYTESTREAM_H__
+#define __BYTESTREAM_H__
+
+/**
+ * \file
+ * \brief C++ API: Interface for writing bytes, and implementation classes.
+ */
+
+#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
-#include "unicode/uobject.h"
-#include "unicode/std_string.h"
-
-U_NAMESPACE_BEGIN
-
-/**
- * A ByteSink can be filled with bytes.
- * @stable ICU 4.2
- */
-class U_COMMON_API ByteSink : public UMemory {
-public:
- /**
- * Default constructor.
- * @stable ICU 4.2
- */
- ByteSink() { }
- /**
- * Virtual destructor.
- * @stable ICU 4.2
- */
- virtual ~ByteSink();
-
- /**
- * Append "bytes[0,n-1]" to this.
- * @param bytes the pointer to the bytes
- * @param n the number of bytes; must be non-negative
- * @stable ICU 4.2
- */
- virtual void Append(const char* bytes, int32_t n) = 0;
-
+#include "unicode/uobject.h"
+#include "unicode/std_string.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * A ByteSink can be filled with bytes.
+ * @stable ICU 4.2
+ */
+class U_COMMON_API ByteSink : public UMemory {
+public:
+ /**
+ * Default constructor.
+ * @stable ICU 4.2
+ */
+ ByteSink() { }
+ /**
+ * Virtual destructor.
+ * @stable ICU 4.2
+ */
+ virtual ~ByteSink();
+
+ /**
+ * Append "bytes[0,n-1]" to this.
+ * @param bytes the pointer to the bytes
+ * @param n the number of bytes; must be non-negative
+ * @stable ICU 4.2
+ */
+ virtual void Append(const char* bytes, int32_t n) = 0;
+
#ifndef U_HIDE_DRAFT_API
- /**
+ /**
* Appends n bytes to this. Same as Append().
* Call AppendU8() with u8"string literals" which are const char * in C++11
* but const char8_t * in C++20.
@@ -106,175 +106,175 @@ public:
#endif // U_HIDE_DRAFT_API
/**
- * Returns a writable buffer for appending and writes the buffer's capacity to
- * *result_capacity. Guarantees *result_capacity>=min_capacity.
- * May return a pointer to the caller-owned scratch buffer which must have
- * scratch_capacity>=min_capacity.
- * The returned buffer is only valid until the next operation
- * on this ByteSink.
- *
- * After writing at most *result_capacity bytes, call Append() with the
- * pointer returned from this function and the number of bytes written.
- * Many Append() implementations will avoid copying bytes if this function
- * returned an internal buffer.
- *
- * Partial usage example:
- * int32_t capacity;
- * char* buffer = sink->GetAppendBuffer(..., &capacity);
- * ... Write n bytes into buffer, with n <= capacity.
- * sink->Append(buffer, n);
- * In many implementations, that call to Append will avoid copying bytes.
- *
- * If the ByteSink allocates or reallocates an internal buffer, it should use
- * the desired_capacity_hint if appropriate.
- * If a caller cannot provide a reasonable guess at the desired capacity,
- * it should pass desired_capacity_hint=0.
- *
- * If a non-scratch buffer is returned, the caller may only pass
- * a prefix to it to Append().
- * That is, it is not correct to pass an interior pointer to Append().
- *
- * The default implementation always returns the scratch buffer.
- *
- * @param min_capacity required minimum capacity of the returned buffer;
- * must be non-negative
- * @param desired_capacity_hint desired capacity of the returned buffer;
- * must be non-negative
- * @param scratch default caller-owned buffer
- * @param scratch_capacity capacity of the scratch buffer
- * @param result_capacity pointer to an integer which will be set to the
- * capacity of the returned buffer
- * @return a buffer with *result_capacity>=min_capacity
- * @stable ICU 4.2
- */
- virtual char* GetAppendBuffer(int32_t min_capacity,
- int32_t desired_capacity_hint,
- char* scratch, int32_t scratch_capacity,
- int32_t* result_capacity);
-
- /**
- * Flush internal buffers.
- * Some byte sinks use internal buffers or provide buffering
- * and require calling Flush() at the end of the stream.
- * The ByteSink should be ready for further Append() calls after Flush().
- * The default implementation of Flush() does nothing.
- * @stable ICU 4.2
- */
- virtual void Flush();
-
-private:
+ * Returns a writable buffer for appending and writes the buffer's capacity to
+ * *result_capacity. Guarantees *result_capacity>=min_capacity.
+ * May return a pointer to the caller-owned scratch buffer which must have
+ * scratch_capacity>=min_capacity.
+ * The returned buffer is only valid until the next operation
+ * on this ByteSink.
+ *
+ * After writing at most *result_capacity bytes, call Append() with the
+ * pointer returned from this function and the number of bytes written.
+ * Many Append() implementations will avoid copying bytes if this function
+ * returned an internal buffer.
+ *
+ * Partial usage example:
+ * int32_t capacity;
+ * char* buffer = sink->GetAppendBuffer(..., &capacity);
+ * ... Write n bytes into buffer, with n <= capacity.
+ * sink->Append(buffer, n);
+ * In many implementations, that call to Append will avoid copying bytes.
+ *
+ * If the ByteSink allocates or reallocates an internal buffer, it should use
+ * the desired_capacity_hint if appropriate.
+ * If a caller cannot provide a reasonable guess at the desired capacity,
+ * it should pass desired_capacity_hint=0.
+ *
+ * If a non-scratch buffer is returned, the caller may only pass
+ * a prefix to it to Append().
+ * That is, it is not correct to pass an interior pointer to Append().
+ *
+ * The default implementation always returns the scratch buffer.
+ *
+ * @param min_capacity required minimum capacity of the returned buffer;
+ * must be non-negative
+ * @param desired_capacity_hint desired capacity of the returned buffer;
+ * must be non-negative
+ * @param scratch default caller-owned buffer
+ * @param scratch_capacity capacity of the scratch buffer
+ * @param result_capacity pointer to an integer which will be set to the
+ * capacity of the returned buffer
+ * @return a buffer with *result_capacity>=min_capacity
+ * @stable ICU 4.2
+ */
+ virtual char* GetAppendBuffer(int32_t min_capacity,
+ int32_t desired_capacity_hint,
+ char* scratch, int32_t scratch_capacity,
+ int32_t* result_capacity);
+
+ /**
+ * Flush internal buffers.
+ * Some byte sinks use internal buffers or provide buffering
+ * and require calling Flush() at the end of the stream.
+ * The ByteSink should be ready for further Append() calls after Flush().
+ * The default implementation of Flush() does nothing.
+ * @stable ICU 4.2
+ */
+ virtual void Flush();
+
+private:
ByteSink(const ByteSink &) = delete;
ByteSink &operator=(const ByteSink &) = delete;
-};
-
-// -------------------------------------------------------------
-// Some standard implementations
-
-/**
- * Implementation of ByteSink that writes to a flat byte array,
- * with bounds-checking:
- * This sink will not write more than capacity bytes to outbuf.
- * If more than capacity bytes are Append()ed, then excess bytes are ignored,
- * and Overflowed() will return true.
- * Overflow does not cause a runtime error.
- * @stable ICU 4.2
- */
-class U_COMMON_API CheckedArrayByteSink : public ByteSink {
-public:
- /**
- * Constructs a ByteSink that will write to outbuf[0..capacity-1].
- * @param outbuf buffer to write to
- * @param capacity size of the buffer
- * @stable ICU 4.2
- */
- CheckedArrayByteSink(char* outbuf, int32_t capacity);
- /**
- * Destructor.
- * @stable ICU 4.2
- */
- virtual ~CheckedArrayByteSink();
- /**
- * Returns the sink to its original state, without modifying the buffer.
- * Useful for reusing both the buffer and the sink for multiple streams.
- * Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
- * and Overflowed()=FALSE.
- * @return *this
- * @stable ICU 4.6
- */
- virtual CheckedArrayByteSink& Reset();
- /**
- * Append "bytes[0,n-1]" to this.
- * @param bytes the pointer to the bytes
- * @param n the number of bytes; must be non-negative
- * @stable ICU 4.2
- */
- virtual void Append(const char* bytes, int32_t n);
- /**
- * Returns a writable buffer for appending and writes the buffer's capacity to
- * *result_capacity. For details see the base class documentation.
- * @param min_capacity required minimum capacity of the returned buffer;
- * must be non-negative
- * @param desired_capacity_hint desired capacity of the returned buffer;
- * must be non-negative
- * @param scratch default caller-owned buffer
- * @param scratch_capacity capacity of the scratch buffer
- * @param result_capacity pointer to an integer which will be set to the
- * capacity of the returned buffer
- * @return a buffer with *result_capacity>=min_capacity
- * @stable ICU 4.2
- */
- virtual char* GetAppendBuffer(int32_t min_capacity,
- int32_t desired_capacity_hint,
- char* scratch, int32_t scratch_capacity,
- int32_t* result_capacity);
- /**
- * Returns the number of bytes actually written to the sink.
- * @return number of bytes written to the buffer
- * @stable ICU 4.2
- */
- int32_t NumberOfBytesWritten() const { return size_; }
- /**
- * Returns true if any bytes were discarded, i.e., if there was an
- * attempt to write more than 'capacity' bytes.
- * @return TRUE if more than 'capacity' bytes were Append()ed
- * @stable ICU 4.2
- */
- UBool Overflowed() const { return overflowed_; }
- /**
- * Returns the number of bytes appended to the sink.
- * If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()
- * else they return the same number.
- * @return number of bytes written to the buffer
- * @stable ICU 4.6
- */
- int32_t NumberOfBytesAppended() const { return appended_; }
-private:
- char* outbuf_;
- const int32_t capacity_;
- int32_t size_;
- int32_t appended_;
- UBool overflowed_;
+};
+
+// -------------------------------------------------------------
+// Some standard implementations
+
+/**
+ * Implementation of ByteSink that writes to a flat byte array,
+ * with bounds-checking:
+ * This sink will not write more than capacity bytes to outbuf.
+ * If more than capacity bytes are Append()ed, then excess bytes are ignored,
+ * and Overflowed() will return true.
+ * Overflow does not cause a runtime error.
+ * @stable ICU 4.2
+ */
+class U_COMMON_API CheckedArrayByteSink : public ByteSink {
+public:
+ /**
+ * Constructs a ByteSink that will write to outbuf[0..capacity-1].
+ * @param outbuf buffer to write to
+ * @param capacity size of the buffer
+ * @stable ICU 4.2
+ */
+ CheckedArrayByteSink(char* outbuf, int32_t capacity);
+ /**
+ * Destructor.
+ * @stable ICU 4.2
+ */
+ virtual ~CheckedArrayByteSink();
+ /**
+ * Returns the sink to its original state, without modifying the buffer.
+ * Useful for reusing both the buffer and the sink for multiple streams.
+ * Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
+ * and Overflowed()=FALSE.
+ * @return *this
+ * @stable ICU 4.6
+ */
+ virtual CheckedArrayByteSink& Reset();
+ /**
+ * Append "bytes[0,n-1]" to this.
+ * @param bytes the pointer to the bytes
+ * @param n the number of bytes; must be non-negative
+ * @stable ICU 4.2
+ */
+ virtual void Append(const char* bytes, int32_t n);
+ /**
+ * Returns a writable buffer for appending and writes the buffer's capacity to
+ * *result_capacity. For details see the base class documentation.
+ * @param min_capacity required minimum capacity of the returned buffer;
+ * must be non-negative
+ * @param desired_capacity_hint desired capacity of the returned buffer;
+ * must be non-negative
+ * @param scratch default caller-owned buffer
+ * @param scratch_capacity capacity of the scratch buffer
+ * @param result_capacity pointer to an integer which will be set to the
+ * capacity of the returned buffer
+ * @return a buffer with *result_capacity>=min_capacity
+ * @stable ICU 4.2
+ */
+ virtual char* GetAppendBuffer(int32_t min_capacity,
+ int32_t desired_capacity_hint,
+ char* scratch, int32_t scratch_capacity,
+ int32_t* result_capacity);
+ /**
+ * Returns the number of bytes actually written to the sink.
+ * @return number of bytes written to the buffer
+ * @stable ICU 4.2
+ */
+ int32_t NumberOfBytesWritten() const { return size_; }
+ /**
+ * Returns true if any bytes were discarded, i.e., if there was an
+ * attempt to write more than 'capacity' bytes.
+ * @return TRUE if more than 'capacity' bytes were Append()ed
+ * @stable ICU 4.2
+ */
+ UBool Overflowed() const { return overflowed_; }
+ /**
+ * Returns the number of bytes appended to the sink.
+ * If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()
+ * else they return the same number.
+ * @return number of bytes written to the buffer
+ * @stable ICU 4.6
+ */
+ int32_t NumberOfBytesAppended() const { return appended_; }
+private:
+ char* outbuf_;
+ const int32_t capacity_;
+ int32_t size_;
+ int32_t appended_;
+ UBool overflowed_;
CheckedArrayByteSink() = delete;
CheckedArrayByteSink(const CheckedArrayByteSink &) = delete;
CheckedArrayByteSink &operator=(const CheckedArrayByteSink &) = delete;
-};
-
-/**
- * Implementation of ByteSink that writes to a "string".
- * The StringClass is usually instantiated with a std::string.
- * @stable ICU 4.2
- */
-template<typename StringClass>
-class StringByteSink : public ByteSink {
- public:
- /**
- * Constructs a ByteSink that will append bytes to the dest string.
- * @param dest pointer to string object to append to
- * @stable ICU 4.2
- */
- StringByteSink(StringClass* dest) : dest_(dest) { }
- /**
+};
+
+/**
+ * Implementation of ByteSink that writes to a "string".
+ * The StringClass is usually instantiated with a std::string.
+ * @stable ICU 4.2
+ */
+template<typename StringClass>
+class StringByteSink : public ByteSink {
+ public:
+ /**
+ * Constructs a ByteSink that will append bytes to the dest string.
+ * @param dest pointer to string object to append to
+ * @stable ICU 4.2
+ */
+ StringByteSink(StringClass* dest) : dest_(dest) { }
+ /**
* Constructs a ByteSink that reserves append capacity and will append bytes to the dest string.
*
* @param dest pointer to string object to append to
@@ -288,22 +288,22 @@ class StringByteSink : public ByteSink {
}
}
/**
- * Append "bytes[0,n-1]" to this.
- * @param data the pointer to the bytes
- * @param n the number of bytes; must be non-negative
- * @stable ICU 4.2
- */
- virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }
- private:
- StringClass* dest_;
+ * Append "bytes[0,n-1]" to this.
+ * @param data the pointer to the bytes
+ * @param n the number of bytes; must be non-negative
+ * @stable ICU 4.2
+ */
+ virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }
+ private:
+ StringClass* dest_;
StringByteSink() = delete;
StringByteSink(const StringByteSink &) = delete;
StringByteSink &operator=(const StringByteSink &) = delete;
-};
-
-U_NAMESPACE_END
-
+};
+
+U_NAMESPACE_END
+
#endif /* U_SHOW_CPLUSPLUS_API */
-#endif // __BYTESTREAM_H__
+#endif // __BYTESTREAM_H__