aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/util.cpp
diff options
context:
space:
mode:
authorv01d <v01d@yandex-team.ru>2022-02-10 16:49:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:40 +0300
commit5c6482e8c13dfaad60e604f0474606a0ec153b1d (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf/json/util.cpp
parentfa8b0420162dd36d4f569fdc3f63da0bef8bb8c7 (diff)
downloadydb-5c6482e8c13dfaad60e604f0474606a0ec153b1d.tar.gz
Restoring authorship annotation for <v01d@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf/json/util.cpp')
-rw-r--r--library/cpp/protobuf/json/util.cpp102
1 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/protobuf/json/util.cpp b/library/cpp/protobuf/json/util.cpp
index 0145d6c674..53a065eee2 100644
--- a/library/cpp/protobuf/json/util.cpp
+++ b/library/cpp/protobuf/json/util.cpp
@@ -1,54 +1,54 @@
-#include "util.h"
-
-#include <util/string/ascii.h>
-
-namespace {
- void ToSnakeCaseImpl(TString* const name, std::function<bool(const char)> requiresUnderscore) {
- bool requiresChanges = false;
- size_t size = name->size();
- for (size_t i = 0; i < name->size(); i++) {
- if (IsAsciiUpper(name->at(i))) {
- requiresChanges = true;
- if (i > 0 && requiresUnderscore(name->at(i - 1))) {
- size++;
- }
- }
- }
-
- if (!requiresChanges) {
- return;
- }
-
- if (size != name->size()) {
- TString result;
- result.reserve(size);
- for (size_t i = 0; i < name->size(); i++) {
- const char c = name->at(i);
- if (IsAsciiUpper(c)) {
- if (i > 0 && requiresUnderscore(name->at(i - 1))) {
- result += '_';
- }
- result += AsciiToLower(c);
- } else {
- result += c;
- }
- }
- *name = std::move(result);
- } else {
- name->to_lower();
- }
- }
-}
+#include "util.h"
+
+#include <util/string/ascii.h>
+
+namespace {
+ void ToSnakeCaseImpl(TString* const name, std::function<bool(const char)> requiresUnderscore) {
+ bool requiresChanges = false;
+ size_t size = name->size();
+ for (size_t i = 0; i < name->size(); i++) {
+ if (IsAsciiUpper(name->at(i))) {
+ requiresChanges = true;
+ if (i > 0 && requiresUnderscore(name->at(i - 1))) {
+ size++;
+ }
+ }
+ }
+
+ if (!requiresChanges) {
+ return;
+ }
+
+ if (size != name->size()) {
+ TString result;
+ result.reserve(size);
+ for (size_t i = 0; i < name->size(); i++) {
+ const char c = name->at(i);
+ if (IsAsciiUpper(c)) {
+ if (i > 0 && requiresUnderscore(name->at(i - 1))) {
+ result += '_';
+ }
+ result += AsciiToLower(c);
+ } else {
+ result += c;
+ }
+ }
+ *name = std::move(result);
+ } else {
+ name->to_lower();
+ }
+ }
+}
+
+namespace NProtobufJson {
+ void ToSnakeCase(TString* const name) {
+ ToSnakeCaseImpl(name, [](const char prev) { return prev != '_'; });
+ }
+
+ void ToSnakeCaseDense(TString* const name) {
+ ToSnakeCaseImpl(name, [](const char prev) { return prev != '_' && !IsAsciiUpper(prev); });
+ }
-namespace NProtobufJson {
- void ToSnakeCase(TString* const name) {
- ToSnakeCaseImpl(name, [](const char prev) { return prev != '_'; });
- }
-
- void ToSnakeCaseDense(TString* const name) {
- ToSnakeCaseImpl(name, [](const char prev) { return prev != '_' && !IsAsciiUpper(prev); });
- }
-
bool EqualsIgnoringCaseAndUnderscores(TStringBuf s1, TStringBuf s2) {
size_t i1 = 0, i2 = 0;
@@ -73,4 +73,4 @@ namespace NProtobufJson {
return (i1 == s1.size() && i2 == s2.size());
}
-}
+}