Create top level simdjson.h (#515)

- Allows everyone to #include the same way, singleheader or not.
This commit is contained in:
John Keiser 2020-03-02 14:23:19 -08:00
parent 0b21203141
commit 99667f7c55
51 changed files with 1526 additions and 1513 deletions

View File

@ -27,19 +27,7 @@ stage2_build_tape.cpp
# order matters
ALLCHEADERS="
simdjson/simdjson_version.h
simdjson/portability.h
simdjson/isadetection.h
simdjson/jsonformatutils.h
simdjson/simdjson.h
simdjson/common_defs.h
simdjson/padded_string.h
simdjson/jsonioutil.h
simdjson/jsonminifier.h
simdjson/document.h
simdjson/parsedjson.h
simdjson/jsonparser.h
simdjson/jsonstream.h
simdjson.h
"
found_includes=()

View File

@ -1,6 +1,5 @@
#include <benchmark/benchmark.h>
#include "simdjson/document.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
using namespace simdjson;
using namespace benchmark;
using namespace std;

View File

@ -29,11 +29,8 @@
#ifdef __linux__
#include <libgen.h>
#endif
//#define DEBUG
#include "simdjson/common_defs.h"
#include "simdjson/isadetection.h"
#include "simdjson/jsonioutil.h"
#include "simdjson/document.h"
#include "simdjson.h"
#include <functional>

View File

@ -32,11 +32,7 @@
#include <libgen.h>
#endif
//#define DEBUG
#include "simdjson/common_defs.h"
#include "simdjson/isadetection.h"
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson/document.h"
#include "simdjson.h"
#include <functional>

View File

@ -1,5 +1,4 @@
#include "simdjson/jsonioutil.h"
#include "simdjson/document.h"
#include "simdjson.h"
#include <algorithm>
#include <unistd.h>
#include <vector>

View File

@ -29,9 +29,8 @@
#ifdef __linux__
#include <libgen.h>
#endif
//#define DEBUG
#include "simdjson/common_defs.h"
#include "simdjson/isadetection.h"
#include "simdjson.h"
using std::string;
using std::vector;

View File

@ -1,7 +1,5 @@
#include "simdjson/common_defs.h"
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <chrono>
#include <cstring>
#include <iostream>

View File

@ -2,9 +2,7 @@
#include <unistd.h>
#include "benchmark.h"
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonminifier.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
// #define RAPIDJSON_SSE2 // bad
// #define RAPIDJSON_SSE42 // bad

View File

@ -28,11 +28,8 @@
#ifdef __linux__
#include <libgen.h>
#endif
//#define DEBUG
#include "simdjson/common_defs.h"
#include "simdjson/isadetection.h"
#include "simdjson/jsonioutil.h"
#include "simdjson/document.h"
#include "simdjson.h"
#include <functional>

View File

@ -2,10 +2,8 @@
#include <algorithm>
#include <chrono>
#include <vector>
#include "simdjson/jsonstream.h"
#include "simdjson.h"
#include <map>
#include "simdjson/jsonparser.h"
#include "simdjson/parsedjson.h"
#define NB_ITERATION 5
#define MIN_BATCH_SIZE 200000

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <unistd.h>
#include "benchmark.h"

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#ifndef _MSC_VER
#include "linux-perf-events.h"
#include <unistd.h>
@ -48,7 +48,7 @@ using namespace rapidjson;
#ifdef ALLPARSER
// fastjson has a tricky interface
void on_json_error(void *, const fastjson::ErrorContext &ec) {
void on_json_error(void *, UNUSED const fastjson::ErrorContext &ec) {
// std::cerr<<"ERROR: "<<ec.mesg<<std::endl;
}
bool fastjson_parse(const char *input) {

View File

@ -2,8 +2,7 @@
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#ifdef __linux__
#include "linux-perf-events.h"
#endif

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <cstddef>
#include <cstdint>
#include <iostream>

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <cstddef>
#include <cstdint>
#include <iostream>

View File

@ -1,5 +1,5 @@
#include "simdjson/jsonminifier.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include "simdjson.h"
#include <cstddef>
#include <cstdint>
#include <string>

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <cstddef>
#include <cstdint>
#include <string>

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <cstddef>
#include <cstdint>
#include <string>

25
include/simdjson.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef SIMDJSON_H
#define SIMDJSON_H
#include "simdjson/compiler_check.h"
// Public API
#include "simdjson/simdjson_version.h"
#include "simdjson/error.h"
#include "simdjson/padded_string.h"
#include "simdjson/implementation.h"
#include "simdjson/document.h"
#include "simdjson/jsonstream.h"
#include "simdjson/jsonminifier.h"
// Deprecated API
#include "simdjson/parsedjsoniterator.h"
#include "simdjson/jsonparser.h"
#include "simdjson/parsedjson.h"
#include "simdjson/document_iterator.h"
// Inline functions
#include "simdjson/inline/document.h"
#include "simdjson/inline/document_iterator.h"
#endif // SIMDJSON_H

View File

@ -0,0 +1,20 @@
#ifndef SIMDJSON_COMPILER_CHECK_H
#define SIMDJSON_COMPILER_CHECK_H
#ifndef __cplusplus
#error simdjson requires a C++ compiler
#endif
#ifndef SIMDJSON_CPLUSPLUS
#if defined(_MSVC_LANG) && !defined(__clang__)
#define SIMDJSON_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
#else
#define SIMDJSON_CPLUSPLUS __cplusplus
#endif
#endif
#if (SIMDJSON_CPLUSPLUS < 201703L)
#error simdjson requires a compiler compliant with the C++17 standard
#endif
#endif // SIMDJSON_COMPILER_CHECK_H

View File

@ -1084,7 +1084,4 @@ private:
} // namespace simdjson
#include "simdjson/inline/document.h"
#include "simdjson/document_iterator.h"
#endif // SIMDJSON_DOCUMENT_H

View File

@ -261,6 +261,4 @@ public:
} // namespace simdjson
#include "simdjson/inline/document_iterator.h"
#endif // SIMDJSON_DOCUMENT_ITERATOR_H

View File

@ -1,6 +1,3 @@
// Declaration order requires we get to document.h before implementation.h no matter what
#include "simdjson/document.h"
#ifndef SIMDJSON_IMPLEMENTATION_H
#define SIMDJSON_IMPLEMENTATION_H
@ -8,6 +5,7 @@
#include <string>
#include <atomic>
#include <vector>
#include "simdjson/document.h"
namespace simdjson {

View File

@ -1,9 +1,7 @@
#ifndef SIMDJSON_INLINE_DOCUMENT_H
#define SIMDJSON_INLINE_DOCUMENT_H
#ifndef SIMDJSON_DOCUMENT_H
#error This is an internal file only. Include document.h instead.
#endif
#include "simdjson/document.h"
// Inline implementations go in here if they aren't small enough to go in the class itself or if
// there are complex header file dependencies that need to be broken by externalizing the

View File

@ -1,9 +1,7 @@
#ifndef SIMDJSON_INLINE_DOCUMENT_ITERATOR_H
#define SIMDJSON_INLINE_DOCUMENT_ITERATOR_H
#ifndef SIMDJSON_DOCUMENT_ITERATOR_H
#error This is an internal file only. Include document.h instead.
#endif
#include "simdjson/document_iterator.h"
namespace simdjson {

View File

@ -3,6 +3,6 @@
#ifndef SIMDJSON_PARSEDJSONITERATOR_H
#define SIMDJSON_PARSEDJSONITERATOR_H
#include "document_iterator.h"
#include "simdjson/document_iterator.h"
#endif

View File

@ -1,22 +1,11 @@
/**
* @file
* @deprecated We'll be removing this file so it isn't confused with the top level simdjson.h
*/
#ifndef SIMDJSON_SIMDJSON_H
#define SIMDJSON_SIMDJSON_H
#ifndef __cplusplus
#error simdjson requires a C++ compiler
#endif
#ifndef SIMDJSON_CPLUSPLUS
#if defined(_MSVC_LANG) && !defined(__clang__)
#define SIMDJSON_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
#else
#define SIMDJSON_CPLUSPLUS __cplusplus
#endif
#endif
#if (SIMDJSON_CPLUSPLUS < 201703L)
#error simdjson requires a compiler compliant with the C++17 standard
#endif
#include "simdjson/compiler_check.h"
#include "simdjson/error.h"
#endif // SIMDJSON_H

View File

@ -1,4 +1,4 @@
/* auto-generated on Sat Feb 22 10:41:58 PST 2020. Do not edit! */
/* auto-generated on Mon Mar 2 14:10:52 PST 2020. Do not edit! */
#include <iostream>
#include "simdjson.h"
@ -11,7 +11,9 @@ int main(int argc, char *argv[]) {
simdjson::padded_string p = simdjson::get_corpus(filename);
auto [doc, error] = simdjson::document::parse(p); // do the parsing
if (error) {
std::cout << "document::parse not valid" << std::endl;
std::cout << "document::parse failed" << std::endl;
std::cout << "error code: " << error << std::endl;
std::cout << error_message(error) << std::endl;
} else {
std::cout << "document::parse valid" << std::endl;
}

View File

@ -1,4 +1,4 @@
/* auto-generated on Sat Feb 22 10:41:58 PST 2020. Do not edit! */
/* auto-generated on Mon Mar 2 14:10:52 PST 2020. Do not edit! */
#include "simdjson.h"
/* used for http://dmalloc.com/ Dmalloc - Debug Malloc Library */

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
#include "simdjson/portability.h"
#include "arm64/intrinsics.h"
#include "arm64/bitmanipulation.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>

View File

@ -7,7 +7,7 @@
#include "arm64/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "arm64/intrinsics.h"
#include "arm64/bitmanipulation.h"

View File

@ -1,6 +1,6 @@
#include "simdjson/document.h"
#include "simdjson/inline/document.h"
#include "simdjson/jsonformatutils.h"
#include "simdjson/document.h"
namespace simdjson {

View File

@ -374,9 +374,9 @@ never_inline bool parse_large_integer(const uint8_t *const buf,
// content and append a space before calling this function.
//
// Our objective is accurate parsing (ULP of 0 or 1) at high speed.
really_inline bool parse_number(const uint8_t *const buf,
const uint32_t offset,
bool found_minus,
really_inline bool parse_number(UNUSED const uint8_t *const buf,
UNUSED const uint32_t offset,
UNUSED bool found_minus,
document::parser &parser) {
#ifdef SIMDJSON_SKIPNUMBERPARSING // for performance analysis, it is sometimes
// useful to skip parsing

View File

@ -7,7 +7,7 @@
#include "simdjson/portability.h"
#include "haswell/intrinsics.h"
#include "haswell/bitmanipulation.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>

View File

@ -7,7 +7,7 @@
#include "haswell/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "haswell/intrinsics.h"
#include "haswell/bitmanipulation.h"

View File

@ -10,7 +10,7 @@
#include "simdjson/portability.h"
#include "westmere/intrinsics.h"
#include "westmere/bitmanipulation.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>

View File

@ -7,7 +7,7 @@
#include "westmere/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/parsedjson.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "westmere/intrinsics.h"
#include "westmere/bitmanipulation.h"

View File

@ -1,6 +1,6 @@
#include <unistd.h>
#include "simdjson/jsonparser.h"
#include "simdjson.h"
// #define RAPIDJSON_SSE2 // bad
// #define RAPIDJSON_SSE42 // bad

View File

@ -10,9 +10,7 @@
#include <set>
#include <string_view>
#include "simdjson/jsonparser.h"
#include "simdjson/jsonstream.h"
#include "simdjson/document.h"
#include "simdjson.h"
#ifndef JSON_TEST_PATH
#define JSON_TEST_PATH "jsonexamples/twitter.json"

View File

@ -3,8 +3,7 @@
#include <iostream>
#include <limits>
#include "simdjson/jsonparser.h"
#include "simdjson/document.h"
#include "simdjson.h"
using namespace simdjson;

View File

@ -12,7 +12,7 @@
#include <cstdio>
#include <cstdlib>
#include "simdjson/jsonparser.h"
#include "simdjson.h"
/**
* Does the file filename ends with the given extension.

View File

@ -11,9 +11,8 @@
#include <cstdio>
#include <cstdlib>
#include <simdjson/jsonstream.h>
#include "simdjson/jsonparser.h"
#include "simdjson.h"
/**
* Does the file filename ends with the given extension.

View File

@ -11,7 +11,7 @@
#define JSON_TEST_NUMBERS
#endif
#include "simdjson/common_defs.h"
#include "simdjson.h"
// ulp distance
// Marc B. Reynolds, 2016-2019
@ -132,7 +132,7 @@ void found_float(double result, const uint8_t *buf) {
}
}
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include "src/stage2_build_tape.cpp"
/**

View File

@ -1,7 +1,6 @@
#include <iostream>
#include "simdjson/jsonparser.h"
#include "simdjson/parsedjson.h"
#include "simdjson.h"
int main() {
// {"/~01abc": [0, {"\\\" 0": ["value0", "value1"]}]}"

View File

@ -1,6 +1,5 @@
#include <iostream>
#include "simdjson/document.h"
#include "simdjson/jsonioutil.h"
#include "simdjson.h"
using namespace std;
using namespace simdjson;
@ -10,7 +9,7 @@ void document_parse_error_code() {
string json("[ 1, 2, 3 ]");
auto [doc, error] = document::parse(json);
if (error) { cerr << "Error: " << error_message(error) << endl; exit(1); }
doc.print_json(cout);
UNUSED doc.print_json(cout);
cout << endl;
}
@ -19,7 +18,7 @@ void document_parse_exception() {
string json("[ 1, 2, 3 ]");
document doc = document::parse(json);
doc.print_json(cout);
UNUSED doc.print_json(cout);
cout << endl;
}
@ -28,7 +27,7 @@ void document_parse_padded_string() {
padded_string json(string("[ 1, 2, 3 ]"));
document doc = document::parse(json);
doc.print_json(cout);
UNUSED doc.print_json(cout);
cout << endl;
}
@ -37,7 +36,7 @@ void document_parse_get_corpus() {
padded_string json(get_corpus("jsonexamples/small/demo.json"));
document doc = document::parse(json);
doc.print_json(cout);
UNUSED doc.print_json(cout);
cout << endl;
}
@ -53,7 +52,7 @@ void parser_parse() {
cout << "Parsing " << json.data() << " ..." << endl;
auto [doc, error] = parser.parse(json);
if (error) { cerr << "Error: " << error_message(error) << endl; exit(1); }
doc.print_json(cout);
UNUSED doc.print_json(cout);
cout << endl;
}
}

View File

@ -13,7 +13,7 @@
#define JSON_TEST_STRINGS
#endif
#include "simdjson/common_defs.h"
#include "simdjson.h"
char *fullpath;
@ -289,7 +289,7 @@ void found_string(const uint8_t *buf, const uint8_t *parsed_begin,
}
}
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include "src/stage2_build_tape.cpp"
/**

View File

@ -2,8 +2,7 @@
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
void compute_dump(simdjson::ParsedJson::Iterator &pjh) {
if (pjh.is_object()) {

View File

@ -1,5 +1,4 @@
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
#include <iostream>
void compute_dump(simdjson::ParsedJson::Iterator &pjh) {

View File

@ -1,7 +1,6 @@
#include <iostream>
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
#include "simdjson.h"
size_t count_nonasciibytes(const uint8_t *input, size_t length) {
size_t count = 0;

View File

@ -1,7 +1,6 @@
#include <iostream>
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonminifier.h"
#include "simdjson.h"
int main(int argc, char *argv[]) {
if (argc != 2) {