Removing all stdout, stderr from main library. (#455)
* Removing all stdout,stderr from main library.
This commit is contained in:
parent
48530b89ea
commit
80b4dd2e8a
|
@ -107,9 +107,9 @@ jsonparse_functype* get_jsonparse_func(const Architecture architecture) {
|
|||
|
||||
struct json_parser {
|
||||
const Architecture architecture;
|
||||
const stage1_functype *stage1_func;
|
||||
const stage2_functype *stage2_func;
|
||||
const jsonparse_functype *jsonparse_func;
|
||||
stage1_functype *stage1_func;
|
||||
stage2_functype *stage2_func;
|
||||
jsonparse_functype *jsonparse_func;
|
||||
|
||||
json_parser(const Architecture _architecture) : architecture(_architecture) {
|
||||
this->stage1_func = get_stage1_func(architecture);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DUMPBITS_H
|
||||
#define DUMPBITS_H
|
||||
#include <iostream>
|
||||
|
||||
// dump bits low to high
|
||||
inline void dumpbits_always(uint64_t v, const std::string &msg) {
|
||||
for (uint32_t i = 0; i < 64; i++) {
|
||||
std::cout << (((v >> static_cast<uint64_t>(i)) & 0x1ULL) ? "1" : "_");
|
||||
}
|
||||
std::cout << " " << msg.c_str() << "\n";
|
||||
}
|
||||
|
||||
inline void dumpbits32_always(uint32_t v, const std::string &msg) {
|
||||
for (uint32_t i = 0; i < 32; i++) {
|
||||
std::cout << (((v >> i) & 0x1ULL) ? "1" : "_");
|
||||
}
|
||||
std::cout << " " << msg.c_str() << "\n";
|
||||
}
|
||||
#endif
|
|
@ -1,53 +1,11 @@
|
|||
#ifndef SIMDJSON_JSONFORMATUTILS_H
|
||||
#define SIMDJSON_JSONFORMATUTILS_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
namespace simdjson {
|
||||
// ends with zero char
|
||||
static inline void print_with_escapes(const unsigned char *src) {
|
||||
while (*src) {
|
||||
switch (*src) {
|
||||
case '\b':
|
||||
putchar('\\');
|
||||
putchar('b');
|
||||
break;
|
||||
case '\f':
|
||||
putchar('\\');
|
||||
putchar('f');
|
||||
break;
|
||||
case '\n':
|
||||
putchar('\\');
|
||||
putchar('n');
|
||||
break;
|
||||
case '\r':
|
||||
putchar('\\');
|
||||
putchar('r');
|
||||
break;
|
||||
case '\"':
|
||||
putchar('\\');
|
||||
putchar('"');
|
||||
break;
|
||||
case '\t':
|
||||
putchar('\\');
|
||||
putchar('t');
|
||||
break;
|
||||
case '\\':
|
||||
putchar('\\');
|
||||
putchar('\\');
|
||||
break;
|
||||
default:
|
||||
if (*src <= 0x1F) {
|
||||
printf("\\u%04x", *src);
|
||||
} else {
|
||||
putchar(*src);
|
||||
}
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ends with zero char
|
||||
static inline void print_with_escapes(const unsigned char *src,
|
||||
|
@ -96,49 +54,6 @@ static inline void print_with_escapes(const unsigned char *src,
|
|||
}
|
||||
}
|
||||
|
||||
// print len chars
|
||||
static inline void print_with_escapes(const unsigned char *src, size_t len) {
|
||||
const unsigned char *finalsrc = src + len;
|
||||
while (src < finalsrc) {
|
||||
switch (*src) {
|
||||
case '\b':
|
||||
putchar('\\');
|
||||
putchar('b');
|
||||
break;
|
||||
case '\f':
|
||||
putchar('\\');
|
||||
putchar('f');
|
||||
break;
|
||||
case '\n':
|
||||
putchar('\\');
|
||||
putchar('n');
|
||||
break;
|
||||
case '\r':
|
||||
putchar('\\');
|
||||
putchar('r');
|
||||
break;
|
||||
case '\"':
|
||||
putchar('\\');
|
||||
putchar('"');
|
||||
break;
|
||||
case '\t':
|
||||
putchar('\\');
|
||||
putchar('t');
|
||||
break;
|
||||
case '\\':
|
||||
putchar('\\');
|
||||
putchar('\\');
|
||||
break;
|
||||
default:
|
||||
if (*src <= 0x1F) {
|
||||
printf("\\u%04x", *src);
|
||||
} else {
|
||||
putchar(*src);
|
||||
}
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
// print len chars
|
||||
static inline void print_with_escapes(const unsigned char *src,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "simdjson/common_defs.h"
|
||||
#include "simdjson/simdjson.h"
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#define JSON_VALUE_MASK 0xFFFFFFFFFFFFFF
|
||||
|
@ -53,7 +52,7 @@ public:
|
|||
// this should be called when parsing (right before writing the tapes)
|
||||
void init();
|
||||
|
||||
// print the json to stdout (should be valid)
|
||||
// print the json to std::ostream (should be valid)
|
||||
// return false if the tape is likely wrong (e.g., you did not parse a valid
|
||||
// JSON).
|
||||
WARN_UNUSED
|
||||
|
@ -137,19 +136,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
// dump bits low to high
|
||||
inline void dumpbits_always(uint64_t v, const std::string &msg) {
|
||||
for (uint32_t i = 0; i < 64; i++) {
|
||||
std::cout << (((v >> static_cast<uint64_t>(i)) & 0x1ULL) ? "1" : "_");
|
||||
}
|
||||
std::cout << " " << msg.c_str() << "\n";
|
||||
}
|
||||
|
||||
inline void dumpbits32_always(uint32_t v, const std::string &msg) {
|
||||
for (uint32_t i = 0; i < 32; i++) {
|
||||
std::cout << (((v >> i) & 0x1ULL) ? "1" : "_");
|
||||
}
|
||||
std::cout << " " << msg.c_str() << "\n";
|
||||
}
|
||||
} // namespace simdjson
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#ifdef _MSC_VER
|
||||
#include <iso646.h>
|
||||
|
|
|
@ -369,9 +369,6 @@ really_inline void json_structural_scanner::scan(const uint8_t *buf, const size_
|
|||
template<size_t STEP_SIZE>
|
||||
int find_structural_bits(const uint8_t *buf, size_t len, simdjson::ParsedJson &pj, bool streaming) {
|
||||
if (unlikely(len > pj.byte_capacity)) {
|
||||
std::cerr << "Your ParsedJson object only supports documents up to "
|
||||
<< pj.byte_capacity << " bytes but you are trying to process "
|
||||
<< len << " bytes" << std::endl;
|
||||
return simdjson::CAPACITY;
|
||||
}
|
||||
utf8_checker utf8_checker{};
|
||||
|
|
|
@ -75,7 +75,7 @@ int json_parse_dispatch(const uint8_t *buf, size_t len, ParsedJson &pj,
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
std::cerr << "The processor is not supported by simdjson." << std::endl;
|
||||
// The processor is not supported by simdjson.
|
||||
return simdjson::UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,7 @@ ParsedJson build_parsed_json(const uint8_t *buf, size_t len,
|
|||
bool ok = pj.allocate_capacity(len);
|
||||
if (ok) {
|
||||
json_parse(buf, len, pj, realloc);
|
||||
} else {
|
||||
std::cerr << "failure during memory allocation " << std::endl;
|
||||
}
|
||||
}
|
||||
return pj;
|
||||
}
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -232,7 +232,6 @@ void find_the_best_supported_implementation() {
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
std::cerr << "The processor is not supported by simdjson." << std::endl;
|
||||
// we throw an exception since this should not be recoverable
|
||||
throw new std::runtime_error("unsupported architecture");
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ bool ParsedJson::allocate_capacity(size_t len, size_t max_depth) {
|
|||
if (!string_buf || !tape ||
|
||||
!containing_scope_offset || !ret_address ||
|
||||
!structural_indexes) {
|
||||
std::cerr << "Could not allocate memory" << std::endl;
|
||||
// Could not allocate memory
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
|
@ -102,13 +102,11 @@ bool ParsedJson::print_json(std::ostream &os) const {
|
|||
if (type == 'r') {
|
||||
how_many = tape_val & JSON_VALUE_MASK;
|
||||
} else {
|
||||
fprintf(stderr, "Error: no starting root node?");
|
||||
// Error: no starting root node?
|
||||
return false;
|
||||
}
|
||||
if (how_many > tape_capacity) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"We may be exceeding the tape capacity. Is this a valid document?\n");
|
||||
// We may be exceeding the tape capacity. Is this a valid document?
|
||||
return false;
|
||||
}
|
||||
tape_idx++;
|
||||
|
@ -195,10 +193,10 @@ bool ParsedJson::print_json(std::ostream &os) const {
|
|||
os << ']';
|
||||
break;
|
||||
case 'r': // we start and end with the root node
|
||||
fprintf(stderr, "should we be hitting the root node?\n");
|
||||
// should we be hitting the root node?
|
||||
return false;
|
||||
default:
|
||||
fprintf(stderr, "bug %c\n", type);
|
||||
// bug?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +218,7 @@ bool ParsedJson::dump_raw_tape(std::ostream &os) const {
|
|||
if (type == 'r') {
|
||||
how_many = tape_val & JSON_VALUE_MASK;
|
||||
} else {
|
||||
fprintf(stderr, "Error: no starting root node?");
|
||||
// Error: no starting root node?
|
||||
return false;
|
||||
}
|
||||
os << "\t// pointing to " << how_many << " (right after last node)\n";
|
||||
|
@ -288,7 +286,7 @@ bool ParsedJson::dump_raw_tape(std::ostream &os) const {
|
|||
<< " (start of the scope) \n";
|
||||
break;
|
||||
case 'r': // we start and end with the root node
|
||||
fprintf(stderr, "should we be hitting the root node?\n");
|
||||
// should we be hitting the root node?
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "simdjson/portability.h"
|
||||
#include "simdjson/common_defs.h"
|
||||
|
|
Loading…
Reference in New Issue