aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/cescape_encode.h
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:39 +0300
commita6a92afe03e02795227d2641b49819b687f088f8 (patch)
treef6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /library/cpp/yson_pull/detail/cescape_encode.h
parentc6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff)
downloadydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson_pull/detail/cescape_encode.h')
-rw-r--r--library/cpp/yson_pull/detail/cescape_encode.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/yson_pull/detail/cescape_encode.h b/library/cpp/yson_pull/detail/cescape_encode.h
index bf5765f1d9..bf9a44ba5f 100644
--- a/library/cpp/yson_pull/detail/cescape_encode.h
+++ b/library/cpp/yson_pull/detail/cescape_encode.h
@@ -1,11 +1,11 @@
-#pragma once
-
+#pragma once
+
#include <util/system/types.h>
-
-// Whether to ensure strict ASCII compatibility
-// Turns UTF-8 strings into unreadable garbage for no known reason
-//#define CESCAPE_STRICT_ASCII
-
+
+// Whether to ensure strict ASCII compatibility
+// Turns UTF-8 strings into unreadable garbage for no known reason
+//#define CESCAPE_STRICT_ASCII
+
namespace NYsonPull {
namespace NDetail {
namespace NCEscape {
@@ -14,29 +14,29 @@ namespace NYsonPull {
constexpr ui8 hex_digits[] = "0123456789ABCDEF";
return hex_digits[value];
}
-
+
inline ui8 oct_digit(ui8 value) {
return '0' + value;
}
-
+
inline bool is_printable(ui8 c) {
-#ifdef CESCAPE_STRICT_ASCII
+#ifdef CESCAPE_STRICT_ASCII
return c >= 32 && c <= 126;
-#else
+#else
return c >= 32;
-#endif
+#endif
}
-
+
inline bool is_hex_digit(ui8 c) {
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
}
-
+
inline bool is_oct_digit(ui8 c) {
return c >= '0' && c <= '7';
}
-
+
constexpr size_t ESCAPE_C_BUFFER_SIZE = 4;
-
+
inline size_t escape_char(
ui8 c,
ui8 next,
@@ -85,16 +85,16 @@ namespace NYsonPull {
return 4;
}
}
-
+
template <typename T>
inline void escape_impl(const ui8* str, size_t len, T&& consume) {
ui8 buffer[ESCAPE_C_BUFFER_SIZE];
-
+
size_t i, j;
for (i = 0, j = 0; i < len; ++i) {
auto next_char = i + 1 < len ? str[i + 1] : 0;
size_t rlen = escape_char(str[i], next_char, buffer);
-
+
if (rlen > 1) {
consume(str + j, i - j);
j = i + 1;