aboutsummaryrefslogtreecommitdiff
path: root/src/univalue
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-07-27 12:17:50 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-07-27 14:24:52 +0200
commitfa940f41eaffa4b2a28c465a10a4c12d4b8976b8 (patch)
treed92ef58ded0d996d404b7421103e47df1e375b4f /src/univalue
parentdfe2dc1d84436d4eae351612dbf0b92f032389be (diff)
Remove unused raw-pointer read helper from univalue
Diffstat (limited to 'src/univalue')
-rw-r--r--src/univalue/include/univalue.h8
-rw-r--r--src/univalue/lib/univalue_read.cpp8
-rw-r--r--src/univalue/test/unitester.cpp2
3 files changed, 10 insertions, 8 deletions
diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h
index 94f80f9c27..acbce25741 100644
--- a/src/univalue/include/univalue.h
+++ b/src/univalue/include/univalue.h
@@ -7,13 +7,15 @@
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
#include <charconv>
+#include <cstddef>
#include <cstdint>
-#include <cstring>
#include <map>
#include <stdexcept>
#include <string>
#include <string_view>
+#include <system_error>
#include <type_traits>
+#include <utility>
#include <vector>
class UniValue {
@@ -94,9 +96,7 @@ public:
std::string write(unsigned int prettyIndent = 0,
unsigned int indentLevel = 0) const;
- bool read(const char *raw, size_t len);
- bool read(const char *raw) { return read(raw, strlen(raw)); }
- bool read(std::string_view raw) { return read(raw.data(), raw.size()); }
+ bool read(std::string_view raw);
private:
UniValue::VType typ;
diff --git a/src/univalue/lib/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp
index 2f2385383c..40d465f438 100644
--- a/src/univalue/lib/univalue_read.cpp
+++ b/src/univalue/lib/univalue_read.cpp
@@ -5,10 +5,11 @@
#include <univalue.h>
#include <univalue_utffilter.h>
-#include <cstdio>
#include <cstdint>
+#include <cstdio>
#include <cstring>
#include <string>
+#include <string_view>
#include <vector>
/*
@@ -259,7 +260,7 @@ enum expect_bits : unsigned {
#define setExpect(bit) (expectMask |= EXP_##bit)
#define clearExpect(bit) (expectMask &= ~EXP_##bit)
-bool UniValue::read(const char *raw, size_t size)
+bool UniValue::read(std::string_view str_in)
{
clear();
@@ -270,7 +271,8 @@ bool UniValue::read(const char *raw, size_t size)
unsigned int consumed;
enum jtokentype tok = JTOK_NONE;
enum jtokentype last_tok = JTOK_NONE;
- const char* end = raw + size;
+ const char* raw{str_in.data()};
+ const char* end{raw + str_in.size()};
do {
last_tok = tok;
diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp
index 6344a5a0ab..d27e647e5c 100644
--- a/src/univalue/test/unitester.cpp
+++ b/src/univalue/test/unitester.cpp
@@ -153,7 +153,7 @@ void no_nul_test()
{
char buf[] = "___[1,2,3]___";
UniValue val;
- assert(val.read(buf + 3, 7));
+ assert(val.read({buf + 3, 7}));
}
int main (int argc, char *argv[])