Skip to content

Commit

Permalink
Add jsonpath example stateful allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Mar 13, 2023
1 parent 8c99d35 commit 4629aee
Show file tree
Hide file tree
Showing 236 changed files with 551 additions and 550 deletions.
3 changes: 2 additions & 1 deletion doc/ref/jsonpath/make_expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Output:
#### make_expression with stateful allocator

```c++
#include <string_view> // Assuming C++ 17
#include <jsoncons/json.hpp>
#include <jsoncons_ext/jsonpath/jsonpath.hpp>
#include "sample_allocators.hpp" // for FreelistAllocator
Expand All @@ -222,7 +223,7 @@ int main()

my_json doc = decoder.get_result();

jsoncons::string_view p{"$.books[?(@.category == 'fiction')].title"};
std::string_view p{"$.books[?(@.category == 'fiction')].title"};
auto expr = jsoncons::jsonpath::make_expression<my_json>(std::allocator_arg, alloc, p);
auto result = expr.evaluate(doc);

Expand Down
2 changes: 1 addition & 1 deletion examples/src/array_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bson_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/byte_string_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/cbor_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/cbor_typed_array_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/container_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/csv_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data_model_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/jmespath_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_accessor_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_constructor_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_cursor_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json_cursor.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_filter_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_merge_patch_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_parser_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_reader_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_bitset_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_integer_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_macros_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_name_macro_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_polymorphic_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_tuple_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_variant_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/jsonpatch_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
6 changes: 3 additions & 3 deletions examples/src/jsonpath_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
#include <string_view>
#include <fstream>
#include <cmath>
#include <cassert>
Expand Down Expand Up @@ -848,7 +848,7 @@ namespace {
my_json doc = decoder.get_result();
std::cout << pretty_print(doc) << "\n\n";

jsoncons::string_view p{"$.books[?(@.category == 'fiction')].title"};
std::string_view p{"$.books[?(@.category == 'fiction')].title"};
auto expr = jsoncons::jsonpath::make_expression<my_json>(std::allocator_arg, alloc, p);
auto result = expr.evaluate(doc);

Expand Down
2 changes: 1 addition & 1 deletion examples/src/jsonpointer_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/jsonschema_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/msgpack_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/ojson_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/readme_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include "sample_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/src/sample_allocators.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#ifndef SAMPLE_ALLOCATORS_HPP
Expand Down
2 changes: 1 addition & 1 deletion examples/src/serialization_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/staj_iterator_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/type_extensibility_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include "sample_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/src/ubjson_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include "sample_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/src/unicode_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/wjson_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples_boost/more_examples/src/extensibility.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <jsoncons/json.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples_boost/more_examples/src/more_examples.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion examples_boost/more_examples/src/pool_allocator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under Boost license

#include <boost/pool/pool_alloc.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/allocator_holder.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/basic_json.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/byte_string.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/config/compiler_support.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/config/jsoncons_config.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/config/version.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/conv_error.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Copyright 2019 Daniel Parker
/// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/decode_json.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/decode_traits.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/detail/optional.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/detail/parse_number.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/detail/string_view.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/detail/string_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/detail/write_number.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/encode_json.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/encode_traits.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/json.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/json_array.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/json_content_handler.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
2 changes: 1 addition & 1 deletion include/jsoncons/json_cursor.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Daniel Parker
// Copyright 2013-2023 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Expand Down
Loading

0 comments on commit 4629aee

Please sign in to comment.