本文整理汇总了C++中AStackString类的典型用法代码示例。如果您正苦于以下问题:C++ AStackString类的具体用法?C++ AStackString怎么用?C++ AStackString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AStackString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmitCompilationMessage
// EmitCompilationMessage
//------------------------------------------------------------------------------
void TestNode::EmitCompilationMessage( const char * workingDir ) const
{
AStackString<> output;
output += "Running Test: ";
output += GetName();
output += '\n';
if ( FLog::ShowInfo() || FBuild::Get().GetOptions().m_ShowCommandLines )
{
output += GetTestExecutable()->GetName();
output += ' ';
output += m_TestArguments;
output += '\n';
if ( workingDir )
{
output += "Working Dir: ";
output += workingDir;
output += '\n';
}
}
FLOG_BUILD_DIRECT( output.Get() );
}
示例2: FileExists
REGISTER_TESTS_END
// FileExists
//------------------------------------------------------------------------------
void TestFileIO::FileExists() const
{
// generate a process unique file path
AStackString<> path;
GenerateTempFileName( path );
// ensure doesn't exist
FileIO::FileDelete( path.Get() ); // delete in case left over from previous test run
TEST_ASSERT( FileIO::FileExists( path.Get() ) == false );
// create it
FileStream f;
TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
f.Close();
// ensure exists
TEST_ASSERT( FileIO::FileExists( path.Get() ) == true );
// clean up
TEST_ASSERT( FileIO::FileDelete( path.Get() ) == true );
TEST_ASSERT( FileIO::FileExists( path.Get() ) == false );
}
示例3: OutputDebugStringA
// TracingOutputCallback
//------------------------------------------------------------------------------
/*static*/ bool FLog::TracingOutputCallback( const char * message )
{
uint32_t threadIndex = WorkerThread::GetThreadIndex();
AStackString< 2048 > tmp;
if ( s_ShowProgress )
{
// clear previous progress message
tmp += g_ClearLineString;
}
// print output and then progress
if ( threadIndex > 0 )
{
char buffer[ 8 ];
_itoa_s( threadIndex, buffer, 8, 10 );
tmp += buffer;
tmp += '>';
if ( threadIndex < 10 )
{
tmp += ' '; // keep output aligned when there are > 9 threads
}
}
tmp += message;
// output to debugger if present
#ifdef DEBUG
#ifdef __WINDOWS__
OutputDebugStringA( message );
#endif
#endif
tmp += m_ProgressText;
fwrite( tmp.Get(), 1, tmp.GetLength(), stdout );
return false; // tell tracing not to output it again
}
示例4: ReadOnly
// ReadOnly
//------------------------------------------------------------------------------
void TestFileIO::ReadOnly() const
{
// generate a process unique file path
AStackString<> path;
GenerateTempFileName( path );
// create it
FileStream f;
TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
f.Close();
// should not be read only
TEST_ASSERT( FileIO::GetReadOnly( path ) == false );
// set readonly
TEST_ASSERT( FileIO::SetReadOnly( path.Get(), true ) == true );
// should be read only
TEST_ASSERT( FileIO::GetReadOnly( path ) == true );
// delete should fail
TEST_ASSERT( FileIO::FileDelete( path.Get() ) == false );
// clean up
TEST_ASSERT( FileIO::SetReadOnly( path.Get(), false ) == true );
TEST_ASSERT( FileIO::GetReadOnly( path ) == false );
TEST_ASSERT( FileIO::FileDelete( path.Get() ) == true );
}
示例5: FileTime
// FileTime
//------------------------------------------------------------------------------
void TestFileIO::FileTime() const
{
// generate a process unique file path
AStackString<> path;
GenerateTempFileName( path );
// create it
FileStream f;
TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
f.Close();
// get last write time
const uint64_t oldTime = FileIO::GetFileLastWriteTime( path );
TEST_ASSERT( oldTime != 0 );
// wait for some time that is bigger than filesystem time granularity
#if defined( __OSX__ )
// HFS+ has surprisingly poor time resolution (1 second)
Thread::Sleep( 1100 );
#else
Thread::Sleep( 500 );
#endif
// modify file
FileStream f2;
TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
f.Write( (uint32_t)0 );
f.Close();
// get new last write time
const uint64_t newTime = FileIO::GetFileLastWriteTime( path );
TEST_ASSERT( newTime > oldTime );
// manually set time back
TEST_ASSERT( FileIO::SetFileLastWriteTime( path, oldTime ) == true );
uint64_t timeNow = FileIO::GetFileLastWriteTime( path );
TEST_ASSERT( timeNow == oldTime );
}
示例6: Error
// ReadWeakRef
//------------------------------------------------------------------------------
bool TextReader::ReadWeakRef()
{
// Name
AStackString<> name;
if ( !GetToken( name ) )
{
Error( "Missing weakref name" );
return false;
}
AStackString<> value;
if ( !GetString( value ) )
{
Error( "Missing weakref value" );
return false;
}
const StackFrame & sf = m_DeserializationStack.Top();
// null weak refs can be taken care of right now
if ( value == "null" )
{
WeakRef< Object > nullWR;
sf.m_Reflection->SetProperty( sf.m_Base, name.Get(), nullWR );
return true;
}
// non-null WeakRefs must be deferred
// (since we might not have created the child object yet)
UnresolvedWeakRef u;
u.m_Base = sf.m_Base;
u.m_Reflection = sf.m_Reflection;
u.m_WeakRefName = name;
u.m_WeakRefValue = value;
m_UnresolvedWeakRefs.Append( u );
return true;
}
示例7: string
// AStackStringOverflow
//------------------------------------------------------------------------------
void TestAString::AStackStringOverflow() const
{
{
// constructor with string longer than buffer
AStackString< 8 > string( "01234567890123456789" );
TEST_ASSERT( string.GetLength() == 20 );
TEST_ASSERT( string.GetLength() == AString::StrLen( string.Get() ) );
}
{
// assigned of string longer than buffer
AStackString< 8 > string;
string = "01234567890123456789";
TEST_ASSERT( string.GetLength() == 20 );
TEST_ASSERT( string.GetLength() == AString::StrLen( string.Get() ) );
}
{
// concetentation of string longer than buffer
AStackString< 8 > string;
string += "01234567890123456789";
TEST_ASSERT( string.GetLength() == 20 );
TEST_ASSERT( string.GetLength() == AString::StrLen( string.Get() ) );
}
}
示例8: GetName
// 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() );
}
示例9: GetCacheFileName
// Retrieve
//------------------------------------------------------------------------------
/*virtual*/ bool Cache::Retrieve( const AString & cacheId, void * & data, size_t & dataSize )
{
data = nullptr;
dataSize = 0;
AStackString<> cacheFileName;
GetCacheFileName( cacheId, cacheFileName );
FileStream cacheFile;
if ( cacheFile.Open( cacheFileName.Get(), FileStream::READ_ONLY ) )
{
const size_t cacheFileSize = (size_t)cacheFile.GetFileSize();
AutoPtr< char > mem( (char *)ALLOC( cacheFileSize ) );
if ( cacheFile.Read( mem.Get(), cacheFileSize ) == cacheFileSize )
{
dataSize = cacheFileSize;
data = mem.Release();
return true;
}
}
return false;
}
示例10: envString
// ProcessEnvironment
//------------------------------------------------------------------------------
void FunctionSettings::ProcessEnvironment( const Array< AString > & envStrings ) const
{
// the environment string is used in windows as a double-null terminated string
// so convert our array to a single buffer
// work out space required
uint32_t size = 0;
for ( uint32_t i=0; i<envStrings.GetSize(); ++i )
{
size += envStrings[ i ].GetLength() + 1; // string len inc null
}
// allocate space
AutoPtr< char > envString( (char *)ALLOC( size + 1 ) ); // +1 for extra double-null
// while iterating, extract the LIB environment variable (if there is one)
AStackString<> libEnvVar;
// copy strings end to end
char * dst = envString.Get();
for ( uint32_t i=0; i<envStrings.GetSize(); ++i )
{
if ( envStrings[ i ].BeginsWith( "LIB=" ) )
{
libEnvVar.Assign( envStrings[ i ].Get() + 4, envStrings[ i ].GetEnd() );
}
const uint32_t thisStringLen = envStrings[ i ].GetLength();
AString::Copy( envStrings[ i ].Get(), dst, thisStringLen );
dst += ( thisStringLen + 1 );
}
// final double-null
*dst = '\000';
FBuild::Get().SetEnvironmentString( envString.Get(), size, libEnvVar );
}
示例11: Save
// Save
//------------------------------------------------------------------------------
void WorkerSettings::Save()
{
AStackString<> settingsPath;
Env::GetExePath( settingsPath );
settingsPath += ".settings";
FileStream f;
if ( f.Open( settingsPath.Get(), FileStream::WRITE_ONLY ) )
{
bool ok = true;
// header
ok &= ( f.Write( "FWS", 3 ) == 3 );
ok &= ( f.Write( uint8_t( FBUILDWORKER_SETTINGS_CURRENT_VERSION ) ) == 1 );
// settings
ok &= f.Write( (uint32_t)m_Mode );
ok &= f.Write( m_NumCPUsToUse );
ok &= f.Write( m_StartMinimized );
if ( ok )
{
return;
}
}
#if defined( __WINDOWS__ )
MessageBox( nullptr, "Failed to save settings.", "FBuildWorker", MB_OK );
#elif defined( __APPLE__ )
// TODO:MAC Implement ShowMessageBox
#elif defined( __LINUX__ )
// TODO:LINUX Implement ShowMessageBox
#else
#error Unknown Platform
#endif
}
示例12: Write
// WriteNestedProjects
//------------------------------------------------------------------------------
void SLNGenerator::WriteNestedProjects( const Array< AString > & solutionProjectsToFolder,
const Array< AString > & solutionFolderPaths )
{
if ( solutionProjectsToFolder.GetSize() == 0 &&
solutionFolderPaths.GetSize() == 0 )
{
return; // skip global section
}
Write( "\tGlobalSection(NestedProjects) = preSolution\r\n" );
// Write every project to solution folder relationships
const AString * const solutionProjectsToFolderEnd = solutionProjectsToFolder.End();
for( const AString * it = solutionProjectsToFolder.Begin() ; it != solutionProjectsToFolderEnd ; ++it )
{
Write( it->Get() );
}
// Write every intermediate path
const AString * const solutionFolderPathsEnd = solutionFolderPaths.End();
for( const AString * it = solutionFolderPaths.Begin() ; it != solutionFolderPathsEnd ; ++it )
{
// parse solution folder parent path
AStackString<> solutionFolderParentGuid;
const char * lastSlash = it->FindLast( NATIVE_SLASH );
if ( lastSlash )
{
AStackString<> solutionFolderParentPath( it->Get(), lastSlash );
VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderParentGuid, solutionFolderParentPath );
}
if ( solutionFolderParentGuid.GetLength() > 0 )
{
// generate a guid for the solution folder
AStackString<> solutionFolderGuid;
VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderGuid, *it );
solutionFolderGuid.ToUpper();
solutionFolderParentGuid.ToUpper();
// write parent solution folder relationship
Write( "\t\t%s = %s\r\n", solutionFolderGuid.Get(), solutionFolderParentGuid.Get() );
}
}
Write( "\tEndGlobalSection\r\n" );
}
示例13: DoTableStop
// 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
}
示例14: longStringLen
// 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 );
}
示例15: PROFILE_SECTION
// 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() );
}