本文整理汇总了C++中lString16::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ lString16::empty方法的具体用法?C++ lString16::empty怎么用?C++ lString16::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lString16
的用法示例。
在下文中一共展示了lString16::empty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: open
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;
}
示例4: 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;
}
示例5: onToken
void onToken(char token) {
// 4,5: font-family:
// 6,7: font-weight:
// 8,9: font-style:
//10,11: src:
// 10 11 12 13
// src : url (
//CRLog::trace("state==%d: %c ", _state, token);
switch (token) {
case ':':
if (_state < 2) {
_state = 0;
} else if (_state == 4 || _state == 6 || _state == 8 || _state == 10) {
_state++;
} else if (_state != 3) {
_state = 2;
}
break;
case ';':
if (_state < 2) {
_state = 0;
} else if (_state != 3) {
_state = 2;
}
break;
case '{':
if (_state == 1) {
_state = 2; // inside @font {
_face.clear();
_italic = false;
_bold = false;
_url.clear();
} else
_state = 3; // inside other {
break;
case '}':
if (_state == 2) {
if (!_url.empty()) {
// CRLog::trace("@font { face: %s; bold: %s; italic: %s; url: %s", _face.c_str(), _bold ? "yes" : "no",
// _italic ? "yes" : "no", LCSTR(_url));
_fontList.add(_url, _face, _bold, _italic);
}
}
_state = 0;
break;
case '(':
if (_state == 12) {
_state = 13;
} else {
if (_state > 3)
_state = 2;
}
break;
}
}
示例6: 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";
}
}
示例7: saveHistory
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 );
}
示例8: LVOpenFileStream
bool V3DocViewWin::saveSettings( lString16 filename )
{
crtrace log;
if ( filename.empty() )
filename = _settingsFileName;
if ( filename.empty() )
return false;
_settingsFileName = filename;
log << "V3DocViewWin::saveSettings(" << 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() ) {
lString8 fn = UnicodeToUtf8( filename );
CRLog::error("Cannot open settings file %s for write", fn.c_str() );
return false;
}
return _props->saveToStream( stream.get() );
}
示例9: 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() );
}
示例10: loadHistory
bool ReaderViewNative::loadHistory( lString16 filename )
{
CRFileHist * hist = _docview->getHistory();
if ( !filename.empty() )
historyFileName = filename;
historyFileName = filename;
if ( historyFileName.empty() ) {
CRLog::error("No history file name specified");
return false;
}
CRLog::info("Trying to load history from file %s", LCSTR(historyFileName));
LVStreamRef stream = LVOpenFileStream(historyFileName.c_str(), LVOM_READ);
if ( stream.isNull() ) {
CRLog::error("Cannot open file %s", LCSTR(historyFileName));
return false;
}
bool res = hist->loadFromStream( stream );
if ( res )
CRLog::info("%d items found", hist->getRecords().length());
else
CRLog::error("Cannot read history file content");
return res;
}
示例11: matchWord
bool matchWord( const lString16 & prefix )
{
if ( prefix.empty() )
return false;
return word.startsWithNoCase( prefix );
}
示例12: addPropLine
void addPropLine( lString8 & buf, const char * description, const lString16 & value )
{
if ( !value.empty() ) {
buf << "<tr><td>" << description << "</td><td>" << UnicodeToUtf8(value).c_str() << "</td></tr>\n";
}
}