本文整理汇总了C++中Book::file方法的典型用法代码示例。如果您正苦于以下问题:C++ Book::file方法的具体用法?C++ Book::file怎么用?C++ Book::file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::file方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readMetaInfo
bool DocPlugin::readMetaInfo(Book &book) const {
if (!DocMetaInfoReader(book).readMetaInfo()) {
return false;
}
shared_ptr<ZLInputStream> stream = new DocCharStream(book.file(), 50000);
if (!detectEncodingAndLanguage(book, *stream)) {
stream = new DocAnsiStream(book.file(), 50000);
detectLanguage(book, *stream, ZLEncodingConverter::UTF8, true);
}
return true;
}
示例2: readMetaInfo
bool RtfPlugin::readMetaInfo(Book &book) const {
if (!RtfDescriptionReader(book).readDocument(book.file())) {
return false;
}
if (book.encoding().empty()) {
book.setEncoding("utf-8");
} else if (book.language().empty()) {
shared_ptr<ZLInputStream> stream = new RtfReaderStream(book.file(), 50000);
if (!stream.isNull()) {
detectLanguage(book, *stream);
}
}
return true;
}
示例3: readLanguageAndEncoding
bool OEBPlugin::readLanguageAndEncoding(Book &book) const {
if (book.language().empty()) {
shared_ptr<ZLInputStream> oebStream = new OEBTextStream(opfFile(book.file()));
detectLanguage(book, *oebStream, book.encoding());
}
return true;
}
示例4: removeBook
bool BooksDB::removeBook(const Book &book) {
if (!isInitialized() || book.bookId() == 0) {
return false;
}
myDeleteBook->setFileName(book.file().path());
return executeAsTransaction(*myDeleteBook);
}
示例5: readLanguageAndEncoding
bool TxtPlugin::readLanguageAndEncoding(Book &book) const {
shared_ptr<ZLInputStream> stream = book.file().inputStream();
if (stream.isNull()) {
return false;
}
detectEncodingAndLanguage(book, *stream);
return !book.encoding().empty();
}
示例6: readMetaInfo
bool PluckerPlugin::readMetaInfo(Book &book) const {
shared_ptr<ZLInputStream> stream = new PluckerTextStream(book.file());
detectEncodingAndLanguage(book, *stream);
if (book.encoding().empty()) {
return false;
}
return true;
}
示例7: readMetaInfo
bool OEBPlugin::readMetaInfo(Book &book) const {
const ZLFile &file = book.file();
shared_ptr<ZLInputStream> lock = file.inputStream();
const ZLFile opfFile = this->opfFile(file);
bool code = OEBMetaInfoReader(book).readMetaInfo(opfFile);
if (code && book.language().empty()) {
shared_ptr<ZLInputStream> oebStream = new OEBTextStream(opfFile);
detectLanguage(book, *oebStream);
}
return code;
}
示例8: readMetaInfo
bool HtmlPlugin::readMetaInfo(Book &book) const {
shared_ptr<ZLInputStream> stream = book.file().inputStream();
if (stream.isNull()) {
return false;
}
shared_ptr<ZLInputStream> htmlStream = new HtmlReaderStream(stream, 50000);
detectEncodingAndLanguage(book, *htmlStream);
if (book.encoding().empty()) {
return false;
}
HtmlDescriptionReader(book).readDocument(*stream);
return true;
}
示例9: readMetaInfo
bool EReaderPlugin::readMetaInfo(Book &book) const {
shared_ptr<ZLInputStream> stream = book.file().inputStream();
if (stream.isNull() || ! stream->open()) {
return false;
}
PdbHeader header;
if (!header.read(stream)) {
return false;
}
stream->seek(header.Offsets[0] + 46, true);
unsigned short metaInfoOffset;
PdbUtil::readUnsignedShort(*stream, metaInfoOffset);
if (metaInfoOffset == 0 || metaInfoOffset >= header.Offsets.size()) {
return false;
}
std::size_t currentOffset = header.Offsets[metaInfoOffset];
std::size_t nextOffset =
(metaInfoOffset + 1 < (unsigned short)header.Offsets.size()) ?
header.Offsets[metaInfoOffset + 1] : stream->sizeOfOpened();
if (nextOffset <= currentOffset) {
return false;
}
std::size_t length = nextOffset - currentOffset;
char* metaInfoBuffer = new char[length];
stream->seek(currentOffset, true);
stream->read(metaInfoBuffer, length);
std::string metaInfoStr(metaInfoBuffer, length);
delete[] metaInfoBuffer;
std::string metaInfoData[5]; // Title; Author; Rights; Publisher; isbn;
for (std::size_t i = 0; i < 5; ++i) {
const std::size_t index = metaInfoStr.find('\0');
metaInfoData[i] = metaInfoStr.substr(0,index);
metaInfoStr = metaInfoStr.substr(index + 1);
}
if (!metaInfoData[0].empty()) {
book.setTitle(metaInfoData[0]);
}
if (!metaInfoData[1].empty()) {
book.addAuthor(metaInfoData[1]);
}
stream->close();
return SimplePdbPlugin::readMetaInfo(book);
}
示例10: readMetaInfo
bool CHMPlugin::readMetaInfo(Book &book) const {
const ZLFile &file = book.file();
shared_ptr<ZLInputStream> stream = file.inputStream();
if (stream.isNull() || !stream->open()) {
return false;
}
CHMFileInfo chmFile(file);
if (!chmFile.init(*stream)) {
return false;
}
CHMFileInfo::FileNames names = chmFile.sectionNames(stream);
if (names.empty()) {
return false;
}
/*
shared_ptr<ZLInputStream> entryStream = chmFile.entryStream(stream, names.Start);
if (entryStream.isNull()) {
entryStream = chmFile.entryStream(stream, names.Home);
}
if (entryStream.isNull()) {
entryStream = chmFile.entryStream(stream, names.TOC);
}
/ *
if (entryStream.isNull()) {
chmFile.entryStream(stream, names.Index);
}
* /
if (entryStream.isNull()) {
return false;
}
*/
CHMTextStream textStream(chmFile, stream);
detectEncodingAndLanguage(book, textStream);
if (book.encoding().empty()) {
return false;
}
return true;
}
示例11: readMetainfo
bool SimplePdbPlugin::readMetainfo(Book &book) const {
const ZLFile &file = book.file();
shared_ptr<ZLInputStream> stream = createStream(file);
detectEncodingAndLanguage(book, *stream);
if (book.encoding().empty()) {
return false;
}
int readType = HtmlMetainfoReader::NONE;
if (book.title().empty()) {
readType |= HtmlMetainfoReader::TITLE;
}
if (book.authors().empty()) {
readType |= HtmlMetainfoReader::AUTHOR;
}
if (readType != HtmlMetainfoReader::NONE) {
//if ((readType != HtmlMetainfoReader::NONE) && TextFormatDetector().isHtml(*stream)) {
readType |= HtmlMetainfoReader::TAGS;
HtmlMetainfoReader metainfoReader(book, (HtmlMetainfoReader::ReadType)readType);
metainfoReader.readDocument(*stream);
}
return true;
}
示例12: readUids
bool OEBPlugin::readUids(Book &book) const {
const ZLFile &file = book.file();
return OEBUidReader(book).readUids(opfFile(file));
}
示例13: OEBEncryptionReader
std::vector<shared_ptr<FileEncryptionInfo> > OEBPlugin::readEncryptionInfos(Book &book) const {
const ZLFile &opf = opfFile(book.file());
return OEBEncryptionReader().readEncryptionInfos(epubFile(opf), opf);
}
示例14: readMetainfo
bool OEBPlugin::readMetainfo(Book &book) const {
const ZLFile &file = book.file();
return OEBMetaInfoReader(book).readMetainfo(opfFile(file));
}