本文整理汇总了C++中StrBuf类的典型用法代码示例。如果您正苦于以下问题:C++ StrBuf类的具体用法?C++ StrBuf怎么用?C++ StrBuf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StrBuf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Except
int P4ClientAPI::Except( const char *func, Error *e )
{
StrBuf m;
e->Fmt( &m );
return Except( func, m.Text() );
}
示例2: ErrorStringMatch
static bool ErrorStringMatch(Error *err, const char* msg)
{
StrBuf buf;
err->Fmt(&buf);
string value(buf.Text());
return value.find(msg) != string::npos;
}
示例3: ProcessMessage
void PythonClientUser::ProcessMessage( Error *e )
{
if( this->handler != Py_None )
{
int s = e->GetSeverity();
if ( s == E_EMPTY || s == E_INFO )
{
// info messages should be send to outputInfo
// not outputError, or untagged output looks
// very strange indeed
StrBuf m;
e->Fmt( &m, EF_PLAIN );
PyObject * s = specMgr->CreatePyString( m.Text() );
if( s && CallOutputMethod( "outputInfo", s) )
results.AddOutput( s );
}
else
{
P4Message * msg = (P4Message *) PyObject_New(P4Message, &P4MessageType);
msg->msg = new PythonMessage(e, specMgr);
if( CallOutputMethod( "outputMessage", (PyObject *) msg ) )
results.AddError( e );
}
}
else
results.AddError( e );
}
示例4: ReadConnectionSettings
static void ReadConnectionSettings( lua_State* L, StrBuf& connection )
{
char* buffer = new char[ connection.Length() + 1 ];
strcpy( buffer, connection.Text() );
lua_createtable( L, 3, 0 );
char* start = buffer;
char* ptr = buffer;
int index = 1;
while ( *ptr ) {
if ( *ptr == ',' ) {
lua_pushlstring( L, start, ptr - start );
lua_rawseti( L, -2, index );
++index;
++ptr;
if ( *ptr == ' ' )
++ptr;
start = ptr;
}
else
++ptr;
}
lua_pushlstring( L, start, ptr - start );
lua_rawseti( L, -2, index );
delete[] buffer;
}
示例5: FindListFile
bool FindListFile(const wchar_t *FileName, StrBuf &output)
{
StrBuf Path;
DWORD dwSize;
StrBuf FullPath;
GetFullPath(FileName, FullPath);
StrBuf NtPath;
FormNtPath(FullPath, NtPath);
const wchar_t *final=NULL;
if (GetFileAttributes(NtPath) != INVALID_FILE_ATTRIBUTES)
{
output.Grow(FullPath.Size());
lstrcpy(output, FullPath);
return true;
}
{
const wchar_t *tmp = FSF.PointToName(Info.ModuleName);
Path.Grow(tmp-Info.ModuleName+1);
lstrcpyn(Path,Info.ModuleName,(int)(tmp-Info.ModuleName+1));
dwSize=SearchPath(Path,FileName,NULL,0,NULL,NULL);
if (dwSize)
{
final = Path;
goto success;
}
}
示例6: fprintf
int P4ClientAPI::SetCharset( const char *c )
{
if( P4LUADEBUG_COMMANDS )
fprintf( stderr, "[P4] Setting charset: %s\n", c );
CharSetApi::CharSet cs = CharSetApi::NOCONV;
if ( strlen(c) > 0 ) {
cs = CharSetApi::Lookup( c );
if( cs < 0 )
{
if( exceptionLevel )
{
StrBuf m;
m = "Unknown or unsupported charset: ";
m.Append( c );
return Except( "P4.charset", m.Text() );
}
return 0;
}
}
if( CharSetApi::Granularity( cs ) != 1 ) {
return Except( "P4.charset", "P4Lua does not support a wide charset!");
}
client.SetCharset(c);
client.SetTrans( cs, cs, cs, cs );
return 1;
}
示例7: Diff
void PythonClientUser::Diff( FileSys *f1, FileSys *f2, int doPage,
char *diffFlags, Error *e )
{
EnsurePythonLock guard;
if ( P4PYDBG_CALLS )
cerr << "[P4] Diff() - comparing files" << endl;
//
// Duck binary files. Much the same as ClientUser::Diff, we just
// put the output into Python space rather than stdout.
//
if( !f1->IsTextual() || !f2->IsTextual() )
{
if ( f1->Compare( f2, e ) )
results.AddOutput( "(... files differ ...)" );
return;
}
// Time to diff the two text files. Need to ensure that the
// files are in binary mode, so we have to create new FileSys
// objects to do this.
FileSys *f1_bin = FileSys::Create( FST_BINARY );
FileSys *f2_bin = FileSys::Create( FST_BINARY );
FileSys *t = FileSys::CreateGlobalTemp( f1->GetType() );
f1_bin->Set( f1->Name() );
f2_bin->Set( f2->Name() );
{
//
// In its own block to make sure that the diff object is deleted
// before we delete the FileSys objects.
//
::Diff d;
d.SetInput( f1_bin, f2_bin, diffFlags, e );
if ( ! e->Test() ) d.SetOutput( t->Name(), e );
if ( ! e->Test() ) d.DiffWithFlags( diffFlags );
d.CloseOutput( e );
// OK, now we have the diff output, read it in and add it to
// the output.
if ( ! e->Test() ) t->Open( FOM_READ, e );
if ( ! e->Test() )
{
StrBuf b;
while( t->ReadLine( &b, e ) )
results.AddOutput( b.Text() );
}
}
delete t;
delete f1_bin;
delete f2_bin;
if ( e->Test() ) HandleError( e );
}
示例8:
void
P4ClientApi::SetApiLevel( int level )
{
StrBuf b;
b << level;
apiLevel = level;
client.SetProtocol( "api", b.Text() );
}
示例9: HandleError
void HandleError(Error *InError)
{
#if USE_P4_API
StrBuf ErrorMessage;
InError->Fmt(&ErrorMessage);
OutErrorMessages.Add(FText::FromString(FString(TO_TCHAR(ErrorMessage.Text(), bIsUnicodeServer))));
#endif
}
示例10:
int P4ClientAPI::SetApiLevel( int level )
{
StrBuf b;
b << level;
apiLevel = level;
client.SetProtocol( "api", b.Text() );
ui.SetApiLevel( level );
return 0;
}
示例11: L
P4ClientAPI::P4ClientAPI( lua_State *L )
: L( L )
, specMgr( L )
, ui( L, &specMgr )
{
debug = 0;
server2 = 0;
depth = 0;
exceptionLevel = 2;
maxResults = 0;
maxScanRows = 0;
maxLockTime = 0;
prog = "unnamed p4lua script";
apiLevel = atoi( P4Tag::l_client );
enviro = new Enviro;
// cb.client = this;
InitFlags();
// Enable form parsing
client.SetProtocol( "specstring", "" );
//
// Load the current working directory, and any P4CONFIG file in place
//
HostEnv henv;
StrBuf cwd;
henv.GetCwd( cwd, enviro );
if( cwd.Length() )
enviro->Config( cwd );
//
// Load the current ticket file. Start with the default, and then
// override it if P4TICKETS is set.
//
const char *t;
henv.GetTicketFile( ticketFile );
if( t = enviro->Get( "P4TICKETS" ) ) {
ticketFile = t;
}
//
// Do the same for P4CHARSET
//
const char *lc;
if( ( lc = enviro->Get( "P4CHARSET" )) ) {
SetCharset(lc);
}
}
示例12: p4_retrieve_gui_connections
static int p4_retrieve_gui_connections( lua_State *L ) {
StrBuf settingsFilename;
settingsFilename << getenv( "HOMEDRIVE" );
settingsFilename << getenv( "HOMEPATH" );
settingsFilename << "/.p4qt/settings";
FILE* file = fopen( settingsFilename.Text(), "rt" );
if ( !file )
return 0;
lua_newtable( L ); // p4Connections
int p4ConnectionsCount = 0;
bool inRecentConnections = false;
char line[ 4096 ];
while ( fgets( line, sizeof( line ) - 1, file ) ) {
char* end = line + strlen( line ) - 1;
while ( *end == 13 || *end == 10 )
*end-- = 0;
if ( inRecentConnections ) {
if ( line[0] != '\t' ) {
inRecentConnections = false;
} else {
StrBuf connection;
ReadValue( connection, line + 1 );
ReadConnectionSettings( L, connection );
lua_rawseti( L, -2, ++p4ConnectionsCount );
}
}
if ( !inRecentConnections ) {
if ( strcmp( line, "RecentConnections:" ) == 0 || strcmp( line, "RecentConnection:" ) == 0 )
inRecentConnections = true;
else if ( strncmp( line, "LastConnection=", 15 ) == 0 || strncmp( line, "PrevConnection=", 15 ) == 0 )
{
lua_pushliteral( L, "LastConnection" );
StrBuf connection;
ReadValue( connection, line + 15 );
ReadConnectionSettings( L, connection );
lua_rawset( L, -3 );
}
else if ( strncmp( line, "OpenWorkspaces=", 15 ) == 0 )
{
lua_pushliteral( L, "OpenWorkspaces" );
StrBuf connection;
ReadValue( connection, line + 15 );
ReadConnectionSettings( L, connection );
lua_rawset( L, -3 );
}
}
}
return 1;
}
示例13: L
P4ClientApi::P4ClientApi( lua_State *L )
: L( L )
, specMgr( L )
, ui( L, &specMgr )
, keepAliveRef( LUA_NOREF )
{
initCount = 0;
debug = 0;
server2 = 0;
depth = 0;
exceptionLevel = 2;
maxResults = 0;
maxScanRows = 0;
maxLockTime = 0;
apiLevel = atoi( P4Tag::l_client );
enviro = new Enviro;
prog = "unnamed p4lua script";
cb.client = this;
// Enable form parsing, and set tagged mode on by default
mode |= M_PARSE_FORMS + M_TAGGED ;
client.SetProtocol( "specstring", "" );
//
// Load any P4CONFIG file
//
HostEnv henv;
StrBuf cwd;
henv.GetCwd( cwd, enviro );
if( cwd.Length() )
enviro->Config( cwd );
//
// Load the current ticket file. Start with the default, and then
// override it if P4TICKETS is set.
//
const char *t;
henv.GetTicketFile( ticketFile );
if( t = enviro->Get( "P4TICKETS" ) )
ticketFile = t;
//
// Load the current P4CHARSET if set.
//
if( client.GetCharset().Length() )
SetCharset( client.GetCharset().Text() );
}
示例14: getRepr
void LuaMessage::getRepr()
{
StrBuf a;
StrBuf b;
err.Fmt( a, EF_PLAIN );
b << "[";
b << "Gen:" << err.GetGeneric();
b << "/Sev:" << err.GetSeverity();
b << "]: ";
b << a;
lua_pushlstring( L, b.Text(), b.Length() );
}
示例15: Except
//
// Returns a hash whose keys contain the names of the fields in a spec of the
// specified type. Not yet exposed to Ruby clients, but may be in future.
//
int
P4ClientApi::SpecFields( const char * type )
{
if ( !specMgr.HaveSpecDef( type ) )
{
StrBuf m;
m = "No spec definition for ";
m.Append( type );
m.Append( " objects." );
return Except( "P4#spec_fields", m.Text() );
}
return specMgr.SpecFields( type );
}