/src/yaml-cpp/src/null.cpp
Line | Count | Source |
1 | | #include "yaml-cpp/null.h" |
2 | | #include <cstring> |
3 | | |
4 | | namespace YAML { |
5 | | _Null Null; |
6 | | |
7 | | template <std::size_t N> |
8 | 5.86M | static bool same(const char* str, std::size_t size, const char (&literal)[N]) { |
9 | 5.86M | constexpr int literalSize = N - 1; // minus null terminator |
10 | 5.86M | return size == literalSize && std::strncmp(str, literal, literalSize) == 0; |
11 | 5.86M | } null.cpp:bool YAML::same<2ul>(char const*, unsigned long, char const (&) [2ul]) Line | Count | Source | 8 | 1.47M | static bool same(const char* str, std::size_t size, const char (&literal)[N]) { | 9 | 1.47M | constexpr int literalSize = N - 1; // minus null terminator | 10 | 1.47M | return size == literalSize && std::strncmp(str, literal, literalSize) == 0; | 11 | 1.47M | } |
null.cpp:bool YAML::same<5ul>(char const*, unsigned long, char const (&) [5ul]) Line | Count | Source | 8 | 4.39M | static bool same(const char* str, std::size_t size, const char (&literal)[N]) { | 9 | 4.39M | constexpr int literalSize = N - 1; // minus null terminator | 10 | 4.39M | return size == literalSize && std::strncmp(str, literal, literalSize) == 0; | 11 | 4.39M | } |
|
12 | | |
13 | 1.47M | bool IsNullString(const char* str, std::size_t size) { |
14 | 1.47M | return size == 0 || same(str, size, "~") || same(str, size, "null") || |
15 | 1.46M | same(str, size, "Null") || same(str, size, "NULL"); |
16 | 1.47M | } |
17 | | } // namespace YAML |