aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream
diff options
context:
space:
mode:
authorsobols <sobols@yandex-team.ru>2022-02-10 16:47:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:08 +0300
commit03335cb18337a0ef51966452a66a69b01abea218 (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /util/stream
parent09961b69c61f471ddd594e0fd877df62a8021562 (diff)
downloadydb-03335cb18337a0ef51966452a66a69b01abea218.tar.gz
Restoring authorship annotation for <sobols@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r--util/stream/ios_ut.cpp86
-rw-r--r--util/stream/output.cpp64
2 files changed, 75 insertions, 75 deletions
diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp
index 9600edf228..139f4296e5 100644
--- a/util/stream/ios_ut.cpp
+++ b/util/stream/ios_ut.cpp
@@ -27,9 +27,9 @@ class TStreamsTest: public TTestBase {
UNIT_TEST(TestReadTo);
UNIT_TEST(TestWtrokaOutput);
UNIT_TEST(TestIStreamOperators);
- UNIT_TEST(TestWchar16Output);
- UNIT_TEST(TestWchar32Output);
- UNIT_TEST(TestUtf16StingOutputByChars);
+ UNIT_TEST(TestWchar16Output);
+ UNIT_TEST(TestWchar32Output);
+ UNIT_TEST(TestUtf16StingOutputByChars);
UNIT_TEST_SUITE_END();
public:
@@ -45,9 +45,9 @@ public:
void TestWtrokaOutput();
void TestIStreamOperators();
void TestReadTo();
- void TestWchar16Output();
- void TestWchar32Output();
- void TestUtf16StingOutputByChars();
+ void TestWchar16Output();
+ void TestWchar32Output();
+ void TestUtf16StingOutputByChars();
};
UNIT_TEST_SUITE_REGISTRATION(TStreamsTest);
@@ -450,48 +450,48 @@ void TStreamsTest::TestWtrokaOutput() {
UNIT_ASSERT(s == Text);
}
-
-void TStreamsTest::TestWchar16Output() {
- TString s;
- TStringOutput os(s);
- os << wchar16(97); // latin a
+
+void TStreamsTest::TestWchar16Output() {
+ TString s;
+ TStringOutput os(s);
+ os << wchar16(97); // latin a
os << u'\u044E'; // cyrillic ю
- os << u'я';
- os << wchar16(0xD801); // high surrogate is printed as replacement character U+FFFD
- os << u'b';
-
+ os << u'я';
+ os << wchar16(0xD801); // high surrogate is printed as replacement character U+FFFD
+ os << u'b';
+
UNIT_ASSERT_VALUES_EQUAL(s, "aюя"
"\xEF\xBF\xBD"
"b");
-}
-
-void TStreamsTest::TestWchar32Output() {
- TString s;
- TStringOutput os(s);
- os << wchar32(97); // latin a
+}
+
+void TStreamsTest::TestWchar32Output() {
+ TString s;
+ TStringOutput os(s);
+ os << wchar32(97); // latin a
os << U'\u044E'; // cyrillic ю
- os << U'я';
- os << U'\U0001F600'; // grinning face
- os << u'b';
-
+ os << U'я';
+ os << U'\U0001F600'; // grinning face
+ os << u'b';
+
UNIT_ASSERT_VALUES_EQUAL(s, "aюя"
"\xF0\x9F\x98\x80"
"b");
-}
-
-void TStreamsTest::TestUtf16StingOutputByChars() {
- TString s = "\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8";
- TUtf16String w = UTF8ToWide(s);
-
- UNIT_ASSERT_VALUES_EQUAL(w.size(), 10);
-
- TStringStream stream0;
- stream0 << w;
- UNIT_ASSERT_VALUES_EQUAL(stream0.Str(), s);
-
- TStringStream stream1;
- for (size_t i = 0; i < 10; i++) {
- stream1 << w[i];
- }
- UNIT_ASSERT_VALUES_EQUAL(stream1.Str(), s);
-}
+}
+
+void TStreamsTest::TestUtf16StingOutputByChars() {
+ TString s = "\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8";
+ TUtf16String w = UTF8ToWide(s);
+
+ UNIT_ASSERT_VALUES_EQUAL(w.size(), 10);
+
+ TStringStream stream0;
+ stream0 << w;
+ UNIT_ASSERT_VALUES_EQUAL(stream0.Str(), s);
+
+ TStringStream stream1;
+ for (size_t i = 0; i < 10; i++) {
+ stream1 << w[i];
+ }
+ UNIT_ASSERT_VALUES_EQUAL(stream1.Str(), s);
+}
diff --git a/util/stream/output.cpp b/util/stream/output.cpp
index 552a58eff7..db81b81b70 100644
--- a/util/stream/output.cpp
+++ b/util/stream/output.cpp
@@ -5,7 +5,7 @@
#include <util/memory/tempbuf.h>
#include <util/generic/singleton.h>
#include <util/generic/yexception.h>
-#include <util/charset/utf8.h>
+#include <util/charset/utf8.h>
#include <util/charset/wide.h>
#if defined(_android_)
@@ -24,8 +24,8 @@
#include <io.h>
#endif
-constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
-
+constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
+
IOutputStream::IOutputStream() noexcept = default;
IOutputStream::~IOutputStream() = default;
@@ -52,25 +52,25 @@ void IOutputStream::DoWriteC(char ch) {
DoWrite(&ch, 1);
}
-template <>
-void Out<wchar16>(IOutputStream& o, wchar16 ch) {
- const wchar32 w32ch = ReadSymbol(&ch, &ch + 1);
- size_t length;
- unsigned char buffer[MAX_UTF8_BYTES];
- WriteUTF8Char(w32ch, length, buffer);
- o.Write(buffer, length);
-}
-
-template <>
-void Out<wchar32>(IOutputStream& o, wchar32 ch) {
- size_t length;
- unsigned char buffer[MAX_UTF8_BYTES];
- WriteUTF8Char(ch, length, buffer);
- o.Write(buffer, length);
-}
-
+template <>
+void Out<wchar16>(IOutputStream& o, wchar16 ch) {
+ const wchar32 w32ch = ReadSymbol(&ch, &ch + 1);
+ size_t length;
+ unsigned char buffer[MAX_UTF8_BYTES];
+ WriteUTF8Char(w32ch, length, buffer);
+ o.Write(buffer, length);
+}
+
+template <>
+void Out<wchar32>(IOutputStream& o, wchar32 ch) {
+ size_t length;
+ unsigned char buffer[MAX_UTF8_BYTES];
+ WriteUTF8Char(ch, length, buffer);
+ o.Write(buffer, length);
+}
+
static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
- const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
+ const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
TTempBuf buffer(buflen + 1);
char* const data = buffer.Data();
size_t written = 0;
@@ -80,7 +80,7 @@ static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
}
static void WriteString(IOutputStream& o, const wchar32* w, size_t n) {
- const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
+ const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
TTempBuf buffer(buflen + 1);
char* const data = buffer.Data();
size_t written = 0;
@@ -105,16 +105,16 @@ void Out<std::string_view>(IOutputStream& o, const std::string_view& p) {
}
template <>
-void Out<std::u16string_view>(IOutputStream& o, const std::u16string_view& p) {
- WriteString(o, p.data(), p.length());
-}
-
-template <>
-void Out<std::u32string_view>(IOutputStream& o, const std::u32string_view& p) {
- WriteString(o, p.data(), p.length());
-}
-
-template <>
+void Out<std::u16string_view>(IOutputStream& o, const std::u16string_view& p) {
+ WriteString(o, p.data(), p.length());
+}
+
+template <>
+void Out<std::u32string_view>(IOutputStream& o, const std::u32string_view& p) {
+ WriteString(o, p.data(), p.length());
+}
+
+template <>
void Out<TStringBuf>(IOutputStream& o, const TStringBuf& p) {
o.Write(p.data(), p.length());
}