Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/danielaparker/jsoncons in…
Browse files Browse the repository at this point in the history
…to json_pointer
  • Loading branch information
danielaparker committed May 23, 2024
2 parents d16c677 + ba20164 commit 20131a7
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 180 deletions.
120 changes: 76 additions & 44 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,48 +137,80 @@ jobs:
- working-directory: build/
run: ctest -C ubuntu-latest --output-on-failure

# clang_build_cxx20:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
# - name: install_gcc
# run: |
# sudo apt update
# sudo apt install clang-14
# shell: bash
# - name: cmake
# run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
# env:
# CC: clang-14
# CXX: clang++-14
#
# - working-directory: build/
# run: cmake --build . --config ubuntu-latest
#
# - working-directory: build/
# run: ctest -C ubuntu-latest --output-on-failure

# gcc_build_48:
# name: GCC 4.8
# runs-on: ubuntu-18.04
#
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Install
# run: |
# sudo apt-get update -y -qq && sudo apt-get install -y -qq g++-4.8 binutils
# shell: bash
# - name: cmake
# run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
# env:
# CC: gcc-4.8
# CXX: g++-4.8
# - name: build
# run: cmake --build build --parallel 10
# - name: test
# run: cd build ; ctest -j 10 --output-on-failure

ci_test_compilers_gcc:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: ['6','7','8','9','10','11','12','latest']
container: gcc:${{ matrix.compiler }}
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/[email protected]
- name: cmake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
- name: build
run: cmake --build build
- name: test
run: cd build ; ctest --output-on-failure

ci_test_compilers_gcc2:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: ['12','latest']
container: gcc:${{ matrix.compiler }}
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/[email protected]
- name: cmake
run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
- name: build
run: cmake --build build
- name: test
run: cd build ; ctest --output-on-failure

ci_test_compilers_clang:
runs-on: ubuntu-latest
strategy:
matrix:
# compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '15-bullseye', 'latest']
compiler: ['3.9', '4', '5', '6', '7','8','9', '10', '11', '12', '13', '14', '15-bullseye']
container: silkeh/clang:${{ matrix.compiler }}
steps:
- name: Install unzip and git
run: apt-get update ; apt-get install -y unzip git
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/[email protected]
- name: cmake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On
- name: build
working-directory: build/
run: cmake --build .
- name: test
working-directory: build/
run: ctest --output-on-failure

ci_test_compilers_clang2:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: ['13', '15-bullseye']
container: silkeh/clang:${{ matrix.compiler }}
steps:
- name: Install unzip and git
run: apt-get update ; apt-get install -y unzip git
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/[email protected]
- name: cmake
run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
- name: build
working-directory: build/
run: cmake --build .
- name: test
working-directory: build/
run: ctest --output-on-failure

4 changes: 4 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug, Release]
architecture: [x64, x86]

runs-on: windows-latest

Expand All @@ -41,6 +42,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug, Release]
architecture: [x64, x86]

runs-on: windows-latest

Expand All @@ -66,6 +68,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug, Release]
architecture: [x64, x86]

runs-on: windows-2019

Expand All @@ -91,6 +94,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug, Release]
architecture: [x64, x86]

runs-on: windows-2019

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -719,21 +719,21 @@ string_value: 1.23456789012345678901234567890 (bigdec)

## Supported compilers

