diff options
Diffstat (limited to 'src/xml_to_data')
-rw-r--r-- | src/xml_to_data/device_xml_to_data.cpp | 10 | ||||
-rw-r--r-- | src/xml_to_data/device_xml_to_data.h | 3 | ||||
-rw-r--r-- | src/xml_to_data/prog_xml_to_data.h | 16 | ||||
-rw-r--r-- | src/xml_to_data/xml_to_data.h | 16 |
4 files changed, 33 insertions, 12 deletions
diff --git a/src/xml_to_data/device_xml_to_data.cpp b/src/xml_to_data/device_xml_to_data.cpp index 5ad40a5..84d177f 100644 --- a/src/xml_to_data/device_xml_to_data.cpp +++ b/src/xml_to_data/device_xml_to_data.cpp @@ -241,10 +241,16 @@ Device::Package Device::XmlToDataBase::processPackage(TQDomElement element) void Device::XmlToDataBase::parse() { // process device files - TQStringList files = TQDir::current().entryList("*.xml"); + TQStringList files; + TQDir xmlFilesDir; + if (!xmlFolder.isEmpty()) + { + xmlFilesDir.setPath(xmlFolder); + } + files = xmlFilesDir.entryList("*.xml"); for (uint i=0; i<uint(files.count()); i++) { _data = 0; - TQDomDocument doc = parseFile(files[i]); + TQDomDocument doc = parseFile(xmlFilesDir.absFilePath(files[i])); TQDomElement root = doc.documentElement(); if ( root.nodeName()!="device" ) tqFatal("root node should be \"device\""); processDevice(root); diff --git a/src/xml_to_data/device_xml_to_data.h b/src/xml_to_data/device_xml_to_data.h index b505cdd..c535346 100644 --- a/src/xml_to_data/device_xml_to_data.h +++ b/src/xml_to_data/device_xml_to_data.h @@ -23,7 +23,7 @@ namespace Device class XmlToDataBase : public ::XmlToData { public: - XmlToDataBase() : _data(0) {} + XmlToDataBase(const TQString &folder) : XmlToData(folder), _data(0) {} protected: mutable Data *_data; @@ -49,6 +49,7 @@ template <class DataType> class XmlToData : public XmlToDataBase, public DataStreamer<DataType> { public: + XmlToData(const TQString &folder) : XmlToDataBase(folder) {} virtual Device::Data *createData() const { return new DataType; } DataType *data() { return static_cast<DataType *>(_data); } const DataType *data() const { return static_cast<DataType *>(_data); } diff --git a/src/xml_to_data/prog_xml_to_data.h b/src/xml_to_data/prog_xml_to_data.h index bcca9da..b977359 100644 --- a/src/xml_to_data/prog_xml_to_data.h +++ b/src/xml_to_data/prog_xml_to_data.h @@ -9,6 +9,7 @@ #ifndef PROG_XML_TO_DATA_H #define PROG_XML_TO_DATA_H +#include <tqdir.h> #include <tqfile.h> #include <tqtextstream.h> #include <tqmap.h> @@ -21,8 +22,8 @@ template <class Data> class ExtXmlToData : public ::XmlToData { public: - ExtXmlToData(const TQString &basename, const TQString &namespac) - : _basename(basename), _namespace(namespac) {} + ExtXmlToData(const TQString &folder, const TQString &basename, const TQString &namespac) + : ::XmlToData(folder), _basename(basename), _namespace(namespac) {} protected: TQString _basename, _namespace; @@ -85,7 +86,12 @@ void ExtXmlToData<Data>::parseDevice(TQDomElement element) template <class Data> void ExtXmlToData<Data>::parse() { - TQDomDocument doc = parseFile(_basename + ".xml"); + TQDir xmlFilesDir; + if (!xmlFolder.isEmpty()) + { + xmlFilesDir.setPath(xmlFolder); + } + TQDomDocument doc = parseFile(xmlFilesDir.absFilePath(_basename + ".xml")); TQDomElement root = doc.documentElement(); if ( root.nodeName()!="type" ) tqFatal("Root node should be \"type\""); if ( root.attribute("name")!=_basename ) tqFatal(TQString("Root node name is not \"%1\"").arg(_basename)); @@ -186,8 +192,8 @@ template <class Data> class XmlToData : public ExtXmlToData<Data> { public: - XmlToData(const TQString &basename, const TQString &namespac) - : ExtXmlToData<Data>(basename, namespac) {} + XmlToData(const TQString &folder, const TQString &basename, const TQString &namespac) + : ExtXmlToData<Data>(folder, basename, namespac) {} protected: virtual void outputFunctions(TQTextStream &s) const; diff --git a/src/xml_to_data/xml_to_data.h b/src/xml_to_data/xml_to_data.h index 1b45ea6..2d91640 100644 --- a/src/xml_to_data/xml_to_data.h +++ b/src/xml_to_data/xml_to_data.h @@ -10,13 +10,14 @@ #define XML_TO_DATA_H #include "common/global/global.h" -# include <tqdom.h> + +#include <tqdom.h> #include <tqstringlist.h> class XmlToData { public: - XmlToData() {} + XmlToData(const TQString &folder) : xmlFolder(folder) {} virtual ~XmlToData() {} void process(); @@ -30,12 +31,19 @@ protected: const TQString &attribute, const TQString &value) const; void checkTagNames(TQDomElement element, const TQString &tag, const TQStringList &names) const; TQDomDocument parseFile(const TQString &filename) const; + + TQString xmlFolder; }; #define XML_MAIN(_type) \ - int main(int, char **) \ + int main(int argc, char **argv) \ { \ - _type dx; \ + TQString xmlFolder = TQString::null; \ + if (argc > 1) \ + { \ + xmlFolder = argv[1]; \ + } \ + _type dx(xmlFolder); \ dx.process(); \ return 0; \ } |