nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
41.33k stars 6.58k forks source link

using allocator for bson #4167

Open alexfishgait1234 opened 9 months ago

alexfishgait1234 commented 9 months ago

[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]

we need some json functionality completely without any memory allocations. That means passing allocators als template parameter to different classes: parser,binary_reader,inputadapter,sax_dom_parser,lexer. json functions that need to use custom memory allocator: to_bson;from_bson;parse. Some std containers in lib are not allocator aware: -std::vector token_string - lexer -std::vector<BasicJsonType> ref_stack - json_sax.hpp we need 2 types of allocator as template parameter : basic_json and char_type(char) there are also make_shared ptr in output adapter which should be replaced with allocate_shared. some other minor conversions functions which allocate.

usage from our client code will be as follows: namespace rtjson { using json = nlohmann::basic_json<std::map, std::vector, sqp::core::rtutils::RtString, //use rtstring bool, long long, unsigned long long, double, sqp::core::memory::PolymorphicAllocator, //use polymorpic allocator

                              nlohmann::adl_serializer>;

} // namespace ext

using json = rtjson::json;

Pull request checklist

Read the Contribution Guidelines for detailed information.

Please don't

github-actions[bot] commented 9 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @alexfishgait1234 Please read and follow the Contribution Guidelines.

coveralls commented 9 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling cf81aa75b61ab8fab93471ca274f85e6798908aa on swissQprint:feature/afi/RtBson into fac07e22c5d7dd0423ccf31c02db5603d27e6556 on nlohmann:develop.

gregmarr commented 9 months ago

@alexfishgait1234 You made your changes in the single_include file, which is generated from the individual files in the include directory. You need to change the individual files and then update the single_include version using make amalgamate.

alexfishgait1234 commented 9 months ago

Hoi.thanks a lot for writing. Sorry for the mess.i wanted to create pull request in our forked local repo in order to test it but by mistake did it for your develop.its still draft of course. We want to use bson format without any memory allocation with our real-time string and allocator.i found all places where this allocator support is missing and trying to implement it.this lib is really greater and we want to integrate it in our real time product.thanks a lot .alex

On Fri, Sep 29, 2023, 17:31 Niels Lohmann @.***> wrote:

@.**** requested changes on this pull request.

  • Please amalgamate.
  • Please add a proper description of the changes. Why are they needed? What is the benefit?
  • Please add a test case using the allocator and the string type.

— Reply to this email directly, view it on GitHub https://github.com/nlohmann/json/pull/4167#pullrequestreview-1651036275, or unsubscribe https://github.com/notifications/unsubscribe-auth/AODNI3FSYIBLO3STSUFCEJTX43SVVANCNFSM6AAAAAA5MKXRBQ . You are receiving this because you were mentioned.Message ID: @.***>

github-actions[bot] commented 9 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @alexfishgait1234 Please read and follow the Contribution Guidelines.

alexfishgait1234 commented 9 months ago

how can i remove single_include/hnohmann/json.hpp from pull request please?

github-actions[bot] commented 9 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @alexfishgait1234 Please read and follow the Contribution Guidelines.

github-actions[bot] commented 9 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @alexfishgait1234 Please read and follow the Contribution Guidelines.