本文整理汇总了C++中WString::printf方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::printf方法的具体用法?C++ WString::printf怎么用?C++ WString::printf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::printf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editRequest
void VMsgLog::editRequest( WMenuItem* )
{
int index = _batcher->selected();
if( index >= 0 ) {
const char* text = *(WString*)_data[index];
char file[101]; int line, offset; char help[51];
if( matchLine( index, file, line, offset, help ) ) {
WSystemHelp *sh;
const char *hf;
if( findHelpFile( file, &sh, 0 ) == 0 ) {
hf = "";
} else {
hf = sh->getHelpFile();
}
WString msg;
int resId = atoi( help ) + 1;
WFileName filename( file );
if( filename.needQuotes() ) {
msg.printf( "EditFileAtPos -f\"%s\" %d %d 0 %d",
file, line, offset, resId );
} else {
msg.printf( "EditFileAtPos -f%s %d %d 0 %d",
file, line, offset, resId );
}
msg.concat( " \"" );
msg.concat( text ); // error message
msg.concat( "\" " );
msg.concat( hf ); // help file
_parent->executeCommand( msg, EXECUTE_EDITOR, "LogEdit" );
} else {
WMessageDialog::info( this, "Can't find a filename in '%s'", text );
}
}
}
示例2: addFromMask
bool MComponent::addFromMask( WFileName& search, WString& err )
{
bool ok = true;
WFileName asearch( search );
asearch.absoluteTo( _filename );
DIR* dir = opendir( asearch );
if( !dir ) {
err.printf( "no files found for '%s'", (const char*)search );
ok = false;
} else {
for(;;) {
struct dirent* ent = readdir( dir );
if( !ent ) break;
WFileName newfile( ent->d_name );
newfile.setDrive( search.drive() );
newfile.setDir( search.dir() );
// newfile.toLower();
if( !addFromFilename( newfile, err ) ) {
ok = false;
break;
}
}
closedir( dir );
}
return( ok );
}
示例3: updateCurOs
void VCompDialog::updateCurOs( void )
{
MTarget *curtarg;
int pos;
WString curname;
int i;
WPickList& targets = _config->targets();
int icount = _imagelist->count();
for( i=0; i < icount; i++ ) {
_imagelist->deleteString( 0 );
}
pos = 0;
icount = targets.count();
_tgList.reset();
for( i=0; i< icount; i++ ) {
curtarg = (MTarget *)targets[i];
if( _cur_os == curtarg->targetOS() ) {
curname.printf( "%s [%s]", curtarg->imageName().gets(),
curtarg->tgtMask().ext() );
_imagelist->insertString( curname.gets(), pos );
_tgList.insertAt( pos, curtarg );
pos++;
}
}
}
示例4: WBRStrDup
char * ScanStreamFile::name( void )
//---------------------------------
{
WString val;
val.printf( "file \"%s\" (line %d)", _fileName, _line );
return WBRStrDup( val );
}
示例5: initialize
void EdModule::initialize()
//-------------------------
{
WString s;
s.printf( "Modules for %s", _name );
setText( s.gets() );
EditModuleList::initialize();
}
示例6: load
void DTViewClass::load()
//----------------------
{
WVList dataMembers;
WVList methods;
WVList friends;
int i;
WString str;
ClassType * cls = (ClassType *) _symbol;
Symbol * s;
_members->clearAndDestroy();
cls->dataMembers( dataMembers );
cls->memberFunctions( methods );
cls->friendFunctions( friends );
for( i = 0; i < friends.count(); i += 1 ) {
s = (Symbol *) friends[ i ];
str.printf( " friend %s;", s->scopedName( FALSE ) );
_members->insert( new ClassMember( s, str.gets() ) );
}
for( i = 0; i < dataMembers.count(); i += 1 ) {
s = (Symbol *) dataMembers[ i ];
str.printf( " %s;", s->scopedName( FALSE ) );
_members->insert( new ClassMember( s, str.gets() ) );
}
for( i = 0; i < methods.count(); i += 1 ) {
s = (Symbol *) methods[ i ];
str.printf( " %s;", s->scopedName( FALSE ) );
_members->insert( new ClassMember( s, str.gets() ) );
}
addDescriptions();
fillBox();
}
示例7: postTitle
void Browse::postTitle()
//----------------------
{
const char * titleText = "Open Watcom Source Browser";
WString title;
title.printf( "%s -- (%s%s), (%s)", titleText,
optManager()->fileName(),
(optManager()->isModified()) ? "*" : "",
dbManager()->fileName() );
setText( title );
}
示例8: error
bool Scanner::error( const char * err )
/*************************************/
{
WString msg;
WString title;
char * name = _scanStream->name();
msgRetType ret;
msg.printf( "%s near '%s'\n\nContinue?", err, _buffer );
title.printf( "Syntax error in %s", name );
ret = WMessageDialog::message( browseTop, MsgError, MsgOkCancel,
msg, title );
WBRFree( name );
if( ret == MsgRetCancel ) {
return true;
} else {
return false;
}
}
示例9: QueryConfigDlg
QueryConfig::QueryConfig( WWindow * prt, const char * txt )
: QueryConfigDlg( this )
, WDialog( prt, frame().r, txt )
, _filter( NULL )
//----------------------------------------------------------------------
{
WString filttxt;
_searchStrings = new WVList;
filttxt.printf( "%s Filters", txt );
_queryFilter = new QueryFilter( this, txt );
}
示例10: searchHook
static bool searchHook( dr_sym_context * symctxt, void *data )
//------------------------------------------------------------
{
FindSymData * info;
bool accept;
Symbol * sym;
info = (FindSymData *) data;
if( symctxt->name == NULL ) {
symctxt->name = DRGetName( symctxt->handle );
}
accept = info->keysym->matches( symctxt );
if( accept ) {
if( info->numItems == 0 ) {
WBRFree( symctxt->name );
symctxt->name = NULL;
info->context = new SearchContext( *symctxt->context );
return false; // <----- early return -- stop search
}
if( info->numItems > 0 ) {
info->numItems -= 1;
}
sym = Symbol::defineSymbol( symctxt->type, symctxt->handle,
symctxt->context->classhdl,
info->call_module,
symctxt->name );
info->data->add( sym );
#if DEBUG
if( !(info->data->count() % 10) ) {
WString stat;
stat.printf( "Loading - %d found", info->data->count() );
browseTop->statusText( stat.gets() );
}
#endif
} else {
WBRFree( symctxt->name );
}
return true; // continue searching
}
示例11: addFromFilename
bool MComponent::addFromFilename( WFileName& filename, WString& err )
{
if( filename.isMask() ) {
return( addFromMask( filename, err ) );
}
MRule* rule = _config->findMatchingRule( filename, _target->rule(), _mask );
if( rule ) {
if( rule == _config->nilRule() ) {
unsigned cnt;
cnt = _items.count();
for( ; cnt > 0; cnt-- ) {
if( *(MItem *)_items[cnt - 1] == filename ) break;
}
if( cnt == 0 ) {
MItem* item = new MItem( filename, this, rule );
newItem( item );
} else {
return( false );
}
} else {
MItem* item = new MItem( filename, this, rule );
MComponent* comp = NULL;
MItem* m = _project->findSameResult( item, &comp );
if( !m ) {
newItem( item );
} else {
delete item;
if( comp != this ) {
err.printf( "Conflicting file '%s' found in target '%s'",
(const char*)*m, (const char*)*comp->target() );
return( false );
}
}
}
return( true );
}
return( false );
}
示例12: debugInfo
void TreeNode::debugInfo( TreeRoot * root )
//-----------------------------------------
{
WString boundLine;
WString descendLine;
char * enabled;
char * placed;
WString statLine;
WString refLine;
WString rootLine;
TreeCoord ox, oy;
TreeRect rootRect;
ox = _parent->getXOff();
oy = _parent->getYOff();
root->getBound( rootRect );
rootLine.printf( "_rootNode = %s, bounding(%ld,%ld,%ld,%ld) ",
root->node()->name(), rootRect.x(), rootRect.y(),
rootRect.w(), rootRect.h() );
boundLine.printf( "_bounding [%s] = (%ld,%ld,%ld,%ld), offset = (%ld,%ld) ",
(_flags.boundSet) ? "set" : "unset",
_bounding.x(), _bounding.y(),
_bounding.w(), _bounding.h(),
ox, oy );
descendLine.printf( "_sibWidth = %ld, _descend = (%ld,%ld,%ld,%ld) ",
_sibWidth, _descend.x(), _descend.y(),
_descend.w(), _descend.h() );
switch( _flags.enabled ) {
case Hidden:
enabled = "Hidden";
break;
default:
enabled = "Visible";
break;
}
switch( _flags.placed ) {
case NotPlaced:
placed = "NotPlaced";
break;
case PartiallyPlaced:
placed = "PartiallyPlaced";
break;
case Arranging:
placed = "Arranging";
break;
default:
placed = "Placed";
}
statLine.printf( " enabled = %s, placed = %s, selected = %s, _level = %d\n",
enabled, placed, (_flags.selected) ? "true" : "false",
getLevel() );
refLine.printf( "hasReference() = %s, isReference() = %s",
hasReference() ? "true" : "false",
isReference() ? "true" : "false" );
WMessageDialog::messagef( _parent, MsgPlain, MsgOk, name(), "%s%s%s%s%s",
(const char *)rootLine, (const char *)boundLine,
(const char *)descendLine, (const char *)statLine,
(const char *)refLine );
}
示例13: TreeFuncHook
bool TreeFuncNode::TreeFuncHook( drmem_hdl owner, dr_ref_info * ref,
char* ownerName, void * info )
//------------------------------------------------------------------
// this function really needs to be split up
{
int parentIndex;
int parentRoot;
TreeFuncNode * parent = NULL;
int childIndex;
int childRoot;
TreeFuncNode * child = NULL;
FuncSearchData* data = (FuncSearchData *) info;
char * depName;
bool accept;
#if DEBUG
data->funcsFound += 1;
if( !(data->funcsFound % 10) ) {
WString stat;
stat.printf( "Loading - %d found", data->funcsFound );
browseTop->statusText( stat.gets() );
}
#endif
// find if the symbol matches the filter
depName = DRGetName( ref->dependent );
accept = data->key->matches( ref->dependent, depName );
WBRFree( depName ); // OPTIMIZE -- could use this later
if( !accept ) {
return true; // <---- early return -- discard symbol, keep looking
}
for( int i = data->roots->count(); i > 0; i -= 1 ) {
TreeFuncNode * rt = (TreeFuncNode*) (*data->roots)[ i - 1 ];
parentIndex = rt->findNode( owner );
if( !parent ) {
if( parentIndex >= 0 ) {
parent = (TreeFuncNode *)(*rt->_flatNodes)[ parentIndex ];
parentRoot = i - 1;
}
}
if( !child ) {
childIndex = rt->findNode( ref->dependent );
if( childIndex >= 0 ) {
child = (TreeFuncNode *)(*rt->_flatNodes)[ childIndex ];
childRoot = i - 1;
}
}
if( child != NULL && parent != NULL ) {
break;
}
}
if( child != NULL && parent != NULL ) {
WBRFree( ownerName );
if( parentRoot == childRoot ) {
int prtIdx = child->findParent( parent );
if( prtIdx < 0 ) {
if( ref->dependent == owner ) { // direct recursion -- a->a
bool inReferences = false;
for( int refIdx = 0; refIdx < child->_flatReferences->count(); refIdx += 1 ) {
if( (*child->_flatReferences)[ refIdx ]->getHandle() == owner ) {
TreeNode * node = (*child->_flatReferences)[ refIdx ];
for( int ref2idx = 0; ref2idx < node->getCount( ParentList ); ref2idx += 1 ) {
if( node->getNode( ParentList, ref2idx )->getHandle() == owner ) {
TreePtr * ptr = node->getPtr( ParentList, ref2idx );
((TreeRefPtr*)ptr)->incRefs();
inReferences = true;
break;
}
}
}
if( inReferences ) {
break;
}
}
if( !inReferences ) {
TreeRefNode * newRef;
newRef = new TreeRefNode( data->parentWin, parent, parent );
parent->_children.add( newRef );
parent->_hasRef = true;
parent->_flatReferences->add( newRef );
}
} else {
parent->_children.add( child );
child->_parents.add(
new TreeFuncPtr( data->parentWin, child, parent, *ref ) );
}
} else {
TreePtr * ptr = child->getPtr( ParentList, prtIdx );
//.........这里部分代码省略.........
示例14: getToken
//.........这里部分代码省略.........
for( count = 0; ; count += 1 ) {
if(( c == '\\' ) && ( _lookFor == LF_MagicString )) {
c = _scanStream->get();
if( isspace( c )) {
_scanStream->unget( c );
c = '\\';
} else {
escaped = true;
}
}
if( c == EOF ) {
if( count == 0 ) {
if( CurrentScanner > 0 ) {
if( _lastToken == T_FileSync || _lastToken == EOF ) {
delete this;
return yylex();
} else {
_lastToken = T_FileSync;
return T_FileSync;
}
} else {
return 0; // done
}
} else {
flush = true;
}
} else if( inquoted && !escaped ) {
if( c == '"' ) {
c = _scanStream->get(); // skip the quote
flush = true;
}
} else if( isspace( c ) || strchr( StartComments, c ) ) {
flush = true;
} else if( strchr( Special, c ) && !escaped ) {
if( count == 0 ) {
_lastToken = c;
return c;
} else {
flush = true;
}
}
if( count >= BufSize - 1 ) {
flush = true;
}
if( flush ) {
_scanStream->unget( c );
_buffer[ count ] = '\0';
if(( _lookFor != LF_String ) && ( _lookFor != LF_MagicString )) {
fnd = tryToken( _lookFor, _buffer );
if( fnd > 0 ) {
lval = fnd;
return fnd;
} else {
if( _recovering ) {
flush = false;
count = -1;
} else {
WString msg;
char * ambigs;
ambigs = tryAmbig( _lookFor, _buffer );
if( ambigs != NULL ) {
msg.printf( "[%s] is ambiguous -- try %s --",
_buffer, ambigs );
WBRFree( ambigs );
} else {
msg.printf( "Unrecognized symbol [%s]", _buffer );
}
if( error( msg ) ) {
return 0;
}
_recovering = true;
flush = false;
count = -1;
}
}
} else {
_stringTable.add( strdup( _buffer ));
lval = _stringTable.count() - 1;
if( _lookFor == LF_String ) {
_lastToken = T_String;
} else {
_lastToken = T_MagicString;
}
return _lastToken;
}
} else {
_buffer[ count ] = (char) c;
}
escaped = false;
c = _scanStream->get();
}
}
示例15: initialize
void DTViewSymbol::initialize()
//-----------------------------
// create the detail view of the symbol and size it.
{
WString titleText;
WRect tmpRect;
char fName[_MAX_PATH];
int width;
int tmpWidth;
int height;
rescale();
//----------------- "Function initialize" title ----------------
titleText.printf( "%s %s", SymbolTitleText[ _symbol->symtype() ],
_symbol->name() );
setText( titleText.gets() );
width = getTextExtentX( titleText.gets() ) + CaptionGadgetSize;
//---------- "Defined: D:\dev\browser\cpp\dtvsym.cpp" line ----------
if( _symbol->defSourceFile( fName ) ) {
_fileText.printf( "%s: %s", (_symbol->isDefined()) ? Defined : Declared, fName );
height = _symbolLineR.r.y();
} else {
height = _fileNameR.r.y();
}
tmpWidth = _fileNameR.r.x() + abs( _fileNameR.r.w() ) +
getTextExtentX( _fileText.gets() );
width = maxInt( width, tmpWidth );
//------- "void DTViewSymbol::initialize()" line -------
tmpRect = _symbolLineR.r;
tmpRect.y( height );
_descPaint = new DescriptionPaint( this, tmpRect, _symbol );
height += _symbolBoxR.r.y() - _symbolLineR.r.y();
tmpWidth = _symbolLineR.r.x() + _descPaint->rect().w() + abs( _symbolLineR.r.w() );
width = maxInt( width, tmpWidth );
//------------------ member listbox --------------------
if( _useBox ) {
tmpRect = _symbolBoxR.r;
tmpRect.y( height );
_symbolBox = new WListBox( this, tmpRect,
LStyleNoIntegral | WStyleHScroll | WStyleVScroll );
_symbolBox->show();
_symbolBox->setFocus();
height += __frame.r.h() - _symbolBoxR.r.y(); // this include 2 * dialogFrameHeight
}
width += 2 * WSystemMetrics::dialogFrameWidth();
height += WSystemMetrics::captionSize();
size( width, height );
show();
}