1#ifndef _MBXMLUTILS_PREPROCESS_H_
2#define _MBXMLUTILS_PREPROCESS_H_
4#include <fmatvec/atom.h>
5#include <mbxmlutilshelper/dom.h>
6#include <mbxmlutils/eval.h>
12 using ParamSet = std::map<std::string, Eval::Value>;
18 std::shared_ptr<MBXMLUtils::DOMParser>,
20 boost::filesystem::path
22 bool trackDependencies);
27 std::shared_ptr<MBXMLUtils::DOMParser>,
29 boost::filesystem::path
31 bool trackDependencies);
34 Preprocess(
const std::shared_ptr<xercesc::DOMDocument> &inputDoc,
bool trackDependencies);
36 void setCheckInterruptFunction(
const std::function<
void()> &func) {
37 checkInterruptFunc=func;
41 void setParam(
const std::shared_ptr<ParamSet>& param_);
43 std::shared_ptr<ParamSet>
getParam()
const;
60 std::shared_ptr<xercesc::DOMDocument> document;
61 std::unique_ptr<std::vector<boost::filesystem::path>> dependencies;
62 std::shared_ptr<Eval> eval;
63 std::shared_ptr<ParamSet> param;
64 std::shared_ptr<DOMParser> noneValidatingParser;
65 static const FQN embedFileNotFound;
67 std::function<void()> checkInterruptFunc;
68 void checkInterrupt() {
69 if(checkInterruptFunc)
73 bool preprocessed {
false };
75 std::shared_ptr<DOMParser> initDependenciesAndParser(std::variant<
76 std::shared_ptr<MBXMLUtils::DOMParser>,
78 boost::filesystem::path
80 bool trackDependencies);
82 std::map<boost::filesystem::path, std::shared_ptr<xercesc::DOMDocument>> parsedFiles;
83 std::shared_ptr<xercesc::DOMDocument> parseCached(
const std::shared_ptr<DOMParser> &parser,
84 const boost::filesystem::path &inputFile,
85 const std::string &msg,
bool allowUnknownRootElement=
false);
87 std::map<size_t, std::shared_ptr<xercesc::DOMDocument>> parsedStream;
88 std::shared_ptr<xercesc::DOMDocument> parseCached(
const std::shared_ptr<DOMParser> &parser,
89 std::istream &inputStream,
90 const std::string &msg,
bool allowUnknownRootElement=
false);
92 void extractEvaluator();
95 xercesc::DOMElement *&e,
97 int &nrElementsEmbeded,
99 const std::shared_ptr<ParamSet>& param=std::shared_ptr<ParamSet>(),
102 int embedXPathCount=1
Definition: preprocess.h:10
std::shared_ptr< xercesc::DOMDocument > getDOMDocument()
Definition: preprocess.h:57
Preprocess(const boost::filesystem::path &inputFile, std::variant< std::shared_ptr< MBXMLUtils::DOMParser >, xercesc::DOMElement *, boost::filesystem::path > parserVariant, bool trackDependencies)
std::shared_ptr< ParamSet > getParam() const
Get available top level parameters after processAndGetDocument is called.
Definition: preprocess.cc:95
Preprocess(const std::shared_ptr< xercesc::DOMDocument > &inputDoc, bool trackDependencies)
std::shared_ptr< Eval > getEvaluator() const
Get the evaluator.
Definition: preprocess.cc:87
const std::vector< boost::filesystem::path > & getDependencies() const
Get all dependencies found during processAndGetDocument.
Definition: preprocess.cc:79
Preprocess(std::istream &inputStream, std::variant< std::shared_ptr< MBXMLUtils::DOMParser >, xercesc::DOMElement *, boost::filesystem::path > parserVariant, bool trackDependencies)
void setParam(const std::shared_ptr< ParamSet > ¶m_)
Set top level parameters to overwrite before processAndGetDocument is called.
Definition: preprocess.cc:91
std::shared_ptr< xercesc::DOMDocument > processAndGetDocument()
Start preprocessing and return the preprocessed DOMDocument.
Definition: preprocess.cc:124