jsoncons requires a compiler with C++11 support. It is tested in continuous integration on [Github Actions](https://github.com/danielaparker/jsoncons/actions), [AppVeyor](https://ci.appveyor.com/project/danielaparker/jsoncons), [Travis](https://travis-ci.org/danielaparker/jsoncons), and [doozer](https://doozer.io/).
jsoncons requires a compiler with minimally C++11 support. It is tested in continuous integration on [Github Actions](https://github.com/danielaparker/jsoncons/actions) and [circleci](https://app.circleci.com/pipelines/circleci/EFpnYcrBiZEvYvns3VF4vT).
[UndefinedBehaviorSanitizer (UBSan)](http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) diagnostics are enabled for selected gcc and clang builds.
Since v0.151.0, it is integrated with [Google OSS-fuzz](https://github.com/google/oss-fuzz), with coverage for all parsers and encoders.

| Compiler | Version |Architecture | Operating System | Notes |
|-------------------------|---------------------------|-------------|-------------------|-------|
| Microsoft Visual Studio | vs2015 (MSVC 19.0.24241.7)| x86,x64 | Windows 10 | |
| | vs2017 | x86,x64 | Windows 10 | |
| | vs2019 | x86,x64 | Windows 10 | |
| g++ | 4.8 and above | x64 | Ubuntu |`std::regex` isn't fully implemented in 4.8, so `jsoncons::jsonpath` regular expression filters aren't supported in 4.8 |
| | 4.8.5 | x64 | CentOS 7.6 |`std::regex` isn't fully implemented in 4.8, so `jsoncons::jsonpath` regular expression filters aren't supported in 4.8 |
| | 6.3.1 (Red Hat 6.3.1-1) | x64 | Fedora release 24 | |
| | 4.9.2 | i386 | Debian 8 | |
| clang | 4.0, 5.0, 6.0, 7, 8, 9, 10| x64 | Ubuntu | |
| clang xcode | 9.3, 9.4, 10, 10.1, 10.2, 11.2, 12 | x64 | OSX | |
| Compiler | Version | Standard | Architecture | Operating System | CI Service |
|-------------------------|------------------------------------|--------------|--------------|------------------|----------------|
| Visual Studio | vs2019 | default | x86, x64 | Windows 10 | GitHub Actions |
| | vs2022 | default | x86, x64 | Windows 10 | GitHub Actions |
| Visual Studio - clang | vs2019 | default | x86, x64 | Windows 10 | GitHub Actions |
| | vs2022 | default | x86, x64 | Windows 10 | GitHub Actions |
| g++ | 10, 11 | c++17 | x64 | Ubuntu | GitHub Actions |
| clang | 13, 14 | default | x64 | Ubuntu | GitHub Actions |
| g++ | 6, 7, 8, 9, 10, 11, 12 | default | x64 | Ubuntu | circleci |
| clang | 3.9, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | default | x64 | Ubuntu | circleci |
| clang xcode | | c++17 | x64 | OSX | GitHub Actions |

## Building the test suite and examples with CMake

Expand Down
5 changes: 0 additions & 5 deletions examples/src/jsonpath_location_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
#include <jsoncons/json.hpp>
#include <jsoncons_ext/jsonpath/jsonpath.hpp>
#include <jsoncons_ext/jsonpointer/jsonpointer.hpp>
#include "FreeListAllocator.hpp"
#include <scoped_allocator>

template<typename T>
using MyScopedAllocator = std::scoped_allocator_adaptor<FreeListAllocator<T>>;

// for brevity
using jsoncons::json;
Expand Down
44 changes: 27 additions & 17 deletions include/jsoncons/config/compiler_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,26 @@
#include <exception>
#include <ostream>

#if defined (__clang__)
#define JSONCONS_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#if defined(__GNUC__)
# if defined(__GNUC_PATCHLEVEL__)
# define JSONCONS_GCC_AVAILABLE(major, minor, patch) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \
>= (major * 10000 + minor * 100 + patch))
# else
# define JSONCONS_GCC_AVAILABLE(major, minor, patch) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) \
>= (major * 10000 + minor * 100 + patch))
# endif
# else
# define JSONCONS_GCC_AVAILABLE(major, minor, patch) 0
#endif

#if defined(__clang__)
# define JSONCONS_CLANG_AVAILABLE(major, minor, patch) \
((__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) \
>= (major * 10000 + minor * 100 + patch))
# else
# define JSONCONS_CLANG_AVAILABLE(major, minor, patch) 0
#endif

// Uncomment the following line to suppress deprecated names (recommended for new code)
Expand All @@ -24,11 +42,6 @@
// MIT license

// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54577
#if defined(__clang__)
#elif defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
#define JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR 1
#define JSONCONS_NO_MAP_CONS_TAKES_ALLOCATOR 1
#endif

#if defined(__clang__)
# define JSONCONS_FALLTHROUGH [[clang::fallthrough]]
Expand Down Expand Up @@ -189,8 +202,8 @@
# if (defined JSONCONS_HAS_2017)
# if defined(__clang__)
# if defined(__APPLE__)
# if JSONCONS_CLANG_VERSION >= 100001
# define JSONCONS_HAS_STD_VARIANT 1
# if JSONCONS_CLANG_AVAILABLE(10,0,1)
# define JSONCONS_HAS_STD_VARIANT 1
# endif
# elif __has_include(<variant>)
# define JSONCONS_HAS_STD_VARIANT 1
Expand Down Expand Up @@ -345,10 +358,10 @@ namespace jsoncons {
#define JSONCONS_COPY(first,last,d_first) std::copy(first, last, d_first)
#endif

#if defined(_MSC_VER) && _MSC_VER <= 1900
#define JSONCONS_CONSTEXPR
#else
#if defined(JSONCONS_HAS_CP14)
#define JSONCONS_CONSTEXPR constexpr
#else
#define JSONCONS_CONSTEXPR
#endif

#if !defined(JSONCONS_HAS_STD_REGEX)
Expand All @@ -362,11 +375,8 @@ namespace jsoncons {
#endif

#if !defined(JSONCONS_HAS_STATEFUL_ALLOCATOR)
#if defined(__clang__)
#define JSONCONS_HAS_STATEFUL_ALLOCATOR 1
#elif (defined(__GNUC__) && (__GNUC__ == 4)) && (defined(__GNUC__) && __GNUC_MINOR__ < 9)
// gcc 4.8 basic_string doesn't satisfy C++11 allocator requirements
// and gcc doesn't support allocators with no default constructor
#if defined(__clang__) && !JSONCONS_CLANG_AVAILABLE(11,0,0)
#elif defined(__GNUC__) && !JSONCONS_GCC_AVAILABLE(10,0,0)
#else
#define JSONCONS_HAS_STATEFUL_ALLOCATOR 1
#endif
Expand Down
32 changes: 0 additions & 32 deletions include/jsoncons/json_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,12 @@ namespace jsoncons {

iterator erase(const_iterator pos)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it = elements_.begin() + (pos - elements_.begin());
return elements_.erase(it);
#else
return elements_.erase(pos);
#endif
}

iterator erase(const_iterator first, const_iterator last)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it1 = elements_.begin() + (first - elements_.begin());
iterator it2 = elements_.begin() + (last - elements_.begin());
return elements_.erase(it1,it2);
#else
return elements_.erase(first,last);
#endif
}

Json& operator[](std::size_t i) {return elements_[i];}
Expand All @@ -210,47 +199,26 @@ namespace jsoncons {
typename std::enable_if<extension_traits::is_stateless<A>::value,iterator>::type
insert(const_iterator pos, T&& value)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it = elements_.begin() + (pos - elements_.begin());
return elements_.emplace(it, std::forward<T>(value));
#else
return elements_.emplace(pos, std::forward<T>(value));
#endif
}
template <class T, class A=allocator_type>
typename std::enable_if<!extension_traits::is_stateless<A>::value,iterator>::type
insert(const_iterator pos, T&& value)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it = elements_.begin() + (pos - elements_.begin());
return elements_.emplace(it, std::forward<T>(value));
#else
return elements_.emplace(pos, std::forward<T>(value));
#endif
}

template <class InputIt>
iterator insert(const_iterator pos, InputIt first, InputIt last)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it = elements_.begin() + (pos - elements_.begin());
elements_.insert(it, first, last);
return first == last ? it : it + 1;
#else
return elements_.insert(pos, first, last);
#endif
}

