void RecordParser::parse(const unsigned char * content, int content_size, RecordParseListener &listener) { ContentBuffer reader(content, content_size); reader.prepare(1); if (reader.content[reader.cursor] != 0) throw parse_exception("unsupported version"); readDocument(reader, listener); }
std::string OEBSimpleIdReader::readId(const ZLFile &file) { myPublicationId.erase(); myBuffer.erase(); myReadState = READ_NONE; readDocument(file); return myPublicationId; }
bool EncodingIntReader::fillTable(int *map) { myMap = map; for (int i = 0; i < 256; ++i) { myMap[i] = i; } return readDocument(myFilePath); }
bool XHTMLReader::readFile(const ZLFile &file, const std::string &referenceName) { fillTagTable(); myPathPrefix = MiscUtil::htmlDirectoryPrefix(file.path()); myReferenceAlias = fileAlias(referenceName); myModelReader.addHyperlinkLabel(myReferenceAlias); const int index = referenceName.rfind('/', referenceName.length() - 1); myReferenceDirName = referenceName.substr(0, index + 1); myPreformatted = false; myNewParagraphInProgress = false; myReadState = XHTML_READ_NOTHING; myBodyCounter = 0; myCurrentParagraphIsEmpty = true; myStyleSheetTable.clear(); myFontMap = new FontMap(); myTagDataStack.clear(); myStyleParser = new StyleSheetSingleStyleParser(myPathPrefix); myTableParser.reset(); return readDocument(file.inputStream(myEncryptionMap)); }
XMLDocument::XMLDocument(const char *path, bool validate, std::string * error, const char * encoding, const bool html): XMLObject() { char *expandedPath = expandPathVariable(const_cast<char *>(path)); if (expandedPath) { if (html) { document = readHTMLDocument(const_cast<const char *>(expandedPath), encoding, error); } else { document = readDocument(const_cast<const char *>(expandedPath), encoding, validate, error); } FREE(expandedPath); if (document) { openDocs.push_back(this); scope->registerPointers(document, this); } } else { document = 0; *error = std::string(gettext("Invalid file name: ")) + std::string(path); } id = scope->getVariableId(*this); scilabType = XMLDOCUMENT; }
bool JSON::load(Variant & root, const std::string & filename) { // Create tokenizer for JSON Tokenizer tokenizer; tokenizer.setOptions( Tokenizer::OptionParseStrings | Tokenizer::OptionParseNumber | Tokenizer::OptionParseBoolean | Tokenizer::OptionParseNull | Tokenizer::OptionCStyleComments | Tokenizer::OptionCppStyleComments ); tokenizer.setQuotationMarks("\""); tokenizer.setSingleCharacters("{}[],:"); // Load file if (!tokenizer.loadDocument(filename)) { return false; } // Begin parsing return readDocument(root, tokenizer); }
bool OEBUidReader::readUids(const ZLFile &file) { myReadState = READ_NONE; if (!readDocument(file)) { return false; } return true; }
bool OEBBookReader::readBook(const std::string &fileName) { myFilePrefix = MiscUtil::htmlDirectoryPrefix(fileName); myIdToHref.clear(); myHtmlFileNames.clear(); myNCXTOCFileName.erase(); myTourTOC.clear(); myGuideTOC.clear(); myState = READ_NONE; if (!readDocument(fileName)) { return false; } myModelReader.setMainTextModel(); myModelReader.pushKind(REGULAR); XHTMLReader xhtmlReader(myModelReader); for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) { if (it != myHtmlFileNames.begin()) { myModelReader.insertEndOfSectionParagraph(); } xhtmlReader.readFile(myFilePrefix + *it, *it); } generateTOC(); return true; }
bool XHTMLReader::readFile(const ZLFile &file, const std::string &referenceName) { fillTagTable(); myPathPrefix = MiscUtil::htmlDirectoryPrefix(file.path()); myReferenceAlias = fileAlias(referenceName); myModelReader.addHyperlinkLabel(myReferenceAlias); const int index = referenceName.rfind('/', referenceName.length() - 1); myReferenceDirName = referenceName.substr(0, index + 1); myPreformatted = false; myNewParagraphInProgress = false; myReadState = READ_NOTHING; myCurrentParagraphIsEmpty = true; myStyleSheetTable.clear(); myCSSStack.clear(); myStyleEntryStack.clear(); myStylesToRemove = 0; myDoPageBreakAfterStack.clear(); myStyleParser = new StyleSheetSingleStyleParser(); myTableParser.reset(); return readDocument(file); }
bool FB2MetaInfoReader::readMetaInfo() { myReadState = READ_NOTHING; for (int i = 0; i < 3; ++i) { myAuthorNames[i].erase(); } return readDocument(myBook.file()); }
void MetaInfoReader::elementStart(const QString &name) { switch (parserState()) { case ParsingDocument: setParserState(readDocument(name)); break; case ParsingMetaInfo: setParserState(readMetaInfoRootElement(name)); break; case ParsingType: setParserState(readTypeElement(name)); break; case ParsingItemLibrary: setParserState(readItemLibraryEntryElement(name)); break; case ParsingProperty: setParserState(readPropertyElement(name)); break; case ParsingQmlSource: setParserState(readQmlSourceElement(name)); break; case Finished: case Undefined: setParserState(Error); addError(tr("Illegal state while parsing"), currentSourceLocation()); case Error: default: return; } }
bool DocBookReader::readBook() { const ZLFile &file = myModelReader.model().book()->file(); shared_ptr<ZLInputStream> stream = file.inputStream(); if (stream.isNull()) { return false; } return readDocument(stream, file.size()); }
int main(void) { element* html = readDocument(); printDocument(html); deleteElement(html); return 0; }
void DocxReader::readContent() { m_xml.readNextStartElement(); if (m_xml.qualifiedName() == "w:styles") { readStyles(); } else if (m_xml.qualifiedName() == "w:document") { readDocument(); } }
bool ORBookReader::readBook() { const ZLFile &file = myModelReader.model().book()->file(); myFilePrefix = MiscUtil::htmlDirectoryPrefix(file.path()); myResources.clear(); myCoverReference.erase(); myHtmlFileIDs.clear(); myImageIDs.clear(); myHtmlFilesOrder.clear(); myTOC.clear(); myState = READ_NONE; if (!readDocument(file)) { return false; } myModelReader.setMainTextModel(); myModelReader.pushKind(REGULAR); if (!myCoverReference.empty()) { myModelReader.addImageReference(myCoverReference); } for (std::vector<std::string>::const_iterator it = myHtmlFilesOrder.begin(); it != myHtmlFilesOrder.end(); ++it) { myHtmlFileIDs.erase(*it); XHTMLReader(myModelReader).readFile(ZLFile(myFilePrefix + myResources[*it]), *it); } int level = 1; for (std::vector<TOCItem>::const_iterator it = myTOC.begin(); it != myTOC.end(); ++it) { int index = myModelReader.model().label(it->Reference).ParagraphNumber; if (index != -1) { for (; level > it->Level; --level) { myModelReader.endContentsParagraph(); } ++level; myModelReader.beginContentsParagraph(index); myModelReader.addContentsData(it->Text); } } for (; level > 1; --level) { myModelReader.endContentsParagraph(); } for (std::set<std::string>::const_iterator it = myHtmlFileIDs.begin(); it != myHtmlFileIDs.end(); ++it) { myModelReader.setFootnoteTextModel(*it); myModelReader.pushKind(REGULAR); XHTMLReader(myModelReader).readFile(ZLFile(myFilePrefix + myResources[*it]), *it); } for (std::map<std::string,std::string>::const_iterator it = myImageIDs.begin(); it != myImageIDs.end(); ++it) { myModelReader.addImage(it->first, new ZLFileImage(ZLFile(myFilePrefix + myResources[it->first], it->second), 0)); } return true; }
shared_ptr<const ZLImage> FB2CoverReader::readCover() { myReadCoverPage = false; myLookForImage = false; myImageId.erase(); myImageStart = -1; readDocument(myFile); return myImage; }
bool JSON::parse(Variant & root, const std::string & document) { auto tokenizer = createJSONTokenizer(); // Set document tokenizer.setDocument(document); // Begin parsing return readDocument(root, tokenizer); }
//! Constructor to create a snapshot from a given file CSnapshot(const Ogre::String &sValidPath) { m_XMLDoc.LoadFile(sValidPath.c_str()); if (m_XMLDoc.Error()) { throw Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND, "XMLdoc parsing error with file: " + sValidPath, __FILE__); } // read the document readDocument(); }
bool XHTMLReader::readFile(const std::string &pathPrefix, const std::string &fileName, const std::string &referenceName) { myModelReader.addHyperlinkLabel(referenceName); fillTagTable(); myPathPrefix = pathPrefix; myReferenceName = referenceName; myPreformatted = false; return readDocument(pathPrefix + fileName); }
shared_ptr<ZLImage> OEBCoverReader::readCover(const std::string &filePath) { myPathPrefix = MiscUtil::htmlDirectoryPrefix(filePath); myReadGuide = false; myImage = 0; myCoverXHTML.erase(); readDocument(filePath); myPathPrefix = MiscUtil::htmlDirectoryPrefix(myCoverXHTML); if (!myCoverXHTML.empty()) { XHTMLImageFinder(*this).readDocument(myCoverXHTML); } return myImage; }
bool FB2DescriptionReader::readDescription(const std::string &fileName) { myReadState = READ_NOTHING; for (int i = 0; i < 3; ++i) { myAuthorNames[i].erase(); } myGenreBuffer.erase(); bool code = readDocument(fileName); if (myBook.authors().empty()) { myBook.authors().push_back( new DBAuthor() ); } return code; }
bool XHTMLReader::readFile(const std::string &pathPrefix, shared_ptr<ZLInputStream> stream, const std::string &referenceName) { myModelReader.addHyperlinkLabel(referenceName); fillTagTable(); myPathPrefix = pathPrefix; myReferenceName = referenceName; myPreformatted = false; return readDocument(stream); }
bool JSON::load(Variant & root, const std::string & filename) { auto tokenizer = createJSONTokenizer(); // Load file if (!tokenizer.loadDocument(filename)) { return false; } // Begin parsing return readDocument(root, tokenizer); }
void FB2MigrationReader::doRead(const ZLFile &file) { myReadState = READ_NOTHING; readDocument(file); if (myUpdateTags) { std::string tagList; for (std::set<std::string>::const_iterator it = myTags.begin(); it != myTags.end(); ++it) { if (it != myTags.begin()) { tagList += ","; } tagList += *it; } myInfo.TagsOption.setValue(tagList); } }
bool OEBBookReader::readBook(const ZLFile &file) { myFilePrefix = MiscUtil::htmlDirectoryPrefix(file.path()); myIdToHref.clear(); myHtmlFileNames.clear(); myNCXTOCFileName.erase(); myCoverFileName.erase(); myCoverFileType.erase(); myCoverMimeType.erase(); myTourTOC.clear(); myGuideTOC.clear(); myState = READ_NONE; if (!readDocument(file)) { return false; } myModelReader.setMainTextModel(); myModelReader.pushKind(REGULAR); //ZLLogger::Instance().registerClass("oeb"); XHTMLReader xhtmlReader(myModelReader); for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) { const ZLFile xhtmlFile(myFilePrefix + *it); if (it == myHtmlFileNames.begin()) { if (myCoverFileName == xhtmlFile.path()) { if (coverIsSingleImage()) { addCoverImage(); continue; } xhtmlReader.setMarkFirstImageAsCover(); } else { addCoverImage(); } } else { myModelReader.insertEndOfSectionParagraph(); } //ZLLogger::Instance().println("oeb", "start " + xhtmlFile.path()); xhtmlReader.readFile(xhtmlFile, *it); //ZLLogger::Instance().println("oeb", "end " + xhtmlFile.path()); //std::string debug = "para count = "; //ZLStringUtil::appendNumber(debug, myModelReader.model().bookTextModel()->paragraphsNumber()); //ZLLogger::Instance().println("oeb", debug); } generateTOC(xhtmlReader); return true; }
bool OEBDescriptionReader::readDescription(const std::string &fileName) { myReadMetaData = false; myReadState = READ_NONE; bool code = readDocument(fileName); if (code) { if (!myAuthorList.empty()) { for (std::vector<std::string>::const_iterator it = myAuthorList.begin(); it != myAuthorList.end(); ++it) { myDescription.addAuthor(*it); } } else { for (std::vector<std::string>::const_iterator it = myAuthorList2.begin(); it != myAuthorList2.end(); ++it) { myDescription.addAuthor(*it); } } } return code; }
shared_ptr<ZLArrayBasedStatistics> ZLStatisticsXMLReader::readStatistics(const std::string &fileName) { std::map<std::string, shared_ptr<ZLArrayBasedStatistics> >::iterator it = statisticsMap.find(fileName); if (it != statisticsMap.end()) { return it->second; } shared_ptr<ZLInputStream> statisticsStream = ZLFile(fileName).inputStream(); if (statisticsStream.isNull() || !statisticsStream->open()) { return 0; } readDocument(statisticsStream); statisticsStream->close(); statisticsMap.insert(std::make_pair(fileName, myStatisticsPtr)); return myStatisticsPtr; }
bool DocBookReader::readBook() { const ZLFile &file = myModelReader.model().book()->file(); shared_ptr<ZLInputStream> stream = file.inputStream(); if (stream.isNull() || !stream->open()) { return false; } myModelReader.setMainTextModel(); myModelReader.pushKind(REGULAR); myModelReader.beginParagraph(); if (!readDocument(stream, true)) { return false; } myModelReader.insertEndOfTextParagraph(); return true; }
bool OEBMetaInfoReader::readMetaInfo(const ZLFile &file) { myReadState = READ_NONE; if (!readDocument(file)) { ZLLogger::Instance().println("epub", "Failure while reading info from " + file.path()); return false; } if (!myAuthorList.empty()) { for (std::vector<std::string>::const_iterator it = myAuthorList.begin(); it != myAuthorList.end(); ++it) { myBook.addAuthor(*it); } } else { for (std::vector<std::string>::const_iterator it = myAuthorList2.begin(); it != myAuthorList2.end(); ++it) { myBook.addAuthor(*it); } } return true; }
CSnapshot(const void *pointer, const size_t size) { memcpy(&m_eCurrentGameState, pointer, sizeof(CGameState::EGameStates)); char *pChar = new char[size]; memcpy(pChar, static_cast<const CGameState::EGameStates*>(pointer) + 1, size - sizeof(CGameState::EGameStates)); m_XMLDoc.Parse(pChar); if (m_XMLDoc.Error()) { throw Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND, "Save state xml document cout not be parsed. Error code" + Ogre::StringConverter::toString(m_XMLDoc.ErrorID()) + " File content:\n" + Ogre::String(pChar), __FILE__); } delete [] pChar; // read the document readDocument(); }