From d0e841d3e90a98fe16234a07e76fb14a49d56c06 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 6 Nov 2025 12:00:21 -0500 Subject: [PATCH] Release Candidate 4.2.2 (#2539) * adding documentation. * release candidate --- CMakeLists.txt | 2 +- Doxyfile | 2 +- doc/basics.md | 3 + doc/dom.md | 16 +++++ include/simdjson/padded_string-inl.h | 4 +- include/simdjson/simdjson_version.h | 4 +- singleheader/simdjson.cpp | 30 +++++++- singleheader/simdjson.h | 104 ++++++++++++++++++++++++++- singleheader/singleheader.zip | Bin 8808576 -> 8811616 bytes 9 files changed, 154 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b77d6d53..a794ec09c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) project( simdjson # The version number is modified by tools/release.py - VERSION 4.2.1 + VERSION 4.2.2 DESCRIPTION "Parsing gigabytes of JSON per second" HOMEPAGE_URL "https://simdjson.org/" LANGUAGES CXX C diff --git a/Doxyfile b/Doxyfile index 1fa420224..a6bac3ed9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = simdjson # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "4.2.1" +PROJECT_NUMBER = "4.2.2" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/basics.md b/doc/basics.md index 7b782fbb8..c25262df8 100644 --- a/doc/basics.md +++ b/doc/basics.md @@ -183,6 +183,9 @@ auto json = padded_string::load("twitter.json"); // load JSON file 'twitter.json ondemand::document doc = parser.iterate(json); // position a pointer at the beginning of the JSON data ``` +(Windows users compiling with C++17 or better may use `wchar_t` strings to support non-ASCII +filenames: `padded_string::load(L"twitter.json")`.) + If you prefer not to create your own `ondemand::parser` instance, you can access a thread-local version by calling `ondemand::parser.get_parser()`. diff --git a/doc/dom.md b/doc/dom.md index b706a36f4..a13dd2c35 100644 --- a/doc/dom.md +++ b/doc/dom.md @@ -54,6 +54,22 @@ dom::parser parser; dom::element doc = parser.parse("[1,2,3]"_padded); // parse a string, the _padded suffix creates a simdjson::padded_string instance ``` +You can also load a `padded_string` from a file. + + +```cpp +auto json = padded_string::load("twitter.json"); // load JSON file 'twitter.json'. +dom::element doc = parser.parse(json); +``` + +(Windows users compiling with C++17 or better may use `wchar_t` strings to support non-ASCII +filenames: `padded_string::load(L"twitter.json")`.) + + +(Windows users compiling with C++17 or better may use `wchar_t` strings to support non-ASCII +filenames: `padded_string::load(L"twitter.json")`.) + + You can copy your data directly on a `simdjson::padded_string` as follows: ```cpp diff --git a/include/simdjson/padded_string-inl.h b/include/simdjson/padded_string-inl.h index cbc6743c4..edc8de10a 100644 --- a/include/simdjson/padded_string-inl.h +++ b/include/simdjson/padded_string-inl.h @@ -8,10 +8,8 @@ #include "simdjson/padded_string_view-inl.h" #include +#include -#if defined(_WIN32) && SIMDJSON_CPLUSPLUS17 - #include -#endif namespace simdjson { namespace internal { diff --git a/include/simdjson/simdjson_version.h b/include/simdjson/simdjson_version.h index ec4270baf..4e4cea7ec 100644 --- a/include/simdjson/simdjson_version.h +++ b/include/simdjson/simdjson_version.h @@ -4,7 +4,7 @@ #define SIMDJSON_SIMDJSON_VERSION_H /** The version of simdjson being used (major.minor.revision) */ -#define SIMDJSON_VERSION "4.2.1" +#define SIMDJSON_VERSION "4.2.2" namespace simdjson { enum { @@ -19,7 +19,7 @@ enum { /** * The revision (major.minor.REVISION) of simdjson being used. */ - SIMDJSON_VERSION_REVISION = 1 + SIMDJSON_VERSION_REVISION = 2 }; } // namespace simdjson diff --git a/singleheader/simdjson.cpp b/singleheader/simdjson.cpp index 6e35e4ebf..a15a6b79d 100644 --- a/singleheader/simdjson.cpp +++ b/singleheader/simdjson.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-11-03 11:03:21 -0500. version 4.2.1 Do not edit! */ +/* auto-generated on 2025-11-05 11:42:38 -0500. version 4.2.2 Do not edit! */ /* including simdjson.cpp: */ /* begin file simdjson.cpp */ #define SIMDJSON_SRC_SIMDJSON_CPP @@ -2752,6 +2752,8 @@ struct simdjson_result_base : protected std::pair { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; }; // struct simdjson_result_base } // namespace internal @@ -2863,6 +2865,8 @@ struct simdjson_result : public internal::simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; }; // struct simdjson_result #if SIMDJSON_EXCEPTIONS @@ -10105,6 +10109,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -16600,6 +16607,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -22950,6 +22960,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -29457,6 +29470,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -36323,6 +36339,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -43011,6 +43030,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -49145,6 +49167,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -54871,6 +54896,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ diff --git a/singleheader/simdjson.h b/singleheader/simdjson.h index 37ace6d70..c9f91ccfb 100644 --- a/singleheader/simdjson.h +++ b/singleheader/simdjson.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-11-03 11:03:21 -0500. version 4.2.1 Do not edit! */ +/* auto-generated on 2025-11-05 11:42:38 -0500. version 4.2.2 Do not edit! */ /* including simdjson.h: */ /* begin file simdjson.h */ #ifndef SIMDJSON_H @@ -2513,7 +2513,7 @@ namespace std { #define SIMDJSON_SIMDJSON_VERSION_H /** The version of simdjson being used (major.minor.revision) */ -#define SIMDJSON_VERSION "4.2.1" +#define SIMDJSON_VERSION "4.2.2" namespace simdjson { enum { @@ -2528,7 +2528,7 @@ enum { /** * The revision (major.minor.REVISION) of simdjson being used. */ - SIMDJSON_VERSION_REVISION = 1 + SIMDJSON_VERSION_REVISION = 2 }; } // namespace simdjson @@ -2815,6 +2815,8 @@ struct simdjson_result_base : protected std::pair { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; }; // struct simdjson_result_base } // namespace internal @@ -2926,6 +2928,8 @@ struct simdjson_result : public internal::simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; }; // struct simdjson_result #if SIMDJSON_EXCEPTIONS @@ -4165,6 +4169,19 @@ struct padded_string final { **/ inline static simdjson_result load(std::string_view path) noexcept; + #if defined(_WIN32) && SIMDJSON_CPLUSPLUS17 + /** + * This function accepts a wide string path (UTF-16) and converts it to + * UTF-8 before loading the file. This allows windows users to work + * with unicode file paths without manually converting the paths everytime. + * + * @return IO_ERROR on error, including conversion failures. + * + * @param path the path to the file as a wide string. + **/ + inline static simdjson_result load(std::wstring_view path) noexcept; + #endif + private: padded_string &operator=(const padded_string &o) = delete; padded_string(const padded_string &o) = delete; @@ -4476,6 +4493,7 @@ inline padded_string_view pad_with_reserve(std::string& s) noexcept { /* end file simdjson/padded_string_view-inl.h */ #include +#include namespace simdjson { namespace internal { @@ -4653,6 +4671,62 @@ inline simdjson_result padded_string::load(std::string_view filen return s; } +#if defined(_WIN32) && SIMDJSON_CPLUSPLUS17 +inline simdjson_result padded_string::load(std::wstring_view filename) noexcept { + // Open the file using the wide characters + SIMDJSON_PUSH_DISABLE_WARNINGS + SIMDJSON_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC: manually verified this is safe + std::FILE *fp = _wfopen(filename.data(), L"rb"); + SIMDJSON_POP_DISABLE_WARNINGS + + if (fp == nullptr) { + return IO_ERROR; + } + + // Get the file size + int ret; +#if SIMDJSON_VISUAL_STUDIO && !SIMDJSON_IS_32BITS + ret = _fseeki64(fp, 0, SEEK_END); +#else + ret = std::fseek(fp, 0, SEEK_END); +#endif // _WIN64 + if(ret < 0) { + std::fclose(fp); + return IO_ERROR; + } +#if SIMDJSON_VISUAL_STUDIO && !SIMDJSON_IS_32BITS + __int64 llen = _ftelli64(fp); + if(llen == -1L) { + std::fclose(fp); + return IO_ERROR; + } +#else + long llen = std::ftell(fp); + if((llen < 0) || (llen == LONG_MAX)) { + std::fclose(fp); + return IO_ERROR; + } +#endif + + // Allocate the padded_string + size_t len = static_cast(llen); + padded_string s(len); + if (s.data() == nullptr) { + std::fclose(fp); + return MEMALLOC; + } + + // Read the padded_string + std::rewind(fp); + size_t bytes_read = std::fread(s.data(), 1, len, fp); + if (std::fclose(fp) != 0 || bytes_read != len) { + return IO_ERROR; + } + + return s; +} +#endif + } // namespace simdjson inline simdjson::padded_string operator ""_padded(const char *str, size_t len) { @@ -12996,6 +13070,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -15191,6 +15268,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -17885,6 +17965,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -20579,6 +20662,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -23388,6 +23474,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -26513,6 +26602,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -29115,6 +29207,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ @@ -31730,6 +31825,9 @@ struct implementation_simdjson_result_base { */ simdjson_inline T&& value_unsafe() && noexcept; + using value_type = T; + using error_type = error_code; + protected: /** users should never directly access first and second. **/ T first{}; /** Users should never directly access 'first'. **/ diff --git a/singleheader/singleheader.zip b/singleheader/singleheader.zip index 7491e033dcb26a5df741597d496ac61208bff6e0..7ec0cadcb987506b6974f817014d985a97b609ff 100644 GIT binary patch delta 2560 zcmciET})F~00(ed0VgU#`Epdpp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