p4c
p4c copied to clipboard
JSONGenerator/Loader cleanups
In trying to use the JSONGenerator/Loader code for additional things, I found a number of ways in which they are tricky to use and easy to use incorrectly (as well as some ways they are used incorrectly), mostly due to having exposed internals. So I made all those internals private and provided a cleaner interface to be used
- JSONGenerator now uses
emitmethods to output values (rather than allowing<< arbitrary textwhich was erro prone), and ensures that objects only contain key-value pairs and vector only contain values (no keys) and things match up properly. - JSONLoader now provides
istester methods for checking that values are the expected type, and manages its internal memory withunique_ptrso as to not require the garbage collector.