Open ye-luo opened 5 years ago
How are you handling the read of/iteration over child XML elements for validation?
Another way of saying "make better use of our wrapper class" would be that we should properly abstract xml handling and not call libxml2 directly from anywhere other than the wrapper. This makes for any easy check on where to focus - any file importing or calling libxml2 other than the wrapper needs fixing.
It would be nice down the road to handle a each XML element with a single class instead of one class for attributes, another class for parameters, yet another for text, and (currently) no class for child elements.
(Removed) See discussion for this date in #407.
Long term the current input parsing needs to be totally rethought and redone. Here we do triage only i.e. use libxml2 correctly.
Agreed. I just wanted to keep the rethinking part going. I will move my comment to #407.
libxml2 is a C library and easy to leak memory if used improperly. See #1801 To avoid these problems, xml usage needs to be cleanly wrapped and we are doing so. The other purpose of wrapping is to do validation at the wrapper level.
Our wrapper classes live in src/OhmmsData XMLParsingString.h handles xml node content to string and one attribute to string. ParameterSet.h handles a set of parameters like
AttributeSet.h handles a set of attributes like
By grepping the source with xmlGet/xmlSet/xmlNew, I still find many direct use of xml outside the wrapper class. I think we can make better use of our wrapper class and kill all the ugly casting in
Also in QMCCostFunctionBase::updateXmlNodes we need the wrapper class to handle writing xml instead of doing it directly.