mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
it complies and crow updated
This commit is contained in:
parent
9b3a27baa9
commit
f9925d6c3b
20 changed files with 870 additions and 513 deletions
51
ext/crow/json.h
Normal file → Executable file
51
ext/crow/json.h
Normal file → Executable file
|
@ -82,7 +82,7 @@ namespace crow
|
|||
Object,
|
||||
};
|
||||
|
||||
const char* get_type_str(type t) {
|
||||
inline const char* get_type_str(type t) {
|
||||
switch(t){
|
||||
case type::Number: return "Number";
|
||||
case type::False: return "False";
|
||||
|
@ -92,7 +92,7 @@ namespace crow
|
|||
case type::Object: return "Object";
|
||||
default: return "Unknown";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class rvalue;
|
||||
rvalue load(const char* data, size_t size);
|
||||
|
@ -131,6 +131,8 @@ namespace crow
|
|||
s_ = r.s_;
|
||||
e_ = r.e_;
|
||||
owned_ = r.owned_;
|
||||
if (r.owned_)
|
||||
r.owned_ = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -164,7 +166,7 @@ namespace crow
|
|||
return os;
|
||||
}
|
||||
private:
|
||||
void force(char* s, uint32_t length)
|
||||
void force(char* s, uint32_t /*length*/)
|
||||
{
|
||||
s_ = s;
|
||||
owned_ = 1;
|
||||
|
@ -262,6 +264,11 @@ namespace crow
|
|||
return i();
|
||||
}
|
||||
|
||||
explicit operator uint64_t() const
|
||||
{
|
||||
return u();
|
||||
}
|
||||
|
||||
explicit operator int() const
|
||||
{
|
||||
return (int)i();
|
||||
|
@ -286,14 +293,28 @@ namespace crow
|
|||
case type::String:
|
||||
return boost::lexical_cast<int64_t>(start_, end_-start_);
|
||||
default:
|
||||
throw std::runtime_error(
|
||||
"expected number, got: " + std::string(get_type_str(t()))
|
||||
);
|
||||
const std::string msg = "expected number, got: "
|
||||
+ std::string(get_type_str(t()));
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
#endif
|
||||
return boost::lexical_cast<int64_t>(start_, end_-start_);
|
||||
}
|
||||
|
||||
uint64_t u() const
|
||||
{
|
||||
#ifndef CROW_JSON_NO_ERROR_CHECK
|
||||
switch (t()) {
|
||||
case type::Number:
|
||||
case type::String:
|
||||
return boost::lexical_cast<uint64_t>(start_, end_-start_);
|
||||
default:
|
||||
throw std::runtime_error(std::string("expected number, got: ") + get_type_str(t()));
|
||||
}
|
||||
#endif
|
||||
return boost::lexical_cast<uint64_t>(start_, end_-start_);
|
||||
}
|
||||
|
||||
double d() const
|
||||
{
|
||||
#ifndef CROW_JSON_NO_ERROR_CHECK
|
||||
|
@ -671,7 +692,7 @@ namespace crow
|
|||
//static const char* escaped = "\"\\/\b\f\n\r\t";
|
||||
struct Parser
|
||||
{
|
||||
Parser(char* data, size_t size)
|
||||
Parser(char* data, size_t /*size*/)
|
||||
: data(data)
|
||||
{
|
||||
}
|
||||
|
@ -1093,17 +1114,16 @@ namespace crow
|
|||
s = r.s();
|
||||
return;
|
||||
case type::List:
|
||||
l = std::move(std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{}));
|
||||
l = std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{});
|
||||
l->reserve(r.size());
|
||||
for(auto it = r.begin(); it != r.end(); ++it)
|
||||
l->emplace_back(*it);
|
||||
return;
|
||||
case type::Object:
|
||||
o = std::move(
|
||||
std::unique_ptr<
|
||||
o = std::unique_ptr<
|
||||
std::unordered_map<std::string, wvalue>
|
||||
>(
|
||||
new std::unordered_map<std::string, wvalue>{}));
|
||||
new std::unordered_map<std::string, wvalue>{});
|
||||
for(auto it = r.begin(); it != r.end(); ++it)
|
||||
o->emplace(it->key(), *it);
|
||||
return;
|
||||
|
@ -1249,7 +1269,7 @@ namespace crow
|
|||
reset();
|
||||
t_ = type::List;
|
||||
if (!l)
|
||||
l = std::move(std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{}));
|
||||
l = std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{});
|
||||
l->clear();
|
||||
l->resize(v.size());
|
||||
size_t idx = 0;
|
||||
|
@ -1266,7 +1286,7 @@ namespace crow
|
|||
reset();
|
||||
t_ = type::List;
|
||||
if (!l)
|
||||
l = std::move(std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{}));
|
||||
l = std::unique_ptr<std::vector<wvalue>>(new std::vector<wvalue>{});
|
||||
if (l->size() < index+1)
|
||||
l->resize(index+1);
|
||||
return (*l)[index];
|
||||
|
@ -1287,11 +1307,10 @@ namespace crow
|
|||
reset();
|
||||
t_ = type::Object;
|
||||
if (!o)
|
||||
o = std::move(
|
||||
std::unique_ptr<
|
||||
o = std::unique_ptr<
|
||||
std::unordered_map<std::string, wvalue>
|
||||
>(
|
||||
new std::unordered_map<std::string, wvalue>{}));
|
||||
new std::unordered_map<std::string, wvalue>{});
|
||||
return (*o)[str];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue