本文整理汇总了C++中LVStreamRef类的典型用法代码示例。如果您正苦于以下问题:C++ LVStreamRef类的具体用法?C++ LVStreamRef怎么用?C++ LVStreamRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LVStreamRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: DetectEpubFormat
bool DetectEpubFormat( LVStreamRef stream )
{
LVContainerRef m_arc = LVOpenArchieve( stream );
if ( m_arc.isNull() )
return false; // not a ZIP archive
//dumpZip( m_arc );
// read "mimetype" file contents from root of archive
lString16 mimeType;
{
LVStreamRef mtStream = m_arc->OpenStream(L"mimetype", LVOM_READ );
if ( !mtStream.isNull() ) {
int size = mtStream->GetSize();
if ( size>4 && size<100 ) {
LVArray<char> buf( size+1, '\0' );
if ( mtStream->Read( buf.get(), size, NULL )==LVERR_OK ) {
for ( int i=0; i<size; i++ )
if ( buf[i]<32 || ((unsigned char)buf[i])>127 )
buf[i] = 0;
buf[size] = 0;
if ( buf[0] )
mimeType = Utf8ToUnicode( lString8( buf.get() ) );
}
}
}
}
if ( mimeType != L"application/epub+zip" )
return false;
return true;
}
示例3: env
jbyteArray scanBookCoverInternal
(JNIEnv * _env, jclass _class, jstring _path)
{
CRJNIEnv env(_env);
lString16 path = env.fromJavaString(_path);
CRLog::debug("scanBookCoverInternal(%s) called", LCSTR(path));
lString16 arcname, item;
LVStreamRef res;
jbyteArray array = NULL;
LVContainerRef arc;
if (!LVSplitArcName(path, arcname, item)) {
// not in archive
LVStreamRef stream = LVOpenFileStream(path.c_str(), LVOM_READ);
if (!stream.isNull()) {
arc = LVOpenArchieve(stream);
if (!arc.isNull()) {
// ZIP-based format
if (DetectEpubFormat(stream)) {
// EPUB
// extract coverpage from epub
res = GetEpubCoverpage(arc);
}
} else {
res = GetFB2Coverpage(stream);
if (res.isNull()) {
doc_format_t fmt;
if (DetectPDBFormat(stream, fmt)) {
res = GetPDBCoverpage(stream);
}
}
}
}
} else {
CRLog::debug("scanBookCoverInternal() : is archive, item=%s, arc=%s", LCSTR(item), LCSTR(arcname));
LVStreamRef arcstream = LVOpenFileStream(arcname.c_str(), LVOM_READ);
if (!arcstream.isNull()) {
arc = LVOpenArchieve(arcstream);
if (!arc.isNull()) {
LVStreamRef stream = arc->OpenStream(item.c_str(), LVOM_READ);
if (!stream.isNull()) {
CRLog::debug("scanBookCoverInternal() : archive stream opened ok, parsing");
res = GetFB2Coverpage(stream);
if (res.isNull()) {
doc_format_t fmt;
if (DetectPDBFormat(stream, fmt)) {
res = GetPDBCoverpage(stream);
}
}
}
}
}
}
if (!res.isNull())
array = env.streamToJByteArray(res);
if (array != NULL)
CRLog::debug("scanBookCoverInternal() : returned cover page array");
else
CRLog::debug("scanBookCoverInternal() : cover page data not found");
return array;
}
示例4: LVCreateMemoryStream
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;
}
示例5: env
/*
* Class: org_coolreader_crengine_Engine
* Method: drawBookCoverInternal
* Signature: (Landroid/graphics/Bitmap;[BLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V
*/
JNIEXPORT void JNICALL Java_org_coolreader_crengine_Engine_drawBookCoverInternal
(JNIEnv * _env, jobject _engine, jobject bitmap, jbyteArray _data, jstring _fontFace, jstring _title, jstring _authors, jstring _seriesName, jint seriesNumber, jint bpp)
{
CRJNIEnv env(_env);
//CRLog::debug("drawBookCoverInternal called");
lString8 fontFace = UnicodeToUtf8(env.fromJavaString(_fontFace));
lString16 title = env.fromJavaString(_title);
lString16 authors = env.fromJavaString(_authors);
lString16 seriesName = env.fromJavaString(_seriesName);
LVStreamRef stream;
LVImageSourceRef image;
if (_data != NULL && _env->GetArrayLength(_data) > 0) {
stream = env.jbyteArrayToStream(_data);
if (!stream.isNull())
image = LVCreateStreamImageSource(stream);
}
LVDrawBuf * drawbuf = BitmapAccessorInterface::getInstance()->lock(_env, bitmap);
if (drawbuf != NULL) {
int factor = 1;
int dx = drawbuf->GetWidth();
int dy = drawbuf->GetHeight();
int MIN_WIDTH = 300;
int MIN_HEIGHT = 400;
if (dx < MIN_WIDTH || dy < MIN_HEIGHT) {
if (dx * 2 < MIN_WIDTH || dy * 2 < MIN_HEIGHT) {
dx *= 3;
dy *= 3;
factor = 3;
} else {
dx *= 2;
dy *= 2;
factor = 2;
}
}
LVDrawBuf * drawbuf2 = drawbuf;
if (factor > 1)
drawbuf2 = new LVColorDrawBuf(dx, dy, drawbuf->GetBitsPerPixel());
if (bpp >= 16) {
// native color resolution
LVDrawBookCover(*drawbuf2, image, fontFace, title, authors, seriesName, seriesNumber);
} else {
LVGrayDrawBuf grayBuf(drawbuf2->GetWidth(), drawbuf2->GetHeight(), bpp);
LVDrawBookCover(grayBuf, image, fontFace, title, authors, seriesName, seriesNumber);
grayBuf.DrawTo(drawbuf2, 0, 0, 0, NULL);
}
if (factor > 1) {
drawbuf->DrawRescaled(drawbuf2, 0, 0, drawbuf->GetWidth(), drawbuf->GetHeight(), 0);
delete drawbuf2;
}
//CRLog::trace("getPageImageInternal calling bitmap->unlock");
BitmapAccessorInterface::getInstance()->unlock(_env, bitmap, drawbuf);
} else {
CRLog::error("bitmap accessor is invalid");
}
//CRLog::debug("drawBookCoverInternal finished");
}
示例6: LVOpenFileStream
bool TexHyph::load( lString16 fileName )
{
LVStreamRef stream = LVOpenFileStream( fileName.c_str(), LVOM_READ );
if ( stream.isNull() )
return false;
return load( stream );
}
示例7: initHyph
void initHyph(const char * fname)
{
HyphMan hyphman;
LVStreamRef stream = LVOpenFileStream( fname, LVOM_READ);
if (!stream)
return;
HyphMan::Open( stream.get() );
}
示例8: OpenStream
virtual LVStreamRef OpenStream( const lChar16 * fname, lvopen_mode_t mode ) {
LVStreamRef res = _container->OpenStream(fname, mode);
if (res.isNull())
return res;
if (isEncryptedItem(fname))
return LVStreamRef(new FontDemanglingStream(res, _fontManglingKey));
return res;
}
示例9:
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() );
}
示例10: LCSTR
bool HyphDictionaryList::open(lString16 hyphDirectory, bool clear)
{
CRLog::info("HyphDictionaryList::open(%s)", LCSTR(hyphDirectory) );
if (clear) {
_list.clear();
addDefault();
}
if ( hyphDirectory.empty() )
return true;
//LVAppendPathDelimiter( hyphDirectory );
LVContainerRef container;
LVStreamRef stream;
if ( (hyphDirectory.endsWith("/") || hyphDirectory.endsWith("\\")) && LVDirectoryExists(hyphDirectory) ) {
container = LVOpenDirectory( hyphDirectory.c_str(), L"*.*" );
} else if ( LVFileExists(hyphDirectory) ) {
stream = LVOpenFileStream( hyphDirectory.c_str(), LVOM_READ );
if ( !stream.isNull() )
container = LVOpenArchieve( stream );
}
if ( !container.isNull() ) {
int len = container->GetObjectCount();
int count = 0;
CRLog::info("%d items found in hyph directory", len);
for ( int i=0; i<len; i++ ) {
const LVContainerItemInfo * item = container->GetObjectInfo( i );
lString16 name = item->GetName();
lString16 suffix;
HyphDictType t = HDT_NONE;
if ( name.endsWith(".pdb") ) {
suffix = "_hyphen_(Alan).pdb";
t = HDT_DICT_ALAN;
} else if ( name.endsWith(".pattern") ) {
suffix = ".pattern";
t = HDT_DICT_TEX;
} else
continue;
lString16 filename = hyphDirectory + name;
lString16 id = name;
lString16 title = name;
if ( title.endsWith( suffix ) )
title.erase( title.length() - suffix.length(), suffix.length() );
_list.add( new HyphDictionary( t, title, id, filename ) );
count++;
}
CRLog::info("%d dictionaries added to list", _list.length());
return true;
} else {
CRLog::info("no hyphenation dictionary items found in hyph directory %s", LCSTR(hyphDirectory));
}
return false;
}
示例11: open
bool open() {
LVStreamRef stream = _container->OpenStream(L"META-INF/encryption.xml", LVOM_READ);
if (stream.isNull())
return false;
EncCallback enccallback(this);
LVXMLParser parser(stream, &enccallback, false, false);
if (!parser.Parse())
return false;
if (_list.length())
return true;
return false;
}
示例12: 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.");
}
示例13: readFileToString
lString8 readFileToString( const char * fname )
{
lString8 buf;
LVStreamRef stream = LVOpenFileStream(fname, LVOM_READ);
if (!stream)
return buf;
int sz = stream->GetSize();
if (sz>0)
{
buf.insert( 0, sz, ' ' );
stream->Read( buf.modify(), sz, NULL );
}
return buf;
}
示例14: env
/*
* Class: org_coolreader_crengine_ReaderView
* Method: setPageBackgroundTextureInternal
* Signature: ([BI)V
*/
JNIEXPORT void JNICALL Java_org_coolreader_crengine_ReaderView_setPageBackgroundTextureInternal
(JNIEnv * _env, jobject _this, jbyteArray jdata, jint tileFlags )
{
CRJNIEnv env(_env);
ReaderViewNative * p = getNative(_env, _this);
LVImageSourceRef img;
if ( jdata!=NULL ) {
LVStreamRef stream = env.jbyteArrayToStream( jdata );
if ( !stream.isNull() ) {
img = LVCreateStreamImageSource(stream);
}
}
p->_docview->setBackgroundImage(img, tileFlags!=0);
}
示例15: read
bool read( LVStreamRef stream ) {
// TODO: byte order support
lvsize_t bytesRead = 0;
if ( stream->Read(this, sizeof(PDBHdr), &bytesRead )!=LVERR_OK )
return false;
if ( bytesRead!=sizeof(PDBHdr) )
return false;
lvByteOrderConv cnv;
if ( cnv.lsf() )
{
cnv.rev(&attributes);
cnv.rev(&version);
cnv.rev(&creationDate);
cnv.rev(&modificationDate);
cnv.rev(&lastBackupDate);
cnv.rev(&modificationNumber);
cnv.rev(&appInfoID);
cnv.rev(&sortInfoID);
cnv.rev(&uniqueIDSeed);
cnv.rev(&nextRecordList);
cnv.rev(&recordCount);
cnv.rev(&firstEntry);
}
return true;
}