IO/config: parse from XML/JSON formatted string#309
IO/config: parse from XML/JSON formatted string#309
Conversation
|
@edoardolombardi FYI, since it's needed by mimic pull https://github.com/optimad/mimic/pull/386 |
579f512 to
56ea949
Compare
added Config specialization class (ConfigStringParser) to read and write XML (or JSON) directly on c++ string. The class is useful to exhange info without passing from filesystem each time. Enhanced IO integration tests 2 e 4 to prove the capabilities of the new class.
56ea949 to
ecbd298
Compare
src/IO/configuration_XML.cpp
Outdated
There was a problem hiding this comment.
Would it be possible to add a private function that takes in input a xmlTextWriterPtr? This will allow to share code between writeConfiguration and writeBufferConfiguration? For "symmetry", this apply also to "readBufferConfiguration".
In bitpit , arguments that are modified by the function are usually passed by pointer at the end of the argument list.
Do we really need a function with a different name? The signature of writeConfiguration and writeBufferConfiguration is different, we can use the same name.
I would still pass a "format" argument (also in the read* function). In this way the function that write the configuration to file and the one that write the configuration to string will generate the same output.
There was a problem hiding this comment.
You're right a compact code is always better. But since pending pull #267 and needs of issue #269 suggest a major underhood rework of tree interface and its parsing capabilities, and the introduction of rapidXML will make a lot easier to compact the code w.r.t. to libxml2, I think it's not the case to lose much time on this now.
| } | ||
|
|
||
| /*! | ||
| \class ConfigStringParser |
There was a problem hiding this comment.
Is this new class really needed? Can we just add an overload to the read/write functions of ConfigParser, this overloads will take in input the string and the format?
There was a problem hiding this comment.
Introducing a class of its own, without overhead of filesystem checks, version control, propagation to static utilities and whatsover was faster and simpler. As I mention earlier, introducing rapidXML instead of libxml2 can straightforward the I/O part a lot.
get rid of boolean for a more clear enum to select the string preferred format
|
For other questions: i think is not worth doing the works asked right now, since we need to rework the class very soon anyway. |
|
moved elsewhere. |
Added Config specialization class (ConfigStringParser) to read and write XML (or JSON) directly from and onto c++ string. The class is useful to exhange info without passing from filesystem each time.
Enhanced IO integration tests 2 e 4 to prove the capabilities of the new class.