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


C++ AStackString::Format方法代码示例

本文整理汇总了C++中AStackString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ AStackString::Format方法的具体用法?C++ AStackString::Format怎么用?C++ AStackString::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AStackString的用法示例。


在下文中一共展示了AStackString::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetRemotePath

// GetRemotePath
//------------------------------------------------------------------------------
void ToolManifest::GetRemotePath( AString & path ) const
{
	VERIFY( FileIO::GetTempDir( path ) );
	AStackString<> subDir;
    #if defined( __WINDOWS__ )
        subDir.Format( ".fbuild.tmp\\worker\\toolchain.%016llx\\", m_ToolId );
    #else
        subDir.Format( "_fbuild.tmp/worker/toolchain.%016llx/", m_ToolId );
    #endif
	path += subDir;
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:13,代码来源:ToolManifest.cpp

示例2: TryLock

// Lock
//------------------------------------------------------------------------------
bool SystemMutex::TryLock()
{ 
    #if defined( __WINDOWS__ )
		void * handle = (void *)CreateMutex( nullptr, TRUE, m_Name.Get() );
		if ( GetLastError() == ERROR_ALREADY_EXISTS )
		{
			if ( ( handle != INVALID_HANDLE_VALUE ) && ( handle != 0 ) )
			{
				CloseHandle( handle );
			}
			return false;
		}
		m_Handle = handle;
		return true;
    #elif defined( __LINUX__ ) || defined( __APPLE__ )
        AStackString<> tempFileName;
        tempFileName.Format( "/var/run/%s.lock", m_Name.Get() );
        m_Handle = open( tempFileName.Get(), O_CREAT | O_RDWR, 0666 );
        int rc = flock( m_Handle, LOCK_EX | LOCK_NB );
        if ( rc )
        {
            if ( errno == EWOULDBLOCK )
            {
                return false; // locked by another process
            }
        }
        return true; // we own it now
    #else
        #error Unknown platform
    #endif
}
开发者ID:grimtraveller,项目名称:fastbuild,代码行数:33,代码来源:SystemMutex.cpp

示例3: DoToggleSection

// DoToggleSection
//------------------------------------------------------------------------------
void Report::DoToggleSection( size_t numMore )
{
	static int tableId = 0;
	++tableId;
	AStackString<> tableIdStr;
	tableIdStr.Format( "table%u", tableId );

	DoTableStop();
	AStackString<> more;
	if ( numMore )
	{
		more.Format( "%u ", (uint32_t)numMore );
	}
	Write( "<a href='javascript:toggleTable(\"%s\");'>%sMore...</a>\n", tableIdStr.Get(), more.Get() );
	DoTableStart( DEFAULT_TABLE_WIDTH, tableIdStr.Get(), true ); // hide table
}
开发者ID:hilbertdu,项目名称:fastbuild,代码行数:18,代码来源:Report.cpp

示例4: LaunchSubProcess

	int LaunchSubProcess( const AString & args )
	{
		// try to make a copy of our exe
		AStackString<> exeName;
		Env::GetExePath( exeName );
		AStackString<> exeNameCopy( exeName );
		exeNameCopy += ".copy";
		Timer t;
		while ( FileIO::FileCopy( exeName.Get(), exeNameCopy.Get() ) == false )
		{
			if ( t.GetElapsed() > 5.0f )
			{
				AStackString<> msg;
				msg.Format( "Failed to make sub-process copy - error: %u (0x%x)\n\nSrc: %s\nDst: %s\n", Env::GetLastErr(), Env::GetLastErr(), exeName.Get(), exeNameCopy.Get() );
				ShowMsgBox( msg.Get() );
				return -2;
			}
			Thread::Sleep( 100 );
		}
	
		AStackString<> argsCopy( args );
		argsCopy += " -subprocess";
	
		// allow subprocess to access the mutex
		g_OneProcessMutex.Unlock();
	
		Process p;
	    #if defined( __WINDOWS__ )
	        p.DisableHandleRedirection(); // TODO:MAC TODO:LINUX is this needed?
	    #endif
		p.Spawn( exeNameCopy.Get(), argsCopy.Get(), nullptr, nullptr );
		p.Detach();
	
		return 0;
	}
开发者ID:ClxS,项目名称:fastbuild,代码行数:35,代码来源:Main.cpp

示例5: ms

// Load
//------------------------------------------------------------------------------
/*static*/ Object * ReflectionInfo::Load( const char * scopedName )
{
	AStackString<> fullPath;
	fullPath.Format( "Reflection\\%s.obj", scopedName );

	FileStream fs;
	if ( fs.Open( fullPath.Get(), FileStream::READ_ONLY ) == false )
	{
		return nullptr;
	}

	const size_t fileSize = (size_t)fs.GetFileSize();
	AutoPtr< char > mem( (char *)Alloc( fileSize + 1 ) );
	if ( fs.Read( mem.Get(), fileSize ) != fileSize )
	{
		return nullptr;
	}
	mem.Get()[ fileSize ] = 0;

	ConstMemoryStream ms( mem.Get(), fileSize + 1 );
	TextReader tr( ms );
	RefObject * refObject = tr.Read();
	ASSERT( !refObject || DynamicCast< Object >( refObject ) );

	return (Object *)refObject;
}
开发者ID:ClxS,项目名称:fastbuild,代码行数:28,代码来源:ReflectionInfo.cpp

示例6: DoPieChart

PRAGMA_DISABLE_POP_MSVC // warning C6262: Function uses '262212' bytes of stack

// DoPieChart
//------------------------------------------------------------------------------
void Report::DoPieChart( const Array< PieItem > & items, const char * units )
{
	AStackString<> buffer;

	uint32_t height = Math::Max< uint32_t >( 140, 40 + 25 * (uint32_t)items.GetSize() );

	m_NumPieCharts++;

	Write( "<section>\n" );
	Write( "<div>\n" );
	Write( "<canvas id=\"canvas%u\" width=\"500\" height=\"%u\">\n", m_NumPieCharts, height );
	Write( "HTML5 Canvas support required.\n" );
	Write( "</canvas>\n" );
	Write( "</div>\n" );

	Write( "<script type=\"text/javascript\">\n" );
	Write( "	var myData = [" );
	for ( size_t i=0; i<items.GetSize(); ++i )
	{
		if ( i > 0 )
		{
			Write( "," );
		}
		buffer.Format( "%2.3f", items[ i ].value );
		Write( buffer.Get() );
	}
	Write( "];\n" );
	Write( "	var myLabels = [" );
	for ( size_t i=0; i<items.GetSize(); ++i )
	{
		if ( i > 0 )
		{
			Write( "," );
		}
		Write( "\"%s\"", items[ i ].label );
	}
	Write( "];\n" );
	Write( "	var myColors = [" );
	for ( size_t i=0; i<items.GetSize(); ++i )
	{
		if ( i > 0 )
		{
			Write( "," );
		}
		Write( "\"#%x\"", items[ i ].color );
	}
	Write( "];\n" );

	Write( "	plotData(\"canvas%u\",myData,myLabels,myColors,\"%s\");\n", m_NumPieCharts, units );
	Write( "</script>\n" );
	Write( "</section>\n" );
}
开发者ID:hilbertdu,项目名称:fastbuild,代码行数:56,代码来源:Report.cpp

示例7: GenerateTempFileName

// GenerateTempFileName
//------------------------------------------------------------------------------
void TestFileIO::GenerateTempFileName( AString & tmpFileName ) const
{
	// get system temp folder
	VERIFY( FileIO::GetTempDir( tmpFileName ) );

	// add process unique identifier
	AStackString<> buffer;
	buffer.Format( "TestFileIO.%u.%u", Process::GetCurrentId(), m_Random.GetRand() );
	tmpFileName += buffer;
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:12,代码来源:TestFileIO.cpp

示例8: UpdateUI

// UpdateUI
//------------------------------------------------------------------------------
void Worker::UpdateUI()
{
	// throttle UI updates
	if ( m_UIUpdateTimer.GetElapsed() < 0.25f )
	{
		return;
	}

	// title bar
	size_t numConnections = m_ConnectionPool->GetNumConnections();
	AStackString<> status;
	status.Format( "%u Connections", (uint32_t)numConnections );
	if ( m_RestartNeeded )
	{
		status += " (Restart Pending)";
	}
	#if defined( __WINDOWS__ )
		if ( m_LastDiskSpaceResult == 0 )
		{
			status += " (Low Disk Space)";
		}
	#endif
	m_MainWindow->SetStatus( status.Get() );

	// thread output
	JobQueueRemote & jqr = JobQueueRemote::Get();
	const size_t numWorkers = jqr.GetNumWorkers();
	for ( size_t i=0; i<numWorkers; ++i )
	{
		// get status of worker
		AStackString<> workerStatus;
		AStackString<> hostName;
		bool isIdle;
		jqr.GetWorkerStatus( i, hostName, workerStatus, isIdle );

		// are we syncing tools?
		if ( isIdle )
		{
			AStackString<> statusStr;
			if ( m_ConnectionPool->IsSynchingTool( statusStr ) )
			{
				// show status of synchronization
				workerStatus = statusStr;
			}
		}

		// reflect in UI
		m_MainWindow->SetWorkerState( i, hostName, workerStatus );
	}

	m_UIUpdateTimer.Start();
}
开发者ID:jujis008,项目名称:fastbuild,代码行数:54,代码来源:Worker.cpp

示例9: Format

// Format
//------------------------------------------------------------------------------
void TestAString::Format() const
{
    // Create a really long input string
    AStackString<> longInput;
    const size_t longStringLen( 1024 * 1024 );
    for ( size_t i=0; i<longStringLen; ++i )
    {
        longInput += 'A';
    }

    // Make sure we correctly handle formatting large strings
    AStackString<> buffer;
    buffer.Format( "%s", longInput.Get() );
    TEST_ASSERT( buffer.GetLength() == longStringLen );
    TEST_ASSERT( AString::StrLen( buffer.Get() ) == longStringLen );
}
开发者ID:dummyunit,项目名称:fastbuild,代码行数:18,代码来源:TestAString.cpp

示例10: DoTableStart

// DoTableStart
//------------------------------------------------------------------------------
void Report::DoTableStart( int width, const char * id, bool hidden )
{
	AStackString<> output;
	output.Format( "<table width=%u", width );
	if ( id )
	{
		output += " id=\"";
		output += id;
		output += "\"";
	}
	if ( hidden )
	{
		output += " style=\"display:none;\"";
	}
	output += ">\n";
	Write( output.Get() );
}
开发者ID:hilbertdu,项目名称:fastbuild,代码行数:19,代码来源:Report.cpp

示例11: defined

// InitTmpDir
//------------------------------------------------------------------------------
/*static*/ void WorkerThread::InitTmpDir( bool remote )
{
	VERIFY( FileIO::GetTempDir( s_TmpRoot ) );
    #if defined( __WINDOWS__ )
        s_TmpRoot += ".fbuild.tmp\\";
    #else
        s_TmpRoot += "_fbuild.tmp/";
    #endif

    // use the working dir hash to uniquify the path
    AStackString<> buffer;
    const uint32_t workingDirHash = remote ? 0 : FBuild::Get().GetOptions().GetWorkingDirHash();
    buffer.Format( "0x%08x", workingDirHash );
    s_TmpRoot += buffer;
    s_TmpRoot += NATIVE_SLASH;

	VERIFY( FileIO::EnsurePathExists( s_TmpRoot ) );
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:20,代码来源:WorkerThread.cpp

示例12:

// FixupAllowedFileExtensions
//------------------------------------------------------------------------------
/*static*/ void ProjectGeneratorBase::FixupAllowedFileExtensions( Array< AString > & extensions )
{
    // For backwards compatibility, we support explicit extensions ".ext" and wildcards "*.ext"
    // To normalize run-time behaviour, we convert everything to wildcard format

    // convert any that are not wildcards patterns
    for ( auto & ext : extensions )
    {
        if ( ext.Find('*') || ext.Find('?') )
        {
            continue; // already a pattern, leave as is
        }

        // convert ".ext" to "*.ext"
        AStackString<> tmp;
        tmp.Format("*%s", ext.Get());
        ext = tmp;
    }
}
开发者ID:liamkf,项目名称:fastbuild,代码行数:21,代码来源:ProjectGeneratorBase.cpp

示例13: lock

// Monitor
//------------------------------------------------------------------------------
/*static*/ void FLog::Monitor( const char * formatString, ... )
{
    // Is monitoring enabled?
    if ( g_MonitorFileStream == nullptr )
    {
        return; // No - nothing to do
    }

    PROFILE_SECTION( "FLog::Monitor" )

    AStackString< 1024 > buffer;
    va_list args;
    va_start( args, formatString );
    buffer.VFormat( formatString, args );
    va_end( args );

    AStackString< 1024 > finalBuffer;
    finalBuffer.Format( "%llu %s", Time::GetCurrentFileTime(), buffer.Get() );

    MutexHolder lock( g_MonitorMutex );
    g_MonitorFileStream->WriteBuffer( finalBuffer.Get(), finalBuffer.GetLength() );
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:24,代码来源:FLog.cpp

示例14: EmitCompilationMessage

// EmitCompilationMessage
//------------------------------------------------------------------------------
void ExecNode::EmitCompilationMessage( const AString & args ) const
{
    // basic info
    AStackString< 2048 > output;
    output += "Run: ";
    output += GetName();
    output += '\n';

    // verbose mode
    if ( FLog::ShowInfo() || FBuild::Get().GetOptions().m_ShowCommandLines )
    {
        AStackString< 1024 > verboseOutput;
        verboseOutput.Format( "%s %s\nWorkingDir: %s\nExpectedReturnCode: %i\n",
                              m_Executable->GetName().Get(),
                              args.Get(),
                              m_WorkingDir.Get(),
                              m_ExpectedReturnCode );
        output += verboseOutput;
    }

    // output all at once for contiguousness
    FLOG_BUILD_DIRECT( output.Get() );
}
开发者ID:punitchandra,项目名称:fastbuild,代码行数:25,代码来源:ExecNode.cpp

示例15: tw

	/*static*/ bool ReflectionInfo::WriteDefinitions()
	{
		uint32_t numProblems = 0;

		const ReflectionInfo * ri = s_FirstReflectionInfo;
		for ( ; ri != nullptr; ri = ri->m_Next )
		{
			// ignore abstract classes
			if ( ri->IsAbstract() )
			{
				continue;
			}

			// Serialize a default instance to a MemoryStream 
			MemoryStream ms;
			{
				// Create and serialize default instance
				if ( ri->IsObject() )
				{
					RefObject * object = ri->CreateObject();
					{
						TextWriter tw( ms );
						tw.Write( object );
					}
					FDELETE( object );
				}
				else
				{
					ASSERT( ri->IsStruct() )
					Struct * str = ri->CreateStruct();
					{
						TextWriter tw( ms );
						tw.Write( str, ri );
					}
					FDELETE( str );
				}
			}

			AStackString<> fileName; 
			fileName.Format( "..\\Data\\Reflection\\.Definitions\\%s.definition", ri->GetTypeName() );

			// avoid writing file if not changed

			// Try to open existing file
			FileStream f;
			if ( f.Open( fileName.Get(), FileStream::READ_ONLY ) )
			{
				// read content
				const uint64_t fileSize = f.GetFileSize();
				if ( fileSize == ms.GetSize() )
				{
					AutoPtr< char > mem( (char *)Alloc( (size_t)fileSize ) );
					if ( f.Read( mem.Get(), (size_t)fileSize ) == fileSize )
					{
						if ( memcmp( mem.Get(), ms.GetData(), (size_t)fileSize ) == 0 )
						{
							continue; // definition has not changed
						}
					}
				}
				f.Close();
			}

			// Definition changed - try to save it

			int result = 0;
			AutoPtr< char > memOut;
			AutoPtr< char > memErr;
			uint32_t memOutSize;
			uint32_t memErrSize;

			// existing definition?
			if ( FileIO::FileExists( fileName.Get() ) )
			{
				// existing - need to open for edit?
				if ( FileIO::GetReadOnly( fileName ) )
				{
					AStackString<> args( "edit " );
					args += fileName;
					Process p;
					if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
					{
						p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
						result = p.WaitForExit();
					}
				}
			}
			else
			{
				// new - open for add
				AStackString<> args( "add " );
				args += fileName;
				Process p;
				if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
				{
					p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
					result = p.WaitForExit();
				}
			}

//.........这里部分代码省略.........
开发者ID:ClxS,项目名称:fastbuild,代码行数:101,代码来源:ReflectionInfo.cpp


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