本文整理汇总了C++中LVStreamRef::get方法的典型用法代码示例。如果您正苦于以下问题:C++ LVStreamRef::get方法的具体用法?C++ LVStreamRef::get怎么用?C++ LVStreamRef::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LVStreamRef
的用法示例。
在下文中一共展示了LVStreamRef::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_actionOpen_triggered
void MainWindow::on_actionOpen_triggered()
{
QString lastPath;
LVPtrVector<CRFileHistRecord> & files = ui->view->getDocView()->getHistory()->getRecords();
if ( files.length()>0 ) {
lastPath = cr2qt( files[0]->getFilePath() );
}
QString fileName = QFileDialog::getOpenFileName(this, tr("Open book file"),
lastPath,
tr("All supported formats (*.fb2 *.txt *.tcr *.rtf *.doc *.epub *.html *.htm *.chm *.zip *.pdb *.pml *.prc *.pml *.mobi);;FB2 books (*.fb2 *.fb2.zip);;Text files (*.txt);;Rich text (*.rtf);;MS Word document (*.doc);;HTML files (*.htm *.html);;EPUB files (*.epub);;CHM files (*.chm);;MOBI files (*.mobi *.prc *.azw);;PalmDOC files (*.pdb *.pml);;ZIP archives (*.zip)"));
if ( fileName.length()==0 )
return;
if ( !ui->view->loadDocument( fileName ) ) {
// error
} else {
#ifdef _DEBUG
LVStreamRef in = ui->view->getDocView()->getCoverPageImageStream();
if ( !in.isNull() ) {
LVStreamRef out = LVOpenFileStream("/tmp/cover.png", LVOM_WRITE);
if ( !out.isNull() ) {
LVPumpStream( out.get(), in.get() );
}
}
#endif
update();
}
}
示例2: LVOpenFileStream
bool V3DocViewWin::loadSettings( lString16 filename )
{
_settingsFileName = filename;
LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_READ );
if ( stream.isNull() ) {
_docview->propsUpdateDefaults( _props );
_docview->propsApply( _props );
_wm->getScreen()->setFullUpdateInterval(_props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
_wm->getScreen()->setTurboUpdateEnabled(_props->getIntDef(PROP_DISPLAY_TURBO_UPDATE_MODE, 0));
//setAccelerators( _wm->getAccTables().get(lString16("main"), _props) );
return false;
}
if ( _props->loadFromStream( stream.get() ) ) {
_props->setIntDef(PROP_FILE_PROPS_FONT_SIZE, 26);
_docview->propsUpdateDefaults( _props );
_docview->propsApply( _props );
_wm->getScreen()->setFullUpdateInterval(_props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
_wm->getScreen()->setTurboUpdateEnabled(_props->getIntDef(PROP_DISPLAY_TURBO_UPDATE_MODE, 0));
setAccelerators( _wm->getAccTables().get(lString16("main"), _props) );
return true;
}
_docview->propsUpdateDefaults( _props );
_docview->propsApply( _props );
_wm->getScreen()->setFullUpdateInterval(_props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
_wm->getScreen()->setTurboUpdateEnabled(_props->getIntDef(PROP_DISPLAY_TURBO_UPDATE_MODE, 0));
//setAccelerators( _wm->getAccTables().get(lString16("main"), _props) );
return false;
}
示例3: saveToStream
bool CRFileHist::saveToStream( LVStream * targetStream )
{
LVStreamRef streamref = LVCreateMemoryStream(NULL, 0, false, LVOM_WRITE);
LVStream * stream = streamref.get();
const char * xml_hdr = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<FictionBookMarks>\r\n";
const char * xml_ftr = "</FictionBookMarks>\r\n";
//const char * crlf = "\r\n";
*stream << xml_hdr;
for ( int i=0; i<_records.length(); i++ ) {
CRFileHistRecord * rec = _records[i];
putTag( stream, 1, "file" );
putTag( stream, 2, "file-info" );
putTagValue( stream, 3, "doc-title", rec->getTitle() );
putTagValue( stream, 3, "doc-author", rec->getAuthor() );
putTagValue( stream, 3, "doc-series", rec->getSeries() );
putTagValue( stream, 3, "doc-filename", rec->getFileName() );
putTagValue( stream, 3, "doc-filepath", rec->getFilePath() );
putTagValue( stream, 3, "doc-filesize", lString16::itoa( (unsigned int)rec->getFileSize() ) );
putTag( stream, 2, "/file-info" );
putTag( stream, 2, "bookmark-list" );
putBookmark( stream, rec->getLastPos() );
for ( int j=0; j<rec->getBookmarks().length(); j++) {
CRBookmark * bmk = rec->getBookmarks()[j];
putBookmark( stream, bmk );
}
putTag( stream, 2, "/bookmark-list" );
putTag( stream, 1, "/file" );
}
*stream << xml_ftr;
LVPumpStream( targetStream, stream );
return true;
}
示例4: initHyph
void initHyph(const char * fname)
{
HyphMan hyphman;
LVStreamRef stream = LVOpenFileStream( fname, LVOM_READ);
if (!stream)
return;
HyphMan::Open( stream.get() );
}
示例5:
bool V3DocViewWin::saveHistory( LVStreamRef stream )
{
if ( stream.isNull() ) {
CRLog::error("Cannot open history file for write" );
return false;
}
_docview->getHistory()->limit( 32 );
return _docview->getHistory()->saveToStream( stream.get() );
}
示例6: dumpZip
static void dumpZip( LVContainerRef arc ) {
lString16 arcName = LVExtractFilenameWithoutExtension( arc->GetName() );
if ( arcName.empty() )
arcName = L"unziparc";
lString16 outDir = lString16("/tmp/") + arcName;
LVCreateDirectory(outDir);
for ( int i=0; i<arc->GetObjectCount(); i++ ) {
const LVContainerItemInfo * info = arc->GetObjectInfo(i);
if ( !info->IsContainer() ) {
lString16 outFileName = outDir + L"/" + info->GetName();
LVCreateDirectory(LVExtractPath(outFileName));
LVStreamRef in = arc->OpenStream(info->GetName(), LVOM_READ);
LVStreamRef out = LVOpenFileStream(outFileName.c_str(), LVOM_WRITE);
if ( !in.isNull() && !out.isNull() ) {
CRLog::trace("Writing %s", LCSTR(outFileName));
LVPumpStream(out.get(), in.get());
}
}
}
}
示例7: InitCREngineLog
void InitCREngineLog( const char * cfgfile )
{
if ( !cfgfile ) {
CRLog::setStdoutLogger();
CRLog::setLogLevel( CRLog::LL_TRACE );
return;
}
lString16 logfname;
lString16 loglevelstr =
#ifdef _DEBUG
L"TRACE";
#else
L"INFO";
#endif
bool autoFlush = false;
CRPropRef logprops = LVCreatePropsContainer();
{
LVStreamRef cfg = LVOpenFileStream( cfgfile, LVOM_READ );
if ( !cfg.isNull() ) {
logprops->loadFromStream( cfg.get() );
logfname = logprops->getStringDef( PROP_LOG_FILENAME, "stdout" );
loglevelstr = logprops->getStringDef( PROP_LOG_LEVEL, "TRACE" );
autoFlush = logprops->getBoolDef( PROP_LOG_AUTOFLUSH, false );
}
}
CRLog::log_level level = CRLog::LL_INFO;
if ( loglevelstr==L"OFF" ) {
level = CRLog::LL_FATAL;
logfname.clear();
} else if ( loglevelstr==L"FATAL" ) {
level = CRLog::LL_FATAL;
} else if ( loglevelstr==L"ERROR" ) {
level = CRLog::LL_ERROR;
} else if ( loglevelstr==L"WARN" ) {
level = CRLog::LL_WARN;
} else if ( loglevelstr==L"INFO" ) {
level = CRLog::LL_INFO;
} else if ( loglevelstr==L"DEBUG" ) {
level = CRLog::LL_DEBUG;
} else if ( loglevelstr==L"TRACE" ) {
level = CRLog::LL_TRACE;
}
if ( !logfname.empty() ) {
if ( logfname==L"stdout" )
CRLog::setStdoutLogger();
else if ( logfname==L"stderr" )
CRLog::setStderrLogger();
else
CRLog::setFileLogger( UnicodeToUtf8( logfname ).c_str(), autoFlush );
}
CRLog::setLogLevel( level );
CRLog::trace("Log initialization done.");
}
示例8: saveHistory
bool ReaderViewNative::saveHistory( lString16 filename )
{
if ( !filename.empty() )
historyFileName = filename;
if ( historyFileName.empty() )
return false;
if ( _docview->isDocumentOpened() ) {
CRLog::debug("ReaderViewNative::saveHistory() : saving position");
_docview->savePosition();
}
CRLog::info("Trying to save history to file %s", LCSTR(historyFileName));
CRFileHist * hist = _docview->getHistory();
LVStreamRef stream = LVOpenFileStream(historyFileName.c_str(), LVOM_WRITE);
if ( stream.isNull() ) {
CRLog::error("Cannot create file %s for writing", LCSTR(historyFileName));
return false;
}
if ( _docview->isDocumentOpened() )
_docview->savePosition();
return hist->saveToStream( stream.get() );
}
示例9: AntiwordStreamGuard
AntiwordStreamGuard(LVStreamRef stream) {
antiword_stream = stream.get();
}
示例10: main
int main(int argc, char *argv[])
{
int res = 0;
{
Device::instance(); // initialize device
#ifndef i386
QProcess::execute("eips -c");
pTouch = new TouchScreen();
#endif
lString16 exedir = LVExtractPath(LocalToUnicode(lString8(argv[0])));
LVAppendPathDelimiter(exedir);
lString16 datadir = exedir + "data/";
lString16 exefontpath = exedir + "fonts";
lString16Collection fontDirs;
fontDirs.add(exefontpath);
#ifndef i386
fontDirs.add("/usr/java/lib/fonts");
fontDirs.add("/mnt/us/fonts");
#endif
CRPropRef props = LVCreatePropsContainer();
{
LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + "cr3.ini").data(), LVOM_READ);
if(!cfg.isNull()) props->loadFromStream(cfg.get());
}
lString16 lang = props->getStringDef(PROP_WINDOW_LANG, "");
InitCREngineLog(props);
CRLog::info("main()");
if(!InitCREngine(argv[0], fontDirs)) {
printf("Cannot init CREngine - exiting\n");
return 2;
}
#ifndef i386
PrintString(1, 1, "crengine version: " + QString(CR_ENGINE_VERSION));
PrintString(1, 2, QString("build date: %1 %2").arg(__DATE__).arg(__TIME__));
if (!Device::isTouch()) {
QString message = "Please wait while application is loading...";
int xpos = ((Device::getWidth()/12-1)-message.length())/2;
int ypos = (Device::getHeight()/20-2)/2;
PrintString(xpos, ypos, message);
}
#endif
// to catch crashes and remove current cache file on crash (SIGSEGV etc.)
crSetSignalHandler();
// set row count depending on device model (used in lists)
int rc = props->getIntDef(PROP_WINDOW_ROW_COUNT, 0);
if(!rc) {
#ifndef i386
switch(Device::getModel()) {
case Device::KDX:
rc = 20;
break;
case Device::KT:
case Device::KPW:
rc = 8;
break;
default:
rc = 10;
}
props->setInt(PROP_WINDOW_ROW_COUNT, rc);
#else
props->setInt(PROP_WINDOW_ROW_COUNT, 10);
#endif
LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + "cr3.ini").data(), LVOM_WRITE);
props->saveToStream(cfg.get());
}
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
MyApplication a(argc, argv);
pMyApp = &a;
// set app stylesheet
#ifndef i386
QString style = Device::isTouch() ? "stylesheet_pw.qss" : "stylesheet_k3.qss";
QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + style);
// set up full update interval for the graphics driver
Device::setFullScreenUpdateEvery(props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
#else
QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + "stylesheet_k3.qss");
#endif
qss.open(QFile::ReadOnly);
if(qss.error() == QFile::NoError) {
a.setStyleSheet(qss.readAll());
qss.close();
}
QMap<QString, QString> langToCode;
langToCode["Russian"] = "ru";
langToCode["French"] = "fr";
langToCode["Hungarian"] = "hu";
langToCode["Italian"] = "it";
langToCode["German"] = "de";
langToCode["Ukrainian"] = "uk";
QString translations = cr2qt(datadir) + "i18n";
QTranslator myappTranslator, qtr;
if (!lang.empty() && lang.compare("English")) {
QString lng = cr2qt(lang);
if (myappTranslator.load(lng, translations)) {
//.........这里部分代码省略.........
示例11: load
bool TexHyph::load( LVStreamRef stream )
{
int w = isCorrectHyphFile(stream.get());
int patternCount = 0;
if (w) {
_hash = stream->crc32();
int i;
lvsize_t dw;
lvByteOrderConv cnv;
int hyph_count = w;
thyph hyph;
lvpos_t p = 78 + (hyph_count * 8 + 2);
stream->SetPos(p);
if ( stream->SetPos(p)!=p )
return false;
lChar16 charMap[256];
unsigned char buf[0x10000];
memset( charMap, 0, sizeof( charMap ) );
// make char map table
for (i=0; i<hyph_count; i++)
{
if ( stream->Read( &hyph, 522, &dw )!=LVERR_OK || dw!=522 )
return false;
cnv.msf( &hyph.len ); //rword(_main_hyph[i].len);
lvpos_t newPos;
if ( stream->Seek( hyph.len, LVSEEK_CUR, &newPos )!=LVERR_OK )
return false;
cnv.msf( hyph.wl );
cnv.msf( hyph.wu );
charMap[ (unsigned char)hyph.al ] = hyph.wl;
charMap[ (unsigned char)hyph.au ] = hyph.wu;
// lChar16 ch = hyph.wl;
// CRLog::debug("wl=%s mask=%c%c", LCSTR(lString16(&ch, 1)), hyph.mask0[0], hyph.mask0[1]);
if (hyph.mask0[0]!='0'||hyph.mask0[1]!='0') {
unsigned char pat[4];
pat[0] = hyph.al;
pat[1] = hyph.mask0[0];
pat[2] = hyph.mask0[1];
pat[3] = 0;
TexPattern * pattern = new TexPattern(pat, 1, charMap);
#if DUMP_PATTERNS==1
CRLog::debug("Pattern: '%s' - %s", LCSTR(lString16(pattern->word)), pattern->attr );
#endif
addPattern( pattern );
patternCount++;
}
}
if ( stream->SetPos(p)!=p )
return false;
for (i=0; i<hyph_count; i++)
{
stream->Read( &hyph, 522, &dw );
if (dw!=522)
return false;
cnv.msf( &hyph.len );
stream->Read(buf, hyph.len, &dw);
if (dw!=hyph.len)
return false;
unsigned char * p = buf;
unsigned char * end_p = p + hyph.len;
while ( p < end_p ) {
lUInt8 sz = *p++;
if ( p + sz > end_p )
break;
TexPattern * pattern = new TexPattern( p, sz, charMap );
#if DUMP_PATTERNS==1
CRLog::debug("Pattern: '%s' - %s", LCSTR(lString16(pattern->word)), pattern->attr);
#endif
addPattern( pattern );
patternCount++;
p += sz + sz + 1;
}
}
return patternCount>0;
} else {
// tex xml format as for FBReader
lString16Collection data;
HyphPatternReader reader( data );
LVXMLParser parser( stream, &reader );
if ( !parser.CheckFormat() )
return false;
if ( !parser.Parse() )
return false;
if ( !data.length() )
return false;
for ( int i=0; i<(int)data.length(); i++ ) {
data[i].lowercase();
TexPattern * pattern = new TexPattern( data[i] );
#if DUMP_PATTERNS==1
CRLog::debug("Pattern: (%s) '%s' - %s", LCSTR(data[i]), LCSTR(lString16(pattern->word)), pattern->attr);
#endif
//.........这里部分代码省略.........
示例12: TestWol
void TestWol()
{
{
LVStreamRef stream = LVOpenFileStream("woltest.wol", LVOM_WRITE);
if (!stream)
return;
LVArray<lUInt32> m(10, 0xbad);
m.clear();
WOLWriter wol(stream.get());
wol.addTitle(
lString8("book title"),
lString8("subj."),
lString8("John Smith"),
lString8("adapter"),
lString8("translator"),
lString8("publisher"),
lString8("2006-11-01"),
lString8("This is introduction."),
lString8("ISBN")
);
LVGrayDrawBuf cover(600, 800);
cover.FillRect(20, 20, 50, 50, 1);
cover.FillRect(40, 70, 120, 190, 2);
cover.FillRect(60, 80, 150, 290, 3);
LVGrayDrawBuf page1(600, 800, 2);
page1.FillRect(0, 0, 150, 150, 1);
page1.FillRect(70, 70, 140, 140, 2);
page1.FillRect(130, 130, 180, 180, 3);
page1.FillRect(400, 400, 550, 750, 1);
page1.FillRect(420, 420, 530, 730, 2);
page1.FillRect(440, 440, 510, 710, 3);
LVGrayDrawBuf page2(600, 800, 2);
page2.FillRect(120, 20, 150, 50, 1);
page2.FillRect(140, 70, 220, 190, 2);
page2.FillRect(160, 80, 250, 290, 3);
LVGrayDrawBuf page3(600, 800, 2);
page3.FillRect(120, 120, 30, 20, 1);
page3.FillRect(10, 10, 120, 120, 2);
page3.FillRect(300, 300, 300, 700, 3);
page3.FillRect(400, 400, 550, 750, 1);
page3.FillRect(420, 420, 530, 730, 2);
page3.FillRect(440, 440, 510, 710, 3);
wol.addCoverImage(cover);
wol.addImage(page1);
wol.addImage(page2);
wol.addImage(page3);
SaveBitmapToFile("page1.bmp", &page1);
SaveBitmapToFile("page2.bmp", &page2);
SaveBitmapToFile("page3.bmp", &page3);
}
{
//LVStream * stream = LVOpenFileStream("Biblia.wol", LVOM_READ);
LVStreamRef stream = LVOpenFileStream("woltest.wol", LVOM_READ);
//LVStream * stream = LVOpenFileStream("info2.wol", LVOM_READ);
if (!stream)
return;
WOLReader rd(stream.get());
if (!rd.readHeader())
return;
LVStreamRef cover = LVOpenFileStream("cover2.bin", LVOM_WRITE);
LVStreamRef log = LVOpenFileStream("woltest.log", LVOM_WRITE);
LVArray<lUInt8> * rdcover = rd.getBookCover();
LVGrayDrawBuf * rdimg1 = rd.getImage(0);
*cover << *rdcover;
//int imgsz = (rdimg1->GetWidth()*2+7)/8*rdimg1->GetHeight();
//LVArray<lUInt8> imgbuf(imgsz, 0);
//memcpy(imgbuf.ptr(), rdimg1->GetScanLine(0), imgsz );
if (rdimg1)
SaveBitmapToFile( "test.bmp", rdimg1 );
//*img << imgbuf;
*log << rd.getBookTitle();
*log << "\r\nimages found: " << lString8::itoa(rd.getImageCount());
delete rdimg1;
}
}
示例13: main
int main(int argc, char *argv[])
{
int res = 0;
{
Device::instance(); // initialize device
#ifndef i386
QProcess::execute("eips -c");
pTouch = new TouchScreen();
#endif
lString16 exedir = LVExtractPath(LocalToUnicode(lString8(argv[0])));
LVAppendPathDelimiter(exedir);
lString16 datadir = exedir + L"data/";
lString16 exefontpath = exedir + L"fonts";
lString16Collection fontDirs;
fontDirs.add(exefontpath);
#ifndef i386
fontDirs.add(lString16(L"/usr/java/lib/fonts"));
fontDirs.add(lString16(L"/mnt/us/fonts"));
#endif
CRPropRef props = LVCreatePropsContainer();
{
LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + L"cr3.ini").data(), LVOM_READ);
if(!cfg.isNull()) props->loadFromStream(cfg.get());
}
lString16 lang = props->getStringDef(PROP_WINDOW_LANG, "");
InitCREngineLog(props);
CRLog::info("main()");
if(!InitCREngine(argv[0], fontDirs)) {
printf("Cannot init CREngine - exiting\n");
return 2;
}
#ifndef i386
PrintString(1, 1, "crengine version: " + QString(CR_ENGINE_VERSION));
PrintString(1, 2, QString("buid date: %1 %2").arg(__DATE__).arg(__TIME__));
if (!Device::isTouch()) {
QString message = "Please wait while application is loading...";
int xpos = ((Device::getWidth()/12-1)-message.length())/2;
int ypos = (Device::getHeight()/20-2)/2;
PrintString(xpos, ypos, message);
}
#endif
// set row count
int rc = props->getIntDef(PROP_WINDOW_ROW_COUNT, 0);
if(!rc) {
#ifndef i386
props->setInt(PROP_WINDOW_ROW_COUNT, Device::getModel() != Device::KDX ? 10 : 16);
#else
props->setInt(PROP_WINDOW_ROW_COUNT, 10);
#endif
LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + L"cr3.ini").data(), LVOM_WRITE);
props->saveToStream(cfg.get());
}
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
MyApplication a(argc, argv);
pMyApp = &a;
// set app stylesheet
#ifndef i386
QString style = (Device::getModel() != Device::KDX ? "stylesheet_k3.qss" : "stylesheet_dx.qss");
if (Device::getModel() == Device::KPW) style = "stylesheet_pw.qss";
QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + style);
// set up full update interval for the graphics driver
QKindleFb *pscreen = static_cast<QKindleFb*>(QScreen::instance());
pscreen->setFullUpdateEvery(props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
#else
QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + "stylesheet_k3.qss");
#endif
qss.open(QFile::ReadOnly);
if(qss.error() == QFile::NoError) {
a.setStyleSheet(qss.readAll());
qss.close();
}
QString translations = cr2qt(datadir) + "i18n";
QTranslator myappTranslator;
if(!lang.empty() && lang.compare(L"English")) {
if(myappTranslator.load(cr2qt(lang), translations))
QApplication::installTranslator(&myappTranslator);
else
qDebug("Can`t load translation file %s from dir %s", UnicodeToUtf8(lang).c_str(), UnicodeToUtf8(qt2cr(translations)).c_str());
}
(void) signal(SIGUSR1, sigCatcher);
MainWindow mainWin;
a.setMainWindow(&mainWin);
mainWin.showFullScreen();
mainWin.doStartupActions();
res = a.exec();
}
ShutdownCREngine();
return res;
}