/* * XMLReader.hh * * Created on: 7 août 2013 * Author: CS */ #ifndef XMLREADER_HH_ #define XMLREADER_HH_ #include "AbstractReader.hh" #include namespace TimeTableCatalog { class XMLReader: public TimeTableCatalog::AbstractReader { public: XMLReader(const std::string& pPath); virtual ~XMLReader(); /** * Reads an XML file */ void read(TimeTable& pTT); /** * Checks the XML tt reader is the right one. Returns false if * the tt XML format is not the expected format. */ bool canRead(const std::string& pPath); protected: /** * Parses an XML file */ void parse(TimeTable& pTT); /** * Processes each interested node of an XMl file. */ virtual void processNode(TimeTable& pTT, xmlTextReaderPtr reader, int &crtIndex) = 0; /** * Checks one of the pMaxTagToRead first nodes is named pNode. * Calls containsNode(xmlTextReaderPtr reader, std::string& pNode). */ bool containsNode(const std::string& pPath, std::string pNode, int pMaxTagToRead = 5); /** * Processes a node and returns true if the currently processed * node is nammed pNode. */ bool containsNode(xmlTextReaderPtr reader, std::string& pNode); /** * Gets the xml expected first node name (except xml tag). */ virtual std::string getFirstNode() = 0; /** * Steps during read : the reader first reads a start tag, * then reads the tag value and then reads the end tag. */ enum READ_STEP { NO_TAG = 0, START_TAG = 1, TEXT = 2, END_TAG = 3 }; /** * The previous start date of an interval, to create an interval * when the stop date is read. */ double _tmpIntervalstartdate; /** * The current tag (set when step is START_TAG). */ std::string _tmpCurrentTag; /** * The current step. */ READ_STEP _step; }; } /* namespace TimeTableCatalog */ #endif /* XMLREADER_HH_ */