aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/cescape.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.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.h')
-rw-r--r--library/cpp/yson_pull/detail/cescape.h92
1 files changed, 46 insertions, 46 deletions
diff --git a/library/cpp/yson_pull/detail/cescape.h b/library/cpp/yson_pull/detail/cescape.h
index 1ea150e69a..2e468fc0f3 100644
--- a/library/cpp/yson_pull/detail/cescape.h
+++ b/library/cpp/yson_pull/detail/cescape.h
@@ -1,40 +1,40 @@
-#pragma once
-
-#include "byte_writer.h"
-#include "cescape_decode.h"
-#include "cescape_encode.h"
-#include "macros.h"
-
-#include <util/generic/strbuf.h>
+#pragma once
+
+#include "byte_writer.h"
+#include "cescape_decode.h"
+#include "cescape_encode.h"
+#include "macros.h"
+
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-#include <util/generic/vector.h>
-
-/* REFERENCES FOR ESCAPE SEQUENCE INTERPRETATION:
- * C99 p. 6.4.3 Universal character names.
- * C99 p. 6.4.4.4 Character constants.
- *
- * <simple-escape-sequence> ::= {
- * \' , \" , \? , \\ ,
- * \a , \b , \f , \n , \r , \t , \v
- * }
- *
- * <octal-escape-sequence> ::= \ <octal-digit> {1, 3}
- * <hexadecimal-escape-sequence> ::= \x <hexadecimal-digit> +
- * <universal-character-name> ::= \u <hexadecimal-digit> {4}
- * || \U <hexadecimal-digit> {8}
- *
- * NOTE (6.4.4.4.7):
- * Each octal or hexadecimal escape sequence is the longest sequence of characters that can
- * constitute the escape sequence.
- *
- * THEREFORE:
- * - Octal escape sequence spans until rightmost non-octal-digit character.
- * - Octal escape sequence always terminates after three octal digits.
- * - Hexadecimal escape sequence spans until rightmost non-hexadecimal-digit character.
- * - Universal character name consists of exactly 4 or 8 hexadecimal digit.
- *
- */
-
+#include <util/generic/vector.h>
+
+/* REFERENCES FOR ESCAPE SEQUENCE INTERPRETATION:
+ * C99 p. 6.4.3 Universal character names.
+ * C99 p. 6.4.4.4 Character constants.
+ *
+ * <simple-escape-sequence> ::= {
+ * \' , \" , \? , \\ ,
+ * \a , \b , \f , \n , \r , \t , \v
+ * }
+ *
+ * <octal-escape-sequence> ::= \ <octal-digit> {1, 3}
+ * <hexadecimal-escape-sequence> ::= \x <hexadecimal-digit> +
+ * <universal-character-name> ::= \u <hexadecimal-digit> {4}
+ * || \U <hexadecimal-digit> {8}
+ *
+ * NOTE (6.4.4.4.7):
+ * Each octal or hexadecimal escape sequence is the longest sequence of characters that can
+ * constitute the escape sequence.
+ *
+ * THEREFORE:
+ * - Octal escape sequence spans until rightmost non-octal-digit character.
+ * - Octal escape sequence always terminates after three octal digits.
+ * - Hexadecimal escape sequence spans until rightmost non-hexadecimal-digit character.
+ * - Universal character name consists of exactly 4 or 8 hexadecimal digit.
+ *
+ */
+
namespace NYsonPull {
namespace NDetail {
namespace NCEscape {
@@ -48,7 +48,7 @@ namespace NYsonPull {
size);
});
}
-
+
// dest must have at least 4*data.size() bytes available
inline size_t encode(ui8* dest, TStringBuf data) {
auto* dest_begin = dest;
@@ -61,11 +61,11 @@ namespace NYsonPull {
});
return dest - dest_begin;
}
-
+
template <typename U>
void encode(byte_writer<U>& dest, TStringBuf data) {
auto& buffer = dest.stream().buffer();
- if (Y_LIKELY(buffer.available() >= data.size() * 4)) {
+ if (Y_LIKELY(buffer.available() >= data.size() * 4)) {
auto size = encode(buffer.pos(), data);
dest.advance(size);
} else {
@@ -77,14 +77,14 @@ namespace NYsonPull {
});
}
}
-
+
inline TString encode(TStringBuf data) {
TString result;
result.reserve(data.size());
encode(result, data);
return result;
- }
-
+ }
+
inline void decode(TString& dest, TStringBuf data) {
NImpl::unescape_impl(
reinterpret_cast<const ui8*>(data.begin()),
@@ -96,7 +96,7 @@ namespace NYsonPull {
dest.append(reinterpret_cast<const char*>(p), len);
});
}
-
+
inline void decode_inplace(TVector<ui8>& data) {
auto* out = static_cast<ui8*>(
::memchr(data.data(), '\\', data.size()));
@@ -115,14 +115,14 @@ namespace NYsonPull {
});
data.resize(out - &data[0]);
}
-
+
inline TString decode(TStringBuf data) {
TString result;
result.reserve(data.size());
decode(result, data);
return result;
}
-
+
ATTRIBUTE(noinline, cold)
inline TString quote(TStringBuf str) {
TString result;
@@ -132,7 +132,7 @@ namespace NYsonPull {
result += '"';
return result;
}
-
+
ATTRIBUTE(noinline, cold)
inline TString quote(ui8 ch) {
char c = ch;