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);
38 void setCheckInterruptFunction(
const std::function<
void()> &func) {
39 checkInterruptFunc=func;
43 void setParam(
const std::shared_ptr<ParamSet>& param_);
45 std::shared_ptr<ParamSet>
getParam()
const;
62 std::shared_ptr<xercesc::DOMDocument> document;
63 std::unique_ptr<std::vector<boost::filesystem::path>> dependencies;
64 std::shared_ptr<Eval> eval;
65 std::shared_ptr<ParamSet> param;
66 std::shared_ptr<DOMParser> noneValidatingParser;
67 static const FQN embedFileNotFound;
69 std::function<void()> checkInterruptFunc;
70 void checkInterrupt() {
71 if(checkInterruptFunc)
75 bool preprocessed {
false };
77 std::shared_ptr<DOMParser> initDependenciesAndParser(std::variant<
78 std::shared_ptr<MBXMLUtils::DOMParser>,
80 boost::filesystem::path
82 bool trackDependencies);
84 std::map<boost::filesystem::path, std::shared_ptr<xercesc::DOMDocument>> parsedFiles;
85 std::shared_ptr<xercesc::DOMDocument> parseCached(
const std::shared_ptr<DOMParser> &parser,
86 const boost::filesystem::path &inputFile,
87 const std::string &msg,
bool allowUnknownRootElement=
false);
89 std::map<size_t, std::shared_ptr<xercesc::DOMDocument>> parsedStream;
90 std::shared_ptr<xercesc::DOMDocument> parseCached(
const std::shared_ptr<DOMParser> &parser,
91 std::istream &inputStream,
92 const std::string &msg,
bool allowUnknownRootElement=
false);
94 void extractEvaluator();
97 xercesc::DOMElement *&e,
99 int &nrElementsEmbeded,
101 const std::shared_ptr<ParamSet>& param=std::shared_ptr<ParamSet>(),
104 int embedXPathCount=1
Definition: preprocess.h:10
std::shared_ptr< xercesc::DOMDocument > getDOMDocument()
Definition: preprocess.h:59
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:106
Preprocess(const std::shared_ptr< xercesc::DOMDocument > &inputDoc, bool trackDependencies)
std::shared_ptr< Eval > getEvaluator() const
Get the evaluator.
Definition: preprocess.cc:98
const std::vector< boost::filesystem::path > & getDependencies() const
Get all dependencies found during processAndGetDocument.
Definition: preprocess.cc:90
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:102
std::shared_ptr< xercesc::DOMDocument > processAndGetDocument()
Start preprocessing and return the preprocessed DOMDocument.
Definition: preprocess.cc:135