当前位置: 首页>>代码示例>>C++>>正文


C++ StrBuf::Text方法代码示例

本文整理汇总了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() );
}
开发者ID:Malaar,项目名称:luaplus51-all,代码行数:27,代码来源:p4clientapi.cpp

示例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;
}
开发者ID:scw000000,项目名称:Engine,代码行数:58,代码来源:p4clientapi.cpp

示例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;
}
开发者ID:scw000000,项目名称:Engine,代码行数:56,代码来源:p4clientapi.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例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;
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例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 );
}
开发者ID:azakk,项目名称:p4python,代码行数:31,代码来源:PythonClientUser.cpp

示例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;
}
开发者ID:robterrell,项目名称:VersionControlPlugins,代码行数:7,代码来源:P4Command.cpp

示例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 );
}
开发者ID:azakk,项目名称:p4python,代码行数:59,代码来源:PythonClientUser.cpp

示例9:

void
P4ClientApi::SetApiLevel( int level )
{
	StrBuf	b;
	b << level;
	apiLevel = level;
	client.SetProtocol( "api", b.Text() );
}
开发者ID:Malaar,项目名称:luaplus51-all,代码行数:8,代码来源:p4clientapi.cpp

示例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
	}
开发者ID:aovi,项目名称:UnrealEngine4,代码行数:8,代码来源:PerforceConnection.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:53,代码来源:

示例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() );
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:14,代码来源:luamessage.cpp

示例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;
}
开发者ID:robterrell,项目名称:VersionControlPlugins,代码行数:24,代码来源:P4Command.cpp

示例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 );
}
开发者ID:Malaar,项目名称:luaplus51-all,代码行数:15,代码来源:clientuserlua.cpp

示例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
}
开发者ID:aovi,项目名称:UnrealEngine4,代码行数:16,代码来源:PerforceConnection.cpp


注:本文中的StrBuf::Text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。