template <class A=allocator_type, class... Args>
typename std::enable_if<extension_traits::is_stateless<A>::value,iterator>::type
emplace(const_iterator pos, Args&&... args)
{
#if defined(JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR)
iterator it = elements_.begin() + (pos - elements_.begin());
return elements_.emplace(it, std::forward<Args>(args)...);
#else
return elements_.emplace(pos, std::forward<Args>(args)...);
#endif
}

template <class... Args>
Expand Down
6 changes: 3 additions & 3 deletions include/jsoncons/json_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,17 +1065,17 @@ namespace detail {
{
static const std::array<CharT, 4>& null_constant()
{
static constexpr std::array<CharT,4> k{'n','u','l','l'};
static constexpr std::array<CharT,4> k{{'n','u','l','l'}};
return k;
}
static const std::array<CharT, 4>& true_constant()
{
static constexpr std::array<CharT,4> k{'t','r','u','e'};
static constexpr std::array<CharT,4> k{{'t','r','u','e'}};
return k;
}
static const std::array<CharT, 5>& false_constant()
{
static constexpr std::array<CharT,5> k{'f','a','l','s','e'};
static constexpr std::array<CharT,5> k{{'f','a','l','s','e'}};
return k;
}
public:
Expand Down
Loading

0 comments on commit 20131a7

Please sign in to comment.