Loading CMakeLists.txt 0 → 100644 +22 −0 Original line number Diff line number Diff line cmake_minimum_required (VERSION 2.6) project (GNPDS_PARSER) SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") SET (PUGIXML_PATH /Path_to_pugixml/src/) FILE(GLOB OURS ${CMAKE_CURRENT_SOURCE_DIR}/gnd/*.cpp) INCLUDE_DIRECTORIES( gnd ${PUGIXML_PATH}) SET (SOURCES ${PUGIXML_PATH}/pugiconfig.hpp ${PUGIXML_PATH}/pugixml.cpp ${OURS} xml/XmlElement.cpp xml/XmlEndfReader.cpp Container.cpp ArrayContainer.cpp TableContainer.cpp ValuesContainer.cpp ) add_executable(GndsParser main.cpp ${SOURCES}) FromJson/GenerateFromJson.py +0 −56 Original line number Diff line number Diff line Loading @@ -67,59 +67,3 @@ if __name__ == "__main__": writer.writeClass(classList.contextList[c][e], outDir) writerC = mClass.MakeClassDefinition(e, c, enumList, classList) writerC.writeClass(classList.contextList[c][e], outDir) # generate a test environment so that we can compile the classes # without AMPX environment scriptDir = os.path.dirname(os.path.realpath(__file__)) utilInfo = util.UtilityClass(None, None) file = open(outDir + '/main.' + utilInfo.classExtension,'w') cmake_min_version = '2.6' qt_min_version = '4.4.3' cpp_standard = 'c++11' file.write('#include <iostream>\n') file.write('#include <fstream>\n') file.write('#include \"xml/XmlEndfReader.h\"\n') file.write('#include \"Definitions.h\"\n') file.write('#include \"Container.h\"\n') file.write('int main(int argc, char** argv) {\n') file.write(' if( argc < 2){\n') file.write(' std::cout<<"Please supply endf file name"<<std::endl;\n') file.write(' return -1;\n') file.write(' }\n') file.write('\n') file.write(' std::fstream in(argv[1]);\n') file.write(' try{\n') file.write(' std::fstream in(argv[1]);\n') file.write(' std::string name(argv[1]);\n') file.write(' std::shared_ptr<const endfgnd::EndfDocument> reactionData = endfgnd::getEndfDocument(in, argv[1]);\n') file.write(' if( reactionData == NULL) throw endfgnd::gnd_error("Failed to load xml endf data");\n') file.write(' std::shared_ptr<const endfgnd::Element> root = reactionData->getRootElement();\n') file.write(' }\n') file.write(' catch(endfgnd::gnd_error & e){\n') file.write(' std::cout<<" Error: "<<e.what()<<std::endl;\n') file.write(' }\n') file.write(' return 0;\n') file.write('}\n') file.close() file = open(outDir + '/CMakeLists.txt', 'w') file.write('cmake_minimum_required (VERSION '+cmake_min_version+')\n') file.write('project (GNPDS_PARSER)\n') file.write('SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} \"-std='+cpp_standard+'\")\n\n') file.write('FILE(GLOB OURS ${CMAKE_CURRENT_SOURCE_DIR}/*.' + utilInfo.classExtension + ')\n') file.write('INCLUDE_DIRECTORIES(' + scriptDir + '/../ ./)\n') file.write('SET (SOURCES \n') file.write(' ${OURS}\n') file.write(' ' + scriptDir + '/../xml/XmlElement.cpp\n') file.write(' ' + scriptDir + '/../xml/XmlEndfReader.cpp\n') file.write(' ' + scriptDir + '/../Container.cpp\n') file.write(' ' + scriptDir + '/../ArrayContainer.cpp\n') file.write(' ' + scriptDir + '/../TableContainer.cpp\n') file.write(' ' + scriptDir + '/../ValuesContainer.cpp\n') file.write(')\n\n') file.write('find_package(Qt4 ' + qt_min_version + ' REQUIRED QtGui QtXml)\n\n') file.write('add_executable(GndsParser ${SOURCES})\n') file.write('target_link_libraries(GndsParser Qt4::QtXml Qt4::QtXmlPatterns)\n') file.close() README.md 0 → 100644 +18 −0 Original line number Diff line number Diff line # Generate GNDS classes from JSON definitions ## Generate the classes The python files to generate the classes reside in the directory `FromJson`, which can currently generate the files from the GNDS 1.9 version: - Check out http://git.oecd-nea.org/science/wpec/gnds/formats.git - Apply the patch given in `FromJson/ChangesToSpecs` - `python GenerateFromJson.py -h` gives the arguments to apply - inFile files gives the relative path of the JSON files to read. For GNDS-1.9 the file is `FromJson/FormatJsonFile` - formatDir is the directory containing the files from the GNDS repository - outDir is the directory where the final files are written ## Use the files The generated files are stored in directory `gnd`. An example `CMakeLists.txt` file is provided. In order to use it, update the path the pugixml and configure and build. This will generate an executable `GndsParser`, which takes as input a GNDS formatted file and prints out the value for the evaluated label. cmake/Dependencies.cmakedeleted 100644 → 0 +0 −8 Original line number Diff line number Diff line SET(LIB_REQUIRED_DEP_PACKAGES ScaleExternalPugixml) SET(LIB_OPTIONAL_DEP_PACKAGES) SET(TEST_REQUIRED_DEP_PACKAGES) SET(TEST_OPTIONAL_DEP_PACKAGES) SET(LIB_REQUIRED_DEP_TPLS) SET(LIB_OPTIONAL_DEP_TPLS) SET(TEST_REQUIRED_DEP_TPLS) SET(TEST_OPTIONAL_DEP_TPLS) main.cpp 0 → 100644 +105 −0 Original line number Diff line number Diff line #include <memory> #include "xml/XmlEndfReader.h" #include "transport_reaction_Suite.h" #include "covariance_covariance_Suite.h" #include "ExternalFiles.h" #include <fstream> #include <string> using namespace endfgnd; int main(int argc, char** argv) { if( argc < 2){ std::cout<<"Please supply endf file name"<<std::endl; return -1; } std::ifstream in(argv[1]); std::string fileName(argv[1]); std::shared_ptr<const EndfDocument> reactionData = getEndfDocument(fileName, in); if (reactionData == NULL) throw endfgnd::gnd_error("Failed to load xml endf data"); std::shared_ptr<const Element> root = reactionData->getRootElement(); std::shared_ptr<transport::reactionSuite> _reactionSuite = NULL; std::shared_ptr<covariance::covarianceSuite> _covarianceSuite = NULL; // covarianceSuite and reactionSuite can contain external file information. // read it std::shared_ptr<endfgnd::ExternalFile> ourFile = std::make_shared<endfgnd::ExternalFile>(); ourFile->setEndfDocument(reactionData); std::shared_ptr<ExternalFiles> external = std::make_shared<endfgnd::ExternalFiles>(); std::vector<std::shared_ptr<const Element>> externalElement = root->getElement("externalFiles"); if (externalElement.size() > 1) throw gnd_error("Expected only one externalFiles element"); if (externalElement.size() == 1) { external->readFromElement(externalElement[0]); } external->setDocumentFromParent(reactionData); if (root->getName().compare("reactionSuite") == 0) { _reactionSuite = std::make_shared<transport::reactionSuite>(); _reactionSuite->setExternalFiles(external); _reactionSuite->setOurFile(ourFile); _reactionSuite->readFromElement(root); } else if (root->getName().compare("covarianceSuite") == 0) { _covarianceSuite = std::make_shared<covariance::covarianceSuite>(); _covarianceSuite->setExternalFiles(external); _covarianceSuite->setOurFile(ourFile); _covarianceSuite->readFromElement(root); } else { throw gnd_error("Invalid root name: " + root->getName()); } // example get evaulated label std::shared_ptr<const styles::styles> _styles; if (_reactionSuite != NULL) { _styles = _reactionSuite->get_styles(); } else if (_covarianceSuite != NULL) { _styles = _covarianceSuite->get_styles(); } else { throw gnd_error( "Need a reactionSuite or covarianceSuite to use getStyleData"); } int eval = _styles->getNum_evaluated(); if (eval == 0) throw gnd_error("This style does not have any evaluated styles"); std::string label; for (int i = 0; i < eval; i++) { std::shared_ptr<const styles::evaluated> evalStyle = _styles->get_evaluated_byIndex(i); std::string derive = evalStyle->derivedFrom(); if (derive.empty()) { if (!label.empty()) { throw gnd_error( "There are more than one style with derivedFrom empty"); } label.append(evalStyle->getLabel()); } } std::cout<<"Evaluated label is: "<<label<<std::endl; } Loading
CMakeLists.txt 0 → 100644 +22 −0 Original line number Diff line number Diff line cmake_minimum_required (VERSION 2.6) project (GNPDS_PARSER) SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") SET (PUGIXML_PATH /Path_to_pugixml/src/) FILE(GLOB OURS ${CMAKE_CURRENT_SOURCE_DIR}/gnd/*.cpp) INCLUDE_DIRECTORIES( gnd ${PUGIXML_PATH}) SET (SOURCES ${PUGIXML_PATH}/pugiconfig.hpp ${PUGIXML_PATH}/pugixml.cpp ${OURS} xml/XmlElement.cpp xml/XmlEndfReader.cpp Container.cpp ArrayContainer.cpp TableContainer.cpp ValuesContainer.cpp ) add_executable(GndsParser main.cpp ${SOURCES})
FromJson/GenerateFromJson.py +0 −56 Original line number Diff line number Diff line Loading @@ -67,59 +67,3 @@ if __name__ == "__main__": writer.writeClass(classList.contextList[c][e], outDir) writerC = mClass.MakeClassDefinition(e, c, enumList, classList) writerC.writeClass(classList.contextList[c][e], outDir) # generate a test environment so that we can compile the classes # without AMPX environment scriptDir = os.path.dirname(os.path.realpath(__file__)) utilInfo = util.UtilityClass(None, None) file = open(outDir + '/main.' + utilInfo.classExtension,'w') cmake_min_version = '2.6' qt_min_version = '4.4.3' cpp_standard = 'c++11' file.write('#include <iostream>\n') file.write('#include <fstream>\n') file.write('#include \"xml/XmlEndfReader.h\"\n') file.write('#include \"Definitions.h\"\n') file.write('#include \"Container.h\"\n') file.write('int main(int argc, char** argv) {\n') file.write(' if( argc < 2){\n') file.write(' std::cout<<"Please supply endf file name"<<std::endl;\n') file.write(' return -1;\n') file.write(' }\n') file.write('\n') file.write(' std::fstream in(argv[1]);\n') file.write(' try{\n') file.write(' std::fstream in(argv[1]);\n') file.write(' std::string name(argv[1]);\n') file.write(' std::shared_ptr<const endfgnd::EndfDocument> reactionData = endfgnd::getEndfDocument(in, argv[1]);\n') file.write(' if( reactionData == NULL) throw endfgnd::gnd_error("Failed to load xml endf data");\n') file.write(' std::shared_ptr<const endfgnd::Element> root = reactionData->getRootElement();\n') file.write(' }\n') file.write(' catch(endfgnd::gnd_error & e){\n') file.write(' std::cout<<" Error: "<<e.what()<<std::endl;\n') file.write(' }\n') file.write(' return 0;\n') file.write('}\n') file.close() file = open(outDir + '/CMakeLists.txt', 'w') file.write('cmake_minimum_required (VERSION '+cmake_min_version+')\n') file.write('project (GNPDS_PARSER)\n') file.write('SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} \"-std='+cpp_standard+'\")\n\n') file.write('FILE(GLOB OURS ${CMAKE_CURRENT_SOURCE_DIR}/*.' + utilInfo.classExtension + ')\n') file.write('INCLUDE_DIRECTORIES(' + scriptDir + '/../ ./)\n') file.write('SET (SOURCES \n') file.write(' ${OURS}\n') file.write(' ' + scriptDir + '/../xml/XmlElement.cpp\n') file.write(' ' + scriptDir + '/../xml/XmlEndfReader.cpp\n') file.write(' ' + scriptDir + '/../Container.cpp\n') file.write(' ' + scriptDir + '/../ArrayContainer.cpp\n') file.write(' ' + scriptDir + '/../TableContainer.cpp\n') file.write(' ' + scriptDir + '/../ValuesContainer.cpp\n') file.write(')\n\n') file.write('find_package(Qt4 ' + qt_min_version + ' REQUIRED QtGui QtXml)\n\n') file.write('add_executable(GndsParser ${SOURCES})\n') file.write('target_link_libraries(GndsParser Qt4::QtXml Qt4::QtXmlPatterns)\n') file.close()
README.md 0 → 100644 +18 −0 Original line number Diff line number Diff line # Generate GNDS classes from JSON definitions ## Generate the classes The python files to generate the classes reside in the directory `FromJson`, which can currently generate the files from the GNDS 1.9 version: - Check out http://git.oecd-nea.org/science/wpec/gnds/formats.git - Apply the patch given in `FromJson/ChangesToSpecs` - `python GenerateFromJson.py -h` gives the arguments to apply - inFile files gives the relative path of the JSON files to read. For GNDS-1.9 the file is `FromJson/FormatJsonFile` - formatDir is the directory containing the files from the GNDS repository - outDir is the directory where the final files are written ## Use the files The generated files are stored in directory `gnd`. An example `CMakeLists.txt` file is provided. In order to use it, update the path the pugixml and configure and build. This will generate an executable `GndsParser`, which takes as input a GNDS formatted file and prints out the value for the evaluated label.
cmake/Dependencies.cmakedeleted 100644 → 0 +0 −8 Original line number Diff line number Diff line SET(LIB_REQUIRED_DEP_PACKAGES ScaleExternalPugixml) SET(LIB_OPTIONAL_DEP_PACKAGES) SET(TEST_REQUIRED_DEP_PACKAGES) SET(TEST_OPTIONAL_DEP_PACKAGES) SET(LIB_REQUIRED_DEP_TPLS) SET(LIB_OPTIONAL_DEP_TPLS) SET(TEST_REQUIRED_DEP_TPLS) SET(TEST_OPTIONAL_DEP_TPLS)
main.cpp 0 → 100644 +105 −0 Original line number Diff line number Diff line #include <memory> #include "xml/XmlEndfReader.h" #include "transport_reaction_Suite.h" #include "covariance_covariance_Suite.h" #include "ExternalFiles.h" #include <fstream> #include <string> using namespace endfgnd; int main(int argc, char** argv) { if( argc < 2){ std::cout<<"Please supply endf file name"<<std::endl; return -1; } std::ifstream in(argv[1]); std::string fileName(argv[1]); std::shared_ptr<const EndfDocument> reactionData = getEndfDocument(fileName, in); if (reactionData == NULL) throw endfgnd::gnd_error("Failed to load xml endf data"); std::shared_ptr<const Element> root = reactionData->getRootElement(); std::shared_ptr<transport::reactionSuite> _reactionSuite = NULL; std::shared_ptr<covariance::covarianceSuite> _covarianceSuite = NULL; // covarianceSuite and reactionSuite can contain external file information. // read it std::shared_ptr<endfgnd::ExternalFile> ourFile = std::make_shared<endfgnd::ExternalFile>(); ourFile->setEndfDocument(reactionData); std::shared_ptr<ExternalFiles> external = std::make_shared<endfgnd::ExternalFiles>(); std::vector<std::shared_ptr<const Element>> externalElement = root->getElement("externalFiles"); if (externalElement.size() > 1) throw gnd_error("Expected only one externalFiles element"); if (externalElement.size() == 1) { external->readFromElement(externalElement[0]); } external->setDocumentFromParent(reactionData); if (root->getName().compare("reactionSuite") == 0) { _reactionSuite = std::make_shared<transport::reactionSuite>(); _reactionSuite->setExternalFiles(external); _reactionSuite->setOurFile(ourFile); _reactionSuite->readFromElement(root); } else if (root->getName().compare("covarianceSuite") == 0) { _covarianceSuite = std::make_shared<covariance::covarianceSuite>(); _covarianceSuite->setExternalFiles(external); _covarianceSuite->setOurFile(ourFile); _covarianceSuite->readFromElement(root); } else { throw gnd_error("Invalid root name: " + root->getName()); } // example get evaulated label std::shared_ptr<const styles::styles> _styles; if (_reactionSuite != NULL) { _styles = _reactionSuite->get_styles(); } else if (_covarianceSuite != NULL) { _styles = _covarianceSuite->get_styles(); } else { throw gnd_error( "Need a reactionSuite or covarianceSuite to use getStyleData"); } int eval = _styles->getNum_evaluated(); if (eval == 0) throw gnd_error("This style does not have any evaluated styles"); std::string label; for (int i = 0; i < eval; i++) { std::shared_ptr<const styles::evaluated> evalStyle = _styles->get_evaluated_byIndex(i); std::string derive = evalStyle->derivedFrom(); if (derive.empty()) { if (!label.empty()) { throw gnd_error( "There are more than one style with derivedFrom empty"); } label.append(evalStyle->getLabel()); } } std::cout<<"Evaluated label is: "<<label<<std::endl; }