aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/yaml-cpp/src/convert.cpp
diff options
context:
space:
mode:
authorbnagaev <bnagaev@yandex-team.ru>2022-02-10 16:47:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:04 +0300
commitc74559fb88da8adac0d9186cfa55a6b13c47695f (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /contrib/libs/yaml-cpp/src/convert.cpp
parentd6449ba66291ff0c0d352c82e6eb3efb4c8a7e8d (diff)
downloadydb-c74559fb88da8adac0d9186cfa55a6b13c47695f.tar.gz
Restoring authorship annotation for <bnagaev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/yaml-cpp/src/convert.cpp')
-rw-r--r--contrib/libs/yaml-cpp/src/convert.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/contrib/libs/yaml-cpp/src/convert.cpp b/contrib/libs/yaml-cpp/src/convert.cpp
index b7e9d7f7f4..ec05b77826 100644
--- a/contrib/libs/yaml-cpp/src/convert.cpp
+++ b/contrib/libs/yaml-cpp/src/convert.cpp
@@ -1,75 +1,75 @@
-#include <algorithm>
-
-#include "yaml-cpp/node/convert.h"
-
-namespace {
-// we're not gonna mess with the mess that is all the isupper/etc. functions
-bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; }
-bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; }
-char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; }
-
-std::string tolower(const std::string& str) {
- std::string s(str);
- std::transform(s.begin(), s.end(), s.begin(), ToLower);
- return s;
-}
-
-template <typename T>
-bool IsEntirely(const std::string& str, T func) {
- for (std::size_t i = 0; i < str.size(); i++)
- if (!func(str[i]))
- return false;
-
- return true;
-}
-
-// IsFlexibleCase
-// . Returns true if 'str' is:
-// . UPPERCASE
-// . lowercase
-// . Capitalized
-bool IsFlexibleCase(const std::string& str) {
- if (str.empty())
- return true;
-
- if (IsEntirely(str, IsLower))
- return true;
-
- bool firstcaps = IsUpper(str[0]);
- std::string rest = str.substr(1);
- return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
-}
-}
-
-namespace YAML {
-bool convert<bool>::decode(const Node& node, bool& rhs) {
- if (!node.IsScalar())
- return false;
-
- // we can't use iostream bool extraction operators as they don't
- // recognize all possible values in the table below (taken from
- // http://yaml.org/type/bool.html)
- static const struct {
- std::string truename, falsename;
- } names[] = {
- {"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
- };
-
- if (!IsFlexibleCase(node.Scalar()))
- return false;
-
- for (unsigned i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
- if (names[i].truename == tolower(node.Scalar())) {
- rhs = true;
- return true;
- }
-
- if (names[i].falsename == tolower(node.Scalar())) {
- rhs = false;
- return true;
- }
- }
-
- return false;
-}
-}
+#include <algorithm>
+
+#include "yaml-cpp/node/convert.h"
+
+namespace {
+// we're not gonna mess with the mess that is all the isupper/etc. functions
+bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; }
+bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; }
+char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; }
+
+std::string tolower(const std::string& str) {
+ std::string s(str);
+ std::transform(s.begin(), s.end(), s.begin(), ToLower);
+ return s;
+}
+
+template <typename T>
+bool IsEntirely(const std::string& str, T func) {
+ for (std::size_t i = 0; i < str.size(); i++)
+ if (!func(str[i]))
+ return false;
+
+ return true;
+}
+
+// IsFlexibleCase
+// . Returns true if 'str' is:
+// . UPPERCASE
+// . lowercase
+// . Capitalized
+bool IsFlexibleCase(const std::string& str) {
+ if (str.empty())
+ return true;
+
+ if (IsEntirely(str, IsLower))
+ return true;
+
+ bool firstcaps = IsUpper(str[0]);
+ std::string rest = str.substr(1);
+ return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
+}
+}
+
+namespace YAML {
+bool convert<bool>::decode(const Node& node, bool& rhs) {
+ if (!node.IsScalar())
+ return false;
+
+ // we can't use iostream bool extraction operators as they don't
+ // recognize all possible values in the table below (taken from
+ // http://yaml.org/type/bool.html)
+ static const struct {
+ std::string truename, falsename;
+ } names[] = {
+ {"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
+ };
+
+ if (!IsFlexibleCase(node.Scalar()))
+ return false;
+
+ for (unsigned i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (names[i].truename == tolower(node.Scalar())) {
+ rhs = true;
+ return true;
+ }
+
+ if (names[i].falsename == tolower(node.Scalar())) {
+ rhs = false;
+ return true;
+ }
+ }
+
+ return false;
+}
+}