aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/common/localeprioritylist.h
diff options
context:
space:
mode:
authormcheshkov <mcheshkov@yandex-team.ru>2022-02-10 16:46:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:16 +0300
commit1312621288956f199a5bd5342b0133d4395fa725 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/icu/common/localeprioritylist.h
parente9d19cec64684c9c1e6b0c98297e5b895cf904fe (diff)
downloadydb-1312621288956f199a5bd5342b0133d4395fa725.tar.gz
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/icu/common/localeprioritylist.h')
-rw-r--r--contrib/libs/icu/common/localeprioritylist.h230
1 files changed, 115 insertions, 115 deletions
diff --git a/contrib/libs/icu/common/localeprioritylist.h b/contrib/libs/icu/common/localeprioritylist.h
index a39f7e1f5b..80ca38a7b5 100644
--- a/contrib/libs/icu/common/localeprioritylist.h
+++ b/contrib/libs/icu/common/localeprioritylist.h
@@ -1,115 +1,115 @@
-// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
-
-// localeprioritylist.h
-// created: 2019jul11 Markus W. Scherer
-
-#ifndef __LOCALEPRIORITYLIST_H__
-#define __LOCALEPRIORITYLIST_H__
-
-#include "unicode/utypes.h"
-#include "unicode/locid.h"
-#include "unicode/stringpiece.h"
-#include "unicode/uobject.h"
-
-struct UHashtable;
-
-U_NAMESPACE_BEGIN
-
-struct LocaleAndWeightArray;
-
-/**
- * Parses a list of locales from an accept-language string.
- * We are a bit more lenient than the spec:
- * We accept extra whitespace in more places, empty range fields,
- * and any number of qvalue fraction digits.
- *
- * https://tools.ietf.org/html/rfc2616#section-14.4
- * 14.4 Accept-Language
- *
- * Accept-Language = "Accept-Language" ":"
- * 1#( language-range [ ";" "q" "=" qvalue ] )
- * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
- *
- * Each language-range MAY be given an associated quality value which
- * represents an estimate of the user's preference for the languages
- * specified by that range. The quality value defaults to "q=1". For
- * example,
- *
- * Accept-Language: da, en-gb;q=0.8, en;q=0.7
- *
- * https://tools.ietf.org/html/rfc2616#section-3.9
- * 3.9 Quality Values
- *
- * HTTP content negotiation (section 12) uses short "floating point"
- * numbers to indicate the relative importance ("weight") of various
- * negotiable parameters. A weight is normalized to a real number in
- * the range 0 through 1, where 0 is the minimum and 1 the maximum
- * value. If a parameter has a quality value of 0, then content with
- * this parameter is `not acceptable' for the client. HTTP/1.1
- * applications MUST NOT generate more than three digits after the
- * decimal point. User configuration of these values SHOULD also be
- * limited in this fashion.
- *
- * qvalue = ( "0" [ "." 0*3DIGIT ] )
- * | ( "1" [ "." 0*3("0") ] )
- */
-class U_COMMON_API LocalePriorityList : public UMemory {
-public:
- class Iterator : public Locale::Iterator {
- public:
- UBool hasNext() const override { return count < length; }
-
- const Locale &next() override {
- for(;;) {
- const Locale *locale = list.localeAt(index++);
- if (locale != nullptr) {
- ++count;
- return *locale;
- }
- }
- }
-
- private:
- friend class LocalePriorityList;
-
- Iterator(const LocalePriorityList &list) : list(list), length(list.getLength()) {}
-
- const LocalePriorityList &list;
- int32_t index = 0;
- int32_t count = 0;
- const int32_t length;
- };
-
- LocalePriorityList(StringPiece s, UErrorCode &errorCode);
-
- ~LocalePriorityList();
-
- int32_t getLength() const { return listLength - numRemoved; }
-
- int32_t getLengthIncludingRemoved() const { return listLength; }
-
- Iterator iterator() const { return Iterator(*this); }
-
- const Locale *localeAt(int32_t i) const;
-
- Locale *orphanLocaleAt(int32_t i);
-
-private:
- LocalePriorityList(const LocalePriorityList &) = delete;
- LocalePriorityList &operator=(const LocalePriorityList &) = delete;
-
- bool add(const Locale &locale, int32_t weight, UErrorCode &errorCode);
-
- void sort(UErrorCode &errorCode);
-
- LocaleAndWeightArray *list = nullptr;
- int32_t listLength = 0;
- int32_t numRemoved = 0;
- bool hasWeights = false; // other than 1.0
- UHashtable *map = nullptr;
-};
-
-U_NAMESPACE_END
-
-#endif // __LOCALEPRIORITYLIST_H__
+// © 2019 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html#License
+
+// localeprioritylist.h
+// created: 2019jul11 Markus W. Scherer
+
+#ifndef __LOCALEPRIORITYLIST_H__
+#define __LOCALEPRIORITYLIST_H__
+
+#include "unicode/utypes.h"
+#include "unicode/locid.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+
+struct UHashtable;
+
+U_NAMESPACE_BEGIN
+
+struct LocaleAndWeightArray;
+
+/**
+ * Parses a list of locales from an accept-language string.
+ * We are a bit more lenient than the spec:
+ * We accept extra whitespace in more places, empty range fields,
+ * and any number of qvalue fraction digits.
+ *
+ * https://tools.ietf.org/html/rfc2616#section-14.4
+ * 14.4 Accept-Language
+ *
+ * Accept-Language = "Accept-Language" ":"
+ * 1#( language-range [ ";" "q" "=" qvalue ] )
+ * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
+ *
+ * Each language-range MAY be given an associated quality value which
+ * represents an estimate of the user's preference for the languages
+ * specified by that range. The quality value defaults to "q=1". For
+ * example,
+ *
+ * Accept-Language: da, en-gb;q=0.8, en;q=0.7
+ *
+ * https://tools.ietf.org/html/rfc2616#section-3.9
+ * 3.9 Quality Values
+ *
+ * HTTP content negotiation (section 12) uses short "floating point"
+ * numbers to indicate the relative importance ("weight") of various
+ * negotiable parameters. A weight is normalized to a real number in
+ * the range 0 through 1, where 0 is the minimum and 1 the maximum
+ * value. If a parameter has a quality value of 0, then content with
+ * this parameter is `not acceptable' for the client. HTTP/1.1
+ * applications MUST NOT generate more than three digits after the
+ * decimal point. User configuration of these values SHOULD also be
+ * limited in this fashion.
+ *
+ * qvalue = ( "0" [ "." 0*3DIGIT ] )
+ * | ( "1" [ "." 0*3("0") ] )
+ */
+class U_COMMON_API LocalePriorityList : public UMemory {
+public:
+ class Iterator : public Locale::Iterator {
+ public:
+ UBool hasNext() const override { return count < length; }
+
+ const Locale &next() override {
+ for(;;) {
+ const Locale *locale = list.localeAt(index++);
+ if (locale != nullptr) {
+ ++count;
+ return *locale;
+ }
+ }
+ }
+
+ private:
+ friend class LocalePriorityList;
+
+ Iterator(const LocalePriorityList &list) : list(list), length(list.getLength()) {}
+
+ const LocalePriorityList &list;
+ int32_t index = 0;
+ int32_t count = 0;
+ const int32_t length;
+ };
+
+ LocalePriorityList(StringPiece s, UErrorCode &errorCode);
+
+ ~LocalePriorityList();
+
+ int32_t getLength() const { return listLength - numRemoved; }
+
+ int32_t getLengthIncludingRemoved() const { return listLength; }
+
+ Iterator iterator() const { return Iterator(*this); }
+
+ const Locale *localeAt(int32_t i) const;
+
+ Locale *orphanLocaleAt(int32_t i);
+
+private:
+ LocalePriorityList(const LocalePriorityList &) = delete;
+ LocalePriorityList &operator=(const LocalePriorityList &) = delete;
+
+ bool add(const Locale &locale, int32_t weight, UErrorCode &errorCode);
+
+ void sort(UErrorCode &errorCode);
+
+ LocaleAndWeightArray *list = nullptr;
+ int32_t listLength = 0;
+ int32_t numRemoved = 0;
+ bool hasWeights = false; // other than 1.0
+ UHashtable *map = nullptr;
+};
+
+U_NAMESPACE_END
+
+#endif // __LOCALEPRIORITYLIST_H__