BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::XercesBuilder Class Reference

#include <XercesBuilder.h>

+ Inheritance diagram for rdbModel::XercesBuilder:

Public Member Functions

 XercesBuilder ()
 
virtual ~XercesBuilder ()
 
virtual unsigned int parseInput (const std::string &inputPath)
 
virtual int buildRdb ()
 
- Public Member Functions inherited from rdbModel::Builder
 Builder ()
 
virtual unsigned int parseInput (const std::string &)=0
 
virtual int buildRdb ()=0
 
void setRdb (Rdb *pRdb)
 
RdbgetRdb ()
 

Additional Inherited Members

- Protected Attributes inherited from rdbModel::Builder
Rdbm_currentRdb
 

Detailed Description

This class is a concrete Builder that use the Xerces parser and the DOM functionalities to parse the xml file and build the generic model hierarchy

Author
D.Favretto & R.Giannitrapani

Definition at line 26 of file XercesBuilder.h.

Constructor & Destructor Documentation

◆ XercesBuilder()

rdbModel::XercesBuilder::XercesBuilder ( )

The constructor

Definition at line 27 of file XercesBuilder.cxx.

◆ ~XercesBuilder()

virtual rdbModel::XercesBuilder::~XercesBuilder ( )
inlinevirtual

Definition at line 34 of file XercesBuilder.h.

34{};

Member Function Documentation

◆ buildRdb()

int rdbModel::XercesBuilder::buildRdb ( )
virtual

Concrete implementation of pure virtual Builder::buildRdb

Implements rdbModel::Builder.

Definition at line 41 of file XercesBuilder.cxx.

41 {
42 using xmlBase::Dom;
43
44 Manager* man = Manager::getManager();
45
46 if (m_doc == 0 ) return 0;
47 m_rdb = man->getRdb();
48 DOMElement* docElt = m_doc->getDocumentElement();
49
50
51 // save attribute information associated with outermost (rdbms) element.
52 m_rdb->m_dbName = Dom::getAttribute(docElt, "dbs");
53 m_rdb->m_majorVersion = 0;
54 m_rdb->m_minorVersion = 0;
55
56 std::string versionString = Dom::getAttribute(docElt, "SchemaVersion");
57 if (!versionString.size()) {
58 versionString = Dom::getAttribute(docElt, "DTDversion");
59 }
60
61 unsigned dotPos = versionString.find('.');
62
63 std::string minorStr = std::string(versionString, dotPos+1);
64 // versionString.size() - (dotPos+1));
65 versionString.resize(dotPos); // now contains just major #
66
67 try {
68 m_rdb->m_majorVersion = facilities::Util::stringToInt(versionString);
69 m_rdb->m_minorVersion = facilities::Util::stringToInt(minorStr);
70 }
71 catch (facilities::WrongType ex) {
72 std::cerr << "rdbModel::XercesBuilder: Bad version string " << std::endl;
73 }
74 m_rdb->m_CVSid = Dom::getAttribute(docElt, "CVSid");
75 if (m_rdb->m_majorVersion != SCHEMA_MAJOR_VERSION) {
76 std::cerr << "Schema major version " << m_rdb->m_majorVersion
77 << " doesn't match expected " << SCHEMA_MAJOR_VERSION
78 << std::endl;
79 std::cerr << "Bye for now";
80 std::cerr.flush();
81 exit(1);
82 }
83
84 // Get vector of table elements.
85 std::vector<DOMElement*> tables;
86 Dom::getChildrenByTagName(docElt, "table", tables);
87 unsigned int nTable = tables.size();
88 unsigned int processed = 0;
89
90 for (unsigned int iTable = 0; iTable < nTable; iTable++) {
91 Table* newTable = buildTable(tables[iTable]);
92
93 if (newTable) {
94 m_rdb->addTable(newTable);
95 processed++;
96 }
97 }
98 return nTable - processed;
99 }
#define SCHEMA_MAJOR_VERSION
static int stringToInt(const std::string &InStr)
Exception class used when converting from string to numeric type.
static Manager * getManager()
Definition: Manager.cxx:24

◆ parseInput()

unsigned int rdbModel::XercesBuilder::parseInput ( const std::string &  inputPath)
virtual

Invoke xml parser to produce DOM (in-memory) representation Concrete implementation of Builder::parseInput

Implements rdbModel::Builder.

Definition at line 30 of file XercesBuilder.cxx.

30 {
31 xmlBase::XmlParser parser;
32
33 parser.doSchema(true);
34
35 // m_doc = parser.parse(filename.c_str(), "rdbms");
36 m_doc = parser.parse(filename.c_str());
37
38 return (m_doc == 0) ? 0xffffffff : 0;
39 }
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.
Definition: XmlParser.cxx:108
void doSchema(bool doit)
Call this method to turn on schema processing (else it's off)
Definition: XmlParser.cxx:92

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