aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/include/unicode/stringpiece.h
diff options
context:
space:
mode:
authormcheshkov <mcheshkov@yandex-team.ru>2022-02-10 16:46:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:15 +0300
commite9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch)
tree2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/include/unicode/stringpiece.h
parent60040c91ffe701a84689b2c6310ff845e65cff42 (diff)
downloadydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/include/unicode/stringpiece.h')
-rw-r--r--contrib/libs/icu/include/unicode/stringpiece.h268
1 files changed, 134 insertions, 134 deletions
diff --git a/contrib/libs/icu/include/unicode/stringpiece.h b/contrib/libs/icu/include/unicode/stringpiece.h
index 52c1e9ebd2..e5a7c56192 100644
--- a/contrib/libs/icu/include/unicode/stringpiece.h
+++ b/contrib/libs/icu/include/unicode/stringpiece.h
@@ -1,4 +1,4 @@
-// © 2016 and later: Unicode, Inc. and others.
+// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
// Copyright (C) 2009-2013, International Business Machines
// Corporation and others. All Rights Reserved.
@@ -28,12 +28,12 @@
*/
#include "unicode/utypes.h"
-
-#if U_SHOW_CPLUSPLUS_API
-
-#include <cstddef>
-#include <type_traits>
-
+
+#if U_SHOW_CPLUSPLUS_API
+
+#include <cstddef>
+#include <type_traits>
+
#include "unicode/uobject.h"
#include "unicode/std_string.h"
@@ -67,107 +67,107 @@ class U_COMMON_API StringPiece : public UMemory {
* Default constructor, creates an empty StringPiece.
* @stable ICU 4.2
*/
- StringPiece() : ptr_(nullptr), length_(0) { }
-
+ StringPiece() : ptr_(nullptr), length_(0) { }
+
/**
* Constructs from a NUL-terminated const char * pointer.
* @param str a NUL-terminated const char * pointer
* @stable ICU 4.2
*/
StringPiece(const char* str);
-#ifndef U_HIDE_DRAFT_API
-#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
- /**
- * Constructs from a NUL-terminated const char8_t * pointer.
- * @param str a NUL-terminated const char8_t * pointer
- * @draft ICU 67
- */
- StringPiece(const char8_t* str) : StringPiece(reinterpret_cast<const char*>(str)) {}
-#endif
- /**
- * Constructs an empty StringPiece.
- * Needed for type disambiguation from multiple other overloads.
- * @param p nullptr
- * @draft ICU 67
- */
- StringPiece(std::nullptr_t p) : ptr_(p), length_(0) {}
-#endif // U_HIDE_DRAFT_API
-
+#ifndef U_HIDE_DRAFT_API
+#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
/**
+ * Constructs from a NUL-terminated const char8_t * pointer.
+ * @param str a NUL-terminated const char8_t * pointer
+ * @draft ICU 67
+ */
+ StringPiece(const char8_t* str) : StringPiece(reinterpret_cast<const char*>(str)) {}
+#endif
+ /**
+ * Constructs an empty StringPiece.
+ * Needed for type disambiguation from multiple other overloads.
+ * @param p nullptr
+ * @draft ICU 67
+ */
+ StringPiece(std::nullptr_t p) : ptr_(p), length_(0) {}
+#endif // U_HIDE_DRAFT_API
+
+ /**
* Constructs from a std::string.
* @stable ICU 4.2
*/
StringPiece(const std::string& str)
: ptr_(str.data()), length_(static_cast<int32_t>(str.size())) { }
-#ifndef U_HIDE_DRAFT_API
-#if defined(__cpp_lib_char8_t) || defined(U_IN_DOXYGEN)
- /**
- * Constructs from a std::u8string.
- * @draft ICU 67
- */
- StringPiece(const std::u8string& str)
- : ptr_(reinterpret_cast<const char*>(str.data())),
- length_(static_cast<int32_t>(str.size())) { }
+#ifndef U_HIDE_DRAFT_API
+#if defined(__cpp_lib_char8_t) || defined(U_IN_DOXYGEN)
+ /**
+ * Constructs from a std::u8string.
+ * @draft ICU 67
+ */
+ StringPiece(const std::u8string& str)
+ : ptr_(reinterpret_cast<const char*>(str.data())),
+ length_(static_cast<int32_t>(str.size())) { }
#endif
-#endif // U_HIDE_DRAFT_API
-
-#ifndef U_HIDE_DRAFT_API
- /**
- * Constructs from some other implementation of a string piece class, from any
- * C++ record type that has these two methods:
- *
- * \code{.cpp}
- *
- * struct OtherStringPieceClass {
- * const char* data(); // or const char8_t*
- * size_t size();
- * };
- *
- * \endcode
- *
- * The other string piece class will typically be std::string_view from C++17
- * or absl::string_view from Abseil.
- *
- * Starting with C++20, data() may also return a const char8_t* pointer,
- * as from std::u8string_view.
- *
- * @param str the other string piece
- * @draft ICU 65
- */
- template <typename T,
- typename = typename std::enable_if<
- (std::is_same<decltype(T().data()), const char*>::value
-#if defined(__cpp_char8_t)
- || std::is_same<decltype(T().data()), const char8_t*>::value
-#endif
- ) &&
- std::is_same<decltype(T().size()), size_t>::value>::type>
- StringPiece(T str)
- : ptr_(reinterpret_cast<const char*>(str.data())),
- length_(static_cast<int32_t>(str.size())) {}
-#endif // U_HIDE_DRAFT_API
-
+#endif // U_HIDE_DRAFT_API
+
+#ifndef U_HIDE_DRAFT_API
/**
+ * Constructs from some other implementation of a string piece class, from any
+ * C++ record type that has these two methods:
+ *
+ * \code{.cpp}
+ *
+ * struct OtherStringPieceClass {
+ * const char* data(); // or const char8_t*
+ * size_t size();
+ * };
+ *
+ * \endcode
+ *
+ * The other string piece class will typically be std::string_view from C++17
+ * or absl::string_view from Abseil.
+ *
+ * Starting with C++20, data() may also return a const char8_t* pointer,
+ * as from std::u8string_view.
+ *
+ * @param str the other string piece
+ * @draft ICU 65
+ */
+ template <typename T,
+ typename = typename std::enable_if<
+ (std::is_same<decltype(T().data()), const char*>::value
+#if defined(__cpp_char8_t)
+ || std::is_same<decltype(T().data()), const char8_t*>::value
+#endif
+ ) &&
+ std::is_same<decltype(T().size()), size_t>::value>::type>
+ StringPiece(T str)
+ : ptr_(reinterpret_cast<const char*>(str.data())),
+ length_(static_cast<int32_t>(str.size())) {}
+#endif // U_HIDE_DRAFT_API
+
+ /**
* Constructs from a const char * pointer and a specified length.
* @param offset a const char * pointer (need not be terminated)
* @param len the length of the string; must be non-negative
* @stable ICU 4.2
*/
StringPiece(const char* offset, int32_t len) : ptr_(offset), length_(len) { }
-#ifndef U_HIDE_DRAFT_API
-#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
- /**
- * Constructs from a const char8_t * pointer and a specified length.
- * @param str a const char8_t * pointer (need not be terminated)
- * @param len the length of the string; must be non-negative
- * @draft ICU 67
- */
- StringPiece(const char8_t* str, int32_t len) :
- StringPiece(reinterpret_cast<const char*>(str), len) {}
-#endif
-#endif // U_HIDE_DRAFT_API
-
+#ifndef U_HIDE_DRAFT_API
+#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
/**
+ * Constructs from a const char8_t * pointer and a specified length.
+ * @param str a const char8_t * pointer (need not be terminated)
+ * @param len the length of the string; must be non-negative
+ * @draft ICU 67
+ */
+ StringPiece(const char8_t* str, int32_t len) :
+ StringPiece(reinterpret_cast<const char*>(str), len) {}
+#endif
+#endif // U_HIDE_DRAFT_API
+
+ /**
* Substring of another StringPiece.
* @param x the other StringPiece
* @param pos start position in x; must be non-negative and <= x.length().
@@ -185,7 +185,7 @@ class U_COMMON_API StringPiece : public UMemory {
StringPiece(const StringPiece& x, int32_t pos, int32_t len);
/**
- * Returns the string pointer. May be nullptr if it is empty.
+ * Returns the string pointer. May be nullptr if it is empty.
*
* data() may return a pointer to a buffer with embedded NULs, and the
* returned buffer may or may not be null terminated. Therefore it is
@@ -218,7 +218,7 @@ class U_COMMON_API StringPiece : public UMemory {
* Sets to an empty string.
* @stable ICU 4.2
*/
- void clear() { ptr_ = nullptr; length_ = 0; }
+ void clear() { ptr_ = nullptr; length_ = 0; }
/**
* Reset the stringpiece to refer to new data.
@@ -235,30 +235,30 @@ class U_COMMON_API StringPiece : public UMemory {
*/
void set(const char* str);
-#ifndef U_HIDE_DRAFT_API
-#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
- /**
- * Resets the stringpiece to refer to new data.
- * @param xdata pointer the new string data. Need not be NUL-terminated.
- * @param len the length of the new data
- * @draft ICU 67
- */
- inline void set(const char8_t* xdata, int32_t len) {
- set(reinterpret_cast<const char*>(xdata), len);
- }
-
- /**
- * Resets the stringpiece to refer to new data.
- * @param str a pointer to a NUL-terminated string.
- * @draft ICU 67
- */
- inline void set(const char8_t* str) {
- set(reinterpret_cast<const char*>(str));
- }
-#endif
-#endif // U_HIDE_DRAFT_API
-
+#ifndef U_HIDE_DRAFT_API
+#if defined(__cpp_char8_t) || defined(U_IN_DOXYGEN)
/**
+ * Resets the stringpiece to refer to new data.
+ * @param xdata pointer the new string data. Need not be NUL-terminated.
+ * @param len the length of the new data
+ * @draft ICU 67
+ */
+ inline void set(const char8_t* xdata, int32_t len) {
+ set(reinterpret_cast<const char*>(xdata), len);
+ }
+
+ /**
+ * Resets the stringpiece to refer to new data.
+ * @param str a pointer to a NUL-terminated string.
+ * @draft ICU 67
+ */
+ inline void set(const char8_t* str) {
+ set(reinterpret_cast<const char*>(str));
+ }
+#endif
+#endif // U_HIDE_DRAFT_API
+
+ /**
* Removes the first n string units.
* @param n prefix length, must be non-negative and <=length()
* @stable ICU 4.2
@@ -288,27 +288,27 @@ class U_COMMON_API StringPiece : public UMemory {
}
}
-#ifndef U_HIDE_DRAFT_API
- /**
- * Searches the StringPiece for the given search string (needle);
- * @param needle The string for which to search.
- * @param offset Where to start searching within this string (haystack).
- * @return The offset of needle in haystack, or -1 if not found.
- * @draft ICU 67
- */
- int32_t find(StringPiece needle, int32_t offset);
-
- /**
- * Compares this StringPiece with the other StringPiece, with semantics
- * similar to std::string::compare().
- * @param other The string to compare to.
- * @return below zero if this < other; above zero if this > other; 0 if this == other.
- * @draft ICU 67
- */
- int32_t compare(StringPiece other);
-#endif // U_HIDE_DRAFT_API
-
+#ifndef U_HIDE_DRAFT_API
/**
+ * Searches the StringPiece for the given search string (needle);
+ * @param needle The string for which to search.
+ * @param offset Where to start searching within this string (haystack).
+ * @return The offset of needle in haystack, or -1 if not found.
+ * @draft ICU 67
+ */
+ int32_t find(StringPiece needle, int32_t offset);
+
+ /**
+ * Compares this StringPiece with the other StringPiece, with semantics
+ * similar to std::string::compare().
+ * @param other The string to compare to.
+ * @return below zero if this < other; above zero if this > other; 0 if this == other.
+ * @draft ICU 67
+ */
+ int32_t compare(StringPiece other);
+#endif // U_HIDE_DRAFT_API
+
+ /**
* Maximum integer, used as a default value for substring methods.
* @stable ICU 4.2
*/
@@ -350,6 +350,6 @@ inline UBool operator!=(const StringPiece& x, const StringPiece& y) {
U_NAMESPACE_END
-#endif /* U_SHOW_CPLUSPLUS_API */
-
+#endif /* U_SHOW_CPLUSPLUS_API */
+
#endif // __STRINGPIECE_H__