bfgroup / b2

B2 makes it easy to build C++ projects, everywhere.
https://www.bfgroup.xyz/b2/
Boost Software License 1.0
75 stars 228 forks source link

Add property-db class to record & write structured data. #397

Closed grafikrobot closed 3 months ago

grafikrobot commented 3 months ago

Proposed changes

This adds a utility to record structured data in the form of a property database where the keys are a property path with string or number values. The data can be converted to a string, or written to a file, as JSON.

This will be used for near future recording and output of a compile database JSON file. And in the later future to produce and consume ecosystem interop information.

Types of changes

What types of changes does your code introduce?

grisumbras commented 3 months ago

Isn't nlohmann/json MIT-licensed?

grafikrobot commented 3 months ago

Isn't nlohmann/json MIT-licensed?

Yes it is. I haven't gotten around to adding a note in the docs for it.

grisumbras commented 3 months ago

I feel like adding MIT code into b2 will be extremely controvercial with Boost devs. Can I convince you to use a standalone version of Boost.JSON instead?

grafikrobot commented 3 months ago

@grisumbras it is my understanding, from having asked about using boost.json previously, that there is no standalone version of it any longer.

grisumbras commented 3 months ago

There is still a standalone fork. But it requires C++17. But I'm sure I can create a version that works with C++11.

grafikrobot commented 3 months ago

There is still a standalone fork. But it requires C++17. But I'm sure I can create a version that works with C++11.

Right.. I meant a standalone 11 version. I thought about making such changes. But never had the need or time. So if you can get such changes made I could use it instead. Even just for the plain reason that Boost.JSON is better software. I'll still go ahead with this PR though. As it's an implementation detail. And eventually I also see the need for using other non-BSL external code. So might as well think about what it means now.

vinniefalco commented 3 months ago

Boost.JSON is overkill if all you are doing is serializing. The only meaningful implementation work for serialization is the quoting and escaping of strings, and the conversion of double to string. We might consider creating a small, actively maintained library that only does JSON serialization, and without using the DOM (the json::value type).

grafikrobot commented 3 months ago

Boost.JSON is overkill if all you are doing is serializing.

I will need read and write in what I use (even if I'm only using write ATM). Not sure what "using the DOM" means though.