OOFEM 3.0
Loading...
Searching...
No Matches
xmldatareader.h
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#ifndef xmldatareader_h
36#define xmldatareader_h
37
38#include "datareader.h"
39#include "xmlinputrecord.h"
40#include <pugixml.hpp>
41#include <set>
42#include <map>
43
44
45
46
47namespace oofem {
53{
54protected:
56 std::string topXmlFile;
57 /* map parent xml node (which is either empty for top-level file for xi:include node for included files) to filenames */
58 std::map<pugi::xml_node,std::string> xmlFiles;
59 /* map document node to ordered list of newline offsets (used to compute line:column from offset in messages) */
60 std::map<pugi::xml_node,std::vector<size_t>> newlines;
61 /* map parent xml node (which is either empty for top-level file for xi:include node for included files) to (sub)document */
62 std::map<pugi::xml_node,pugi::xml_document> docs;
63 struct StackItem{
64 pugi::xml_node parent;
65 pugi::xml_node curr;
66 std::shared_ptr<XMLInputRecord> lastRecord;
67 std::set<pugi::xml_node> seen;
68 int lastRecId=0;
69 };
70 std::vector<StackItem> stack;
71 std::string giveStackPath(); // string representation
72 pugi::xml_document& loadXml(pugi::xml_node parent, const std::string& xml);
73 pugi::xml_node resolveXiInclude(const pugi::xml_node& n);
74 std::tuple<size_t,size_t> offset2lc(const std::vector<size_t>& nl, size_t offset) const;
75 std::string loc() const ;
76 std::string loc(const pugi::xml_node&) const;
77 std::shared_ptr<InputRecord> topRecord;
78 pugi::xml_node giveNamedChild(const pugi::xml_node& parent, const std::string& name);
79 const std::string XiIncludeTag="xi:include";
80 int setRecId(int lastRecId);
81public:
82 XMLDataReader(const std::string& xmlFile);
83 virtual ~XMLDataReader(){};
84 bool hasFlattenedStructure() override { return true; }
85
87 static bool canRead(const std::string& xmlFile);
88 InputRecord& giveInputRecord(InputRecordType, int recordId) override;
89 InputRecord* giveTopInputRecord() override { return topRecord.get(); }
90 bool peekNext(const std :: string &keyword) override { return false; } /* no peeking, it is used for hacks only */
91 void finish() override;
92 std::string giveReferenceName() const override { return topXmlFile; }
93 void enterGroup(const std::string& name) override;
94 void leaveGroup(const std::string& name) override;
95 void enterRecord(InputRecord*) override;
96 void leaveRecord(InputRecord*) override;
97
98 int giveGroupCount(const std::string& name) override;
99 int giveCurrentGroupCount();
100};
101} // end namespace oofem
102#endif // xmldatareader_h
bool hasFlattenedStructure() override
std::vector< StackItem > stack
pugi::xml_node giveNamedChild(const pugi::xml_node &parent, const std::string &name)
pugi::xml_document & loadXml(pugi::xml_node parent, const std::string &xml)
std::map< pugi::xml_node, std::string > xmlFiles
bool peekNext(const std ::string &keyword) override
int setRecId(int lastRecId)
std::string loc() const
std::string giveReferenceName() const override
Gives the reference file name (e.g. file name).
std::map< pugi::xml_node, pugi::xml_document > docs
std::tuple< size_t, size_t > offset2lc(const std::vector< size_t > &nl, size_t offset) const
const std::string XiIncludeTag
std::string giveStackPath()
std::shared_ptr< InputRecord > topRecord
std::map< pugi::xml_node, std::vector< size_t > > newlines
InputRecord * giveTopInputRecord() override
pugi::xml_node resolveXiInclude(const pugi::xml_node &n)
XMLDataReader(const std::string &xmlFile)
#define OOFEM_EXPORT
Definition oofemcfg.h:7
std::shared_ptr< XMLInputRecord > lastRecord
std::set< pugi::xml_node > seen

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011