OOFEM 3.0
Loading...
Searching...
No Matches
oofem::XMLDataReader Class Reference

#include <xmldatareader.h>

Inheritance diagram for oofem::XMLDataReader:
Collaboration diagram for oofem::XMLDataReader:

Classes

struct  StackItem

Public Member Functions

 XMLDataReader (const std::string &xmlFile)
virtual ~XMLDataReader ()
bool hasFlattenedStructure () override
InputRecordgiveInputRecord (InputRecordType, int recordId) override
InputRecordgiveTopInputRecord () override
bool peekNext (const std ::string &keyword) override
void finish () override
std::string giveReferenceName () const override
 Gives the reference file name (e.g. file name).
void enterGroup (const std::string &name) override
void leaveGroup (const std::string &name) override
void enterRecord (InputRecord *) override
void leaveRecord (InputRecord *) override
int giveGroupCount (const std::string &name) override
int giveCurrentGroupCount ()
Public Member Functions inherited from oofem::DataReader
 DataReader ()
virtual ~DataReader ()
std::string giveOutputFileName ()
 Gives the output file name.
std::string giveDescription ()
 Gives the problem description.
bool hasGroup (const std::string &name)
 Predicate whether a named group exists (it can still be empty).
GroupRecords giveGroupRecords (const std::shared_ptr< InputRecord > &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional)
GroupRecords giveGroupRecords (const std::string &name, InputRecordType irType, int numRequired=-1)
InputRecordgiveChildRecord (const std::shared_ptr< InputRecord > &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional)
 Return pointer to subrecord of given type (must be exactly one); if not present, returns nullptr.

Static Public Member Functions

static bool canRead (const std::string &xmlFile)
 guess whether given file is XML

Protected Member Functions

std::string giveStackPath ()
pugi::xml_document & loadXml (pugi::xml_node parent, const std::string &xml)
pugi::xml_node resolveXiInclude (const pugi::xml_node &n)
std::tuple< size_t, size_t > offset2lc (const std::vector< size_t > &nl, size_t offset) const
std::string loc () const
std::string loc (const pugi::xml_node &) const
pugi::xml_node giveNamedChild (const pugi::xml_node &parent, const std::string &name)
int setRecId (int lastRecId)

Protected Attributes

friend XMLInputRecord
std::string topXmlFile
std::map< pugi::xml_node, std::string > xmlFiles
std::map< pugi::xml_node, std::vector< size_t > > newlines
std::map< pugi::xml_node, pugi::xml_document > docs
std::vector< StackItemstack
std::shared_ptr< InputRecordtopRecord
const std::string XiIncludeTag ="xi:include"
Protected Attributes inherited from oofem::DataReader
std::string outputFileName
 Output file name (first line in OOFEM input files).
std::string description
 Description line (second line in OOFEM input files).

Additional Inherited Members

Public Types inherited from oofem::DataReader
enum  InputRecordType {
  IR_domainRec , IR_outManRec , IR_domainCompRec , IR_geometryRec ,
  IR_gbpmRec , IR_emodelRec , IR_mstepRec , IR_expModuleRec ,
  IR_dofmanRec , IR_elemRec , IR_crosssectRec , IR_matRec ,
  IR_nlocBarRec , IR_bcRec , IR_icRec , IR_funcRec ,
  IR_setRec , IR_xfemManRec , IR_enrichFuncRec , IR_geoRec ,
  IR_enrichItemRec , IR_enrichFrontRec , IR_propagationLawRec , IR_crackNucleationRec ,
  IR_fracManRec , IR_failCritRec , IR_contactSurfaceRec , IR_fieldRec ,
  IR_mpmVarRec , IR_mpmTermRec , IR_mpmIntegralRec , IR_unspecified
}
 Determines the type of input record. More...
Static Public Attributes inherited from oofem::DataReader
static constexpr const char * InputRecordTags []
static const int NoSuchGroup =-1

Detailed Description

Class representing the implementation of XML reader. It reads a sequence of input records from data file and creates the corresponding input records.

Definition at line 52 of file xmldatareader.h.

Constructor & Destructor Documentation

◆ XMLDataReader()

oofem::XMLDataReader::XMLDataReader ( const std::string & xmlFile)

◆ ~XMLDataReader()

virtual oofem::XMLDataReader::~XMLDataReader ( )
inlinevirtual

Definition at line 83 of file xmldatareader.h.

Member Function Documentation

◆ canRead()

bool oofem::XMLDataReader::canRead ( const std::string & xmlFile)
static

guess whether given file is XML

Definition at line 141 of file xmldatareader.C.

◆ enterGroup()

void oofem::XMLDataReader::enterGroup ( const std::string & name)
overridevirtual

◆ enterRecord()

void oofem::XMLDataReader::enterRecord ( InputRecord * rec)
overridevirtual

◆ finish()

void oofem::XMLDataReader::finish ( )
overridevirtual

Allows to detach all data connections.

Implements oofem::DataReader.

Definition at line 218 of file xmldatareader.C.

References docs, leaveGroup(), loc(), oofem::XMLInputRecord::node_seen_get(), OOFEM_WARNING, and stack.

◆ giveCurrentGroupCount()

int oofem::XMLDataReader::giveCurrentGroupCount ( )

Definition at line 168 of file xmldatareader.C.

References _XML_DEBUG, giveStackPath(), and stack.

Referenced by giveGroupCount().

◆ giveGroupCount()

int oofem::XMLDataReader::giveGroupCount ( const std::string & name)
overridevirtual

Return number of items in a named group

Parameters
namename of the group; if empty, current group is used
Returns
Number of items in the named group; returns 0 if the group is empty, and -1 (DatReader::NoSuchGroup) if the group does not exist at all.

Reimplemented from oofem::DataReader.

Definition at line 159 of file xmldatareader.C.

References _XML_DEBUG, enterGroup(), giveCurrentGroupCount(), giveStackPath(), and leaveGroup().

◆ giveInputRecord()

InputRecord & oofem::XMLDataReader::giveInputRecord ( InputRecordType irType,
int recordId )
overridevirtual

Returns input record corresponding to given InputRecordType value and its record_id. The returned InputRecord reference is valid only until the next call.

Parameters
irTypeDetermines type of record to be returned.
recordIdDetermines the record number corresponding to component number.

Implements oofem::DataReader.

Definition at line 237 of file xmldatareader.C.

References _XML_DEBUG, oofem::XMLDataReader::StackItem::curr, giveStackPath(), oofem::DataReader::InputRecordTags, oofem::XMLDataReader::StackItem::lastRecId, oofem::XMLDataReader::StackItem::lastRecord, loc(), oofem::XMLInputRecord::node_seen_get(), OOFEM_ERROR, oofem::XMLDataReader::StackItem::parent, resolveXiInclude(), oofem::XMLDataReader::StackItem::seen, stack, and XiIncludeTag.

◆ giveNamedChild()

pugi::xml_node oofem::XMLDataReader::giveNamedChild ( const pugi::xml_node & parent,
const std::string & name )
protected

◆ giveReferenceName()

std::string oofem::XMLDataReader::giveReferenceName ( ) const
inlineoverridevirtual

Gives the reference file name (e.g. file name).

Implements oofem::DataReader.

Definition at line 92 of file xmldatareader.h.

References topXmlFile.

◆ giveStackPath()

std::string oofem::XMLDataReader::giveStackPath ( )
protected

◆ giveTopInputRecord()

InputRecord * oofem::XMLDataReader::giveTopInputRecord ( )
inlineoverridevirtual

Returns top input record, for readers which support it; others return empty pointer

Reimplemented from oofem::DataReader.

Definition at line 89 of file xmldatareader.h.

References topRecord.

◆ hasFlattenedStructure()

bool oofem::XMLDataReader::hasFlattenedStructure ( )
inlineoverridevirtual

Reimplemented from oofem::DataReader.

Definition at line 84 of file xmldatareader.h.

◆ leaveGroup()

void oofem::XMLDataReader::leaveGroup ( const std::string & name)
overridevirtual

Reimplemented from oofem::DataReader.

Definition at line 190 of file xmldatareader.C.

References _XML_DEBUG, giveStackPath(), loc(), OOFEM_ERROR, and stack.

Referenced by finish(), and giveGroupCount().

◆ leaveRecord()

void oofem::XMLDataReader::leaveRecord ( InputRecord * rec)
overridevirtual

◆ loadXml()

pugi::xml_document & oofem::XMLDataReader::loadXml ( pugi::xml_node parent,
const std::string & xml )
protected

◆ loc() [1/2]

std::string oofem::XMLDataReader::loc ( ) const
protected

◆ loc() [2/2]

std::string oofem::XMLDataReader::loc ( const pugi::xml_node & n) const
protected

Definition at line 152 of file xmldatareader.C.

References newlines, offset2lc(), and xmlFiles.

◆ offset2lc()

std::tuple< size_t, size_t > oofem::XMLDataReader::offset2lc ( const std::vector< size_t > & nl,
size_t offset ) const
protected

Definition at line 145 of file xmldatareader.C.

Referenced by loadXml(), and loc().

◆ peekNext()

bool oofem::XMLDataReader::peekNext ( const std ::string & keyword)
inlineoverridevirtual

Peak in advance into the record list.

Returns
True if next keyword is a set.

Reimplemented from oofem::DataReader.

Definition at line 90 of file xmldatareader.h.

◆ resolveXiInclude()

pugi::xml_node oofem::XMLDataReader::resolveXiInclude ( const pugi::xml_node & n)
protected

Definition at line 95 of file xmldatareader.C.

References _XML_DEBUG, docs, giveStackPath(), loadXml(), loc(), OOFEM_ERROR, and XiIncludeTag.

Referenced by giveInputRecord(), and giveNamedChild().

◆ setRecId()

int oofem::XMLDataReader::setRecId ( int lastRecId)
protected

References XMLDataReader().

Member Data Documentation

◆ docs

std::map<pugi::xml_node,pugi::xml_document> oofem::XMLDataReader::docs
protected

Definition at line 62 of file xmldatareader.h.

Referenced by finish(), loadXml(), and resolveXiInclude().

◆ newlines

std::map<pugi::xml_node,std::vector<size_t> > oofem::XMLDataReader::newlines
protected

Definition at line 60 of file xmldatareader.h.

Referenced by loadXml(), and loc().

◆ stack

std::vector<StackItem> oofem::XMLDataReader::stack
protected

◆ topRecord

std::shared_ptr<InputRecord> oofem::XMLDataReader::topRecord
protected

Definition at line 77 of file xmldatareader.h.

Referenced by giveTopInputRecord(), and XMLDataReader().

◆ topXmlFile

std::string oofem::XMLDataReader::topXmlFile
protected

Definition at line 56 of file xmldatareader.h.

Referenced by giveReferenceName(), and XMLDataReader().

◆ XiIncludeTag

const std::string oofem::XMLDataReader::XiIncludeTag ="xi:include"
protected

Definition at line 79 of file xmldatareader.h.

Referenced by giveInputRecord(), giveNamedChild(), and resolveXiInclude().

◆ xmlFiles

std::map<pugi::xml_node,std::string> oofem::XMLDataReader::xmlFiles
protected

Definition at line 58 of file xmldatareader.h.

Referenced by loadXml(), and loc().

◆ XMLInputRecord

friend oofem::XMLDataReader::XMLInputRecord
protected

Definition at line 55 of file xmldatareader.h.

Referenced by enterRecord(), leaveRecord(), and XMLDataReader().


The documentation for this class was generated from the following files:

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