本文整理汇总了C++中lString16类的典型用法代码示例。如果您正苦于以下问题:C++ lString16类的具体用法?C++ lString16怎么用?C++ lString16使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了lString16类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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;
}
开发者ID:CrazyCoder,项目名称:crengine,代码行数:56,代码来源:hyphman.cpp
示例2: processLine
void processLine(lString16 & line) {
if (line.lastChar()=='\r' || line.lastChar()=='\n')
line.erase(line.length()-1, 1);
if (state == 0) {
//
if (line.startsWith(lString16("%"))) {
fprintf(out, "%s\n", LCSTR(line));
return;
}
if (line.startsWith(lString16("\\patterns{"))) {
start();
return;
}
} else {
lString16 word;
for (int i=0; i<=line.length(); i++) {
lChar16 ch = (i<line.length()) ? line[i] : 0;
if (ch == '}')
break;
if (ch==' ' || ch=='\t' || ch=='%' || ch==0) {
if (!word.empty()) {
addPattern(word);
word.clear();
}
if (ch!=' ' && ch!='\t')
break;
} else {
word.append(1, ch);
}
}
}
}
开发者ID:thiensuhack,项目名称:TestCR,代码行数:32,代码来源:mkpattern.cpp
示例3: 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;
}
开发者ID:lunohod-1,项目名称:boox-opensource,代码行数:28,代码来源:mainwnd.cpp
示例4: encodeText
static lString8 encodeText(lString16 text16) {
if (text16.empty())
return lString8::empty_str;
lString8 text = UnicodeToUtf8(text16);
lString8 buf;
for (int i=0; i<text.length(); i++) {
char ch = text[i];
switch (ch) {
case '\\':
buf << "\\\\";
break;
case '\n':
buf << "\\n";
break;
case '\r':
buf << "\\r";
break;
case '\t':
buf << "\\t";
break;
default:
buf << ch;
break;
}
}
return buf;
}
开发者ID:Frenzie,项目名称:crengine,代码行数:27,代码来源:hist.cpp
示例5: addPattern
void addPattern(lString16 pattern) {
if (pattern[0] == '.')
pattern[0] = ' ';
if (pattern[pattern.length()-1] == '.')
pattern[pattern.length()-1] = ' ';
fprintf(out, " <pattern>%s</pattern>\n", LCSTR(pattern));
}
开发者ID:thiensuhack,项目名称:TestCR,代码行数:7,代码来源:mkpattern.cpp
示例6: load
bool TexHyph::load( lString16 fileName )
{
LVStreamRef stream = LVOpenFileStream( fileName.c_str(), LVOM_READ );
if ( stream.isNull() )
return false;
return load( stream );
}
开发者ID:CrazyCoder,项目名称:crengine,代码行数:7,代码来源:hyphman.cpp
示例7: WordWithRanges
WordWithRanges( const lString16 & w, const lString8 & enc, const ldomWord & range )
: word( w ), encoded( enc )
{
wordLower = w;
wordLower.lowercase();
ranges.add( range );
}
开发者ID:Pokec,项目名称:pocketbook-coolreader,代码行数:7,代码来源:dictdlg.cpp
示例8: loadHistory
bool V3DocViewWin::loadHistory( lString16 filename )
{
CRLog::trace("V3DocViewWin::loadHistory( %s )", UnicodeToUtf8(filename).c_str());
_historyFileName = filename;
LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_READ );
return loadHistory( stream );
}
开发者ID:lunohod-1,项目名称:boox-opensource,代码行数:7,代码来源:mainwnd.cpp
示例9: loadDocument
bool ReaderViewNative::loadDocument( lString16 filename )
{
CRLog::info("Loading document %s", LCSTR(filename));
bool res = _docview->LoadDocument(filename.c_str());
CRLog::info("Document %s is loaded %s", LCSTR(filename), (res?"successfully":"with error"));
return res;
}
开发者ID:Trantect,项目名称:CoolReader,代码行数:7,代码来源:readerview.cpp
示例10: splitFName
static void splitFName( lString16 pathname, lString16 & path, lString16 & name )
{
//
int spos = -1;
for ( spos=pathname.length()-1; spos>=0; spos-- ) {
lChar16 ch = pathname[spos];
if ( ch=='\\' || ch=='/' ) {
break;
}
}
if ( spos>=0 ) {
path = pathname.substr( 0, spos+1 );
name = pathname.substr( spos+1, pathname.length()-spos-1 );
} else {
path.clear();
name = pathname;
}
}
开发者ID:Frenzie,项目名称:crengine,代码行数:18,代码来源:hist.cpp
示例11: SetFieldValue
static void SetFieldValue( char * dst, lString16 src )
{
*dst = 0;
if ( src.empty() )
return;
lString8 utf8 = UnicodeToUtf8( src );
strncpy( dst, utf8.c_str(), MAX_PROPERTY_LEN-1);
dst[MAX_PROPERTY_LEN-1] = 0;
}
开发者ID:BlairArchibald,项目名称:Alexandria,代码行数:9,代码来源:fb2props.cpp
示例12: findText
bool SearchDialog::findText( lString16 pattern, int origin, bool reverse, bool caseInsensitive )
{
if ( pattern.empty() )
return false;
if ( pattern!=_lastPattern && origin==1 )
origin = 0;
_lastPattern = pattern;
LVArray<ldomWord> words;
lvRect rc;
_docview->getDocView()->GetPos( rc );
int pageHeight = rc.height();
int start = -1;
int end = -1;
if ( reverse ) {
// reverse
if ( origin == 0 ) {
// from end current page to first page
end = rc.bottom;
} else if ( origin == -1 ) {
// from last page to end of current page
start = rc.bottom;
} else { // origin == 1
// from prev page to first page
end = rc.top;
}
} else {
// forward
if ( origin == 0 ) {
// from current page to last page
start = rc.top;
} else if ( origin == -1 ) {
// from first page to current page
end = rc.top;
} else { // origin == 1
// from next page to last
start = rc.bottom;
}
}
CRLog::debug("CRViewDialog::findText: Current page: %d .. %d", rc.top, rc.bottom);
CRLog::debug("CRViewDialog::findText: searching for text '%s' from %d to %d origin %d", LCSTR(pattern), start, end, origin );
if ( _docview->getDocView()->getDocument()->findText( pattern, caseInsensitive, reverse, start, end, words, 200, pageHeight ) ) {
CRLog::debug("CRViewDialog::findText: pattern found");
_docview->getDocView()->clearSelection();
_docview->getDocView()->selectWords( words );
ldomMarkedRangeList * ranges = _docview->getDocView()->getMarkedRanges();
if ( ranges ) {
if ( ranges->length()>0 ) {
int pos = ranges->get(0)->start.y;
_docview->getDocView()->SetPos(pos);
}
}
return true;
}
CRLog::debug("CRViewDialog::findText: pattern not found");
return false;
}
开发者ID:CrazyCoder,项目名称:coolreader-kindle-qt,代码行数:56,代码来源:searchdlg.cpp
示例13:
bool V3DocViewWin::loadDocument( lString16 filename )
{
if ( !_docview->LoadDocument( filename.c_str() ) ) {
CRLog::error("V3DocViewWin::loadDocument( %s ) - failed!", UnicodeToUtf8(filename).c_str() );
return false;
}
//_docview->swapToCache();
_docview->restorePosition();
return true;
}
开发者ID:lunohod-1,项目名称:boox-opensource,代码行数:10,代码来源:mainwnd.cpp
示例14: TexPattern
TexPattern( const lString16 &s ) : next( NULL )
{
memset( word, 0, sizeof(word) );
memset( attr, '0', sizeof(attr) );
attr[sizeof(attr)-1] = 0;
int n = 0;
for ( int i=0; i<(int)s.length() && n<MAX_PATTERN_SIZE; i++ ) {
lChar16 ch = s[i];
if ( ch>='0' && ch<='9' ) {
attr[n] = (char)ch;
// if (n>0)
// attr[n-1] = (char)ch;
} else {
word[n++] = ch;
}
if (i==(int)s.length()-1)
attr[n+1] = 0;
}
}
开发者ID:CrazyCoder,项目名称:crengine,代码行数:19,代码来源:hyphman.cpp
示例15: setManglingKey
bool setManglingKey(lString16 key) {
if (key.startsWith(lString16(L"urn:uuid:")))
key = key.substr(9);
_fontManglingKey.clear();
_fontManglingKey.reserve(16);
lUInt8 b = 0;
int n = 0;
for (int i=0; i<key.length(); i++) {
int d = hexDigit(key[i]);
if (d>=0) {
b = (b << 4) | d;
if (++n > 1) {
_fontManglingKey.add(b);
n = 0;
b = 0;
}
}
}
return _fontManglingKey.length() == 16;
}
开发者ID:varnie,项目名称:HackedUpReader,代码行数:20,代码来源:epubfmt.cpp
示例16: putTagValue
static void putTagValue( LVStream * stream, int level, const char * tag, lString16 value )
{
for ( int i=0; i<level; i++ )
*stream << " ";
*stream << "<" << tag;
if ( value.empty() ) {
*stream << "/>\r\n";
} else {
*stream << ">" << UnicodeToUtf8( value ).c_str() << "</" << tag << ">\r\n";
}
}
开发者ID:Frenzie,项目名称:crengine,代码行数:11,代码来源:hist.cpp
示例17: LVCreateFileCopyImageSource
bool V3DocViewWin::loadDefaultCover( lString16 filename )
{
LVImageSourceRef cover = LVCreateFileCopyImageSource( filename.c_str() );
if ( !cover.isNull() ) {
_docview->setDefaultCover( cover );
return true;
} else {
IMAGE_SOURCE_FROM_BYTES(defCover, cr3_def_cover_gif);
_docview->setDefaultCover( defCover );
return false;
}
}
开发者ID:lunohod-1,项目名称:boox-opensource,代码行数:12,代码来源:mainwnd.cpp
示例18: UnicodeToUtf8
bool V3DocViewWin::saveHistory( lString16 filename )
{
crtrace log;
if ( filename.empty() )
filename = _historyFileName;
if ( filename.empty() ) {
CRLog::info("Cannot write history file - no file name specified");
return false;
}
CRLog::debug("Exporting bookmarks to %s", UnicodeToUtf8(_bookmarkDir).c_str());
_docview->exportBookmarks(_bookmarkDir); //use default filename
_historyFileName = filename;
log << "V3DocViewWin::saveHistory(" << filename << ")";
LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
if ( !stream ) {
lString16 path16 = LVExtractPath( filename );
lString8 path = UnicodeToLocal( path16 );
#ifdef _WIN32
if ( !CreateDirectoryW( path16.c_str(), NULL ) ) {
CRLog::error("Cannot create directory %s", path.c_str() );
} else {
stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
}
#else
path.erase( path.length()-1, 1 );
CRLog::warn("Cannot create settings file, trying to create directory %s", path.c_str());
if ( mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) ) {
CRLog::error("Cannot create directory %s", path.c_str() );
} else {
stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
}
#endif
}
if ( stream.isNull() ) {
CRLog::error("Error while creating history file %s - position will be lost", UnicodeToUtf8(filename).c_str() );
return false;
}
return saveHistory( stream );
}
开发者ID:lunohod-1,项目名称:boox-opensource,代码行数:39,代码来源:mainwnd.cpp
示例19: findImagesFromDirectory
static void findImagesFromDirectory( lString16 dir, lString16Collection & files ) {
LVAppendPathDelimiter(dir);
if ( !LVDirectoryExists(dir) )
return;
LVContainerRef cont = LVOpenDirectory(dir.c_str());
if ( !cont.isNull() ) {
for ( int i=0; i<cont->GetObjectCount(); i++ ) {
const LVContainerItemInfo * item = cont->GetObjectInfo(i);
if ( !item->IsContainer() ) {
lString16 name = item->GetName();
name.lowercase();
if ( name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".gif")
|| name.endsWith(".jpeg") ) {
files.add(dir + item->GetName());
}
}
}
}
}
开发者ID:frankyifei,项目名称:crengine-snapshot-sourceforge,代码行数:19,代码来源:settings.cpp
示例20: 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() );
}
开发者ID:Trantect,项目名称:CoolReader,代码行数:21,代码来源:readerview.cpp
注:本文中的lString16类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论