本文整理汇总了C++中StrBuf::Text方法的典型用法代码示例。如果您正苦于以下问题:C++ StrBuf::Text方法的具体用法?C++ StrBuf::Text怎么用?C++ StrBuf::Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrBuf
的用法示例。
在下文中一共展示了StrBuf::Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Except
int
P4ClientApi::FormatSpec( const char * type, int table )
{
if ( !specMgr.HaveSpecDef( type ) )
{
StrBuf m;
m = "No spec definition for ";
m.Append( type );
m.Append( " objects." );
return Except( "P4#format_spec", m.Text() );
}
// Got a specdef so now we can attempt to convert.
StrBuf buf;
Error e;
specMgr.SpecToString( type, table, buf, &e );
if( !e.Test() ) {
lua_pushstring( L, buf.Text() );
return 1;
}
StrBuf m;
m = "Error converting hash to a string.";
if( e.Test() ) e.Fmt( m, EF_PLAIN );
return Except( "P4#format_spec", m.Text() );
}
示例2: Except
int P4ClientAPI::Run( const char *cmd, int argc, char * const *argv )
{
// Save the entire command string for our error messages. Makes it
// easy to see where a script has gone wrong.
StrBuf cmdString;
cmdString << "\"p4 " << cmd;
for( int i = 0; i < argc; i++ )
cmdString << " " << argv[ i ];
cmdString << "\"";
if ( P4LUADEBUG_COMMANDS )
fprintf( stderr, "[P4] Executing %s\n", cmdString.Text() );
if ( depth )
{
lua_pushboolean( L, false );
lua_pushstring( L, "Can't execute nested Perforce commands." );
return 2;
}
// Clear out any results from the previous command
ui.Reset();
// Tell the UI which command we're running.
ui.SetCommand( cmd );
if ( ! IsConnected() && exceptionLevel ) {
Except( "P4.run()", "not connected." );
return 0;
}
if ( ! IsConnected() ) {
lua_pushboolean( L, false );
return 1;
}
depth++;
RunCmd( cmd, &ui, argc, argv );
depth--;
if( ui.GetHandler() != LUA_NOREF ) {
if( client.Dropped() && ! ui.IsAlive() ) {
Disconnect();
ConnectOrReconnect();
}
}
P4Result &results = ui.GetResults();
if ( results.ErrorCount() && exceptionLevel )
return Except( "P4:run", "Errors during command execution", cmdString.Text() );
if ( results.WarningCount() && exceptionLevel > 1 )
return Except( "P4:run", "Warnings during command execution",cmdString.Text());
lua_rawgeti( L, LUA_REGISTRYINDEX, results.GetOutput() );
return 1;
}
示例3:
int P4ClientAPI::Except( const char *func, const char *msg )
{
StrBuf m;
StrBuf errors;
StrBuf warnings;
bool terminate = false;
m << "[" << func << "] " << msg;
// Now append any errors and warnings to the text
ui.GetResults().FmtErrors( errors );
ui.GetResults().FmtWarnings( warnings );
if( errors.Length() )
{
m << "\n" << errors;
terminate= true;
}
if( exceptionLevel > 1 && warnings.Length() )
{
m << "\n" << warnings;
terminate= true;
}
if( terminate )
m << "\n\n";
if ( exceptionLevel )
{
luaL_error( L, m.Text() );
return 0;
}
lua_pushnil( L );
if( apiLevel < 68 ) {
lua_pushstring( L, m.Text() );
} else {
// return a list with three elements:
// the string value, the list of errors and list of warnings
// P4Exception will sort out what's what
lua_newtable( L );
lua_pushstring( L, m.Text() );
lua_rawseti( L, -2, 1 );
lua_rawgeti( L, LUA_REGISTRYINDEX, ui.GetResults().GetErrors() );
lua_rawseti( L, -2, 2 );
lua_rawgeti( L, LUA_REGISTRYINDEX, ui.GetResults().GetWarnings() );
lua_rawseti( L, -2, 3 );
}
return 2;
}
示例4: sprintf
static int p4_map_inspect(lua_State* L) {
P4MapMaker* m = p4_checkmap(L, 1);
StrBuf b;
StrBuf tb;
tb.Alloc( 32 );
sprintf( tb.Text(), "%p", (void*) m );
tb.SetLength();
b << "#<P4::Map:" << tb << "> ";
m->Inspect( b );
lua_pushlstring(L, b.Text(), b.Length());
return 1;
}
示例5: 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;
}
示例6: 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 );
}
示例7: ErrorStringMatch
static bool ErrorStringMatch(Error *err, const char* msg)
{
StrBuf buf;
err->Fmt(&buf);
string value(buf.Text());
return value.find(msg) != string::npos;
}
示例8: 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 );
}
示例9:
void
P4ClientApi::SetApiLevel( int level )
{
StrBuf b;
b << level;
apiLevel = level;
client.SetProtocol( "api", b.Text() );
}
示例10: 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
}
示例11: if
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;
}
示例12: 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() );
}
示例13: Conn
// Default handler of P4 error output. Called by the default P4Command::Message() handler.
void P4Command::HandleError( Error *err )
{
if ( err == 0 )
return;
StrBuf buf;
err->Fmt(&buf);
if (HandleOnlineStatusOnError(err))
{
Conn().Log().Fatal() << buf.Text() << Endl;
return; // Error logged and Unity notified about plugin offline
}
// This is a regular non-connection related error
VCSStatus s = errorToVCSStatus(*err);
m_Status.insert(s.begin(), s.end());
// m_Status will contain the error messages to be sent to unity
// Just log locally
Conn().Log().Fatal() << buf.Text() << Endl;
}
示例14: HandleError
void
ClientUserLua::HandleError( Error *e )
{
if( P4LUADEBUG_CALLS )
fprintf( stderr, "[P4] HandleError()\n" );
if( P4LUADEBUG_DATA )
{
StrBuf t;
e->Fmt( t, EF_PLAIN );
fprintf( stderr, "... [%s] %s\n", e->FmtSeverity(), t.Text() );
}
results.AddError( e );
}
示例15: Disconnect
void FPerforceConnection::Disconnect()
{
#if USE_P4_API
Error P4Error;
P4Client.Final(&P4Error);
if (P4Error.Test())
{
StrBuf ErrorMessage;
P4Error.Fmt(&ErrorMessage);
UE_LOG(LogSourceControl, Error, TEXT("P4ERROR: Failed to disconnect from Server."));
UE_LOG(LogSourceControl, Error, TEXT("%s"), TO_TCHAR(ErrorMessage.Text(), bIsUnicode));
}
#endif
}