本文整理汇总了C++中AStackString::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ AStackString::Get方法的具体用法?C++ AStackString::Get怎么用?C++ AStackString::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStackString
的用法示例。
在下文中一共展示了AStackString::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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;
}
示例3: 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 );
}
示例4: FileMove
// FileMove
//------------------------------------------------------------------------------
void TestFileIO::FileMove() const
{
// generate a process unique file path
AStackString<> path;
GenerateTempFileName( path );
// generate copy file name
AStackString<> pathCopy( path );
pathCopy += ".copy";
// make sure nothing is left from previous runs
FileIO::FileDelete( path.Get() );
FileIO::FileDelete( pathCopy.Get() );
// create it
FileStream f;
TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
f.Close();
// move it
TEST_ASSERT( FileIO::FileMove( path, pathCopy ) );
TEST_ASSERT( FileIO::FileExists( path.Get() ) == false );
TEST_ASSERT( FileIO::FileExists( pathCopy.Get() ) == true );
// cleanup
VERIFY( FileIO::FileDelete( pathCopy.Get() ) );
}
示例5: StoreVariableString
// StoreVariableString
//------------------------------------------------------------------------------
bool BFFParser::StoreVariableString( const AString & name,
const BFFIterator & valueStart, const BFFIterator & valueEnd,
const BFFIterator & operatorIter,
BFFStackFrame * frame )
{
// unescape and subsitute embedded variables
AStackString< 2048 > value;
if ( PerformVariableSubstitutions( valueStart, valueEnd, value ) == false )
{
return false;
}
// are we concatenating?
const BFFVariable * varToConcat = nullptr;
if ( *operatorIter == BFF_VARIABLE_CONCATENATION )
{
// find existing
varToConcat = BFFStackFrame::GetVar( name, frame );
if ( varToConcat == nullptr )
{
Error::Error_1026_VariableNotFoundForConcatenation( operatorIter, name );
return false;
}
// make sure types are compatible
if ( varToConcat->IsString() )
{
// OK - can concat String to String
AStackString< 1024 > finalValue( varToConcat->GetString() );
finalValue += value;
BFFStackFrame::SetVarString( name, finalValue, frame );
FLOG_INFO( "Appended '%s' to <String> variable '%s' with result '%s'", value.Get(), name.Get(), finalValue.Get() );
return true;
}
else if ( varToConcat->IsArrayOfStrings() )
{
// OK - can concat String to ArrayOfStrings
Array< AString > finalValues( varToConcat->GetArrayOfStrings().GetSize() + 1, false );
finalValues = varToConcat->GetArrayOfStrings();
finalValues.Append( value );
BFFStackFrame::SetVarArrayOfStrings( name, finalValues, frame );
FLOG_INFO( "Appended '%s' to <ArrayOfStrings> variable '%s' with result of %i items", value.Get(), name.Get(), finalValues.GetSize() );
return true;
}
else
{
Error::Error_1027_CannotConcatenate( operatorIter, name, varToConcat->GetType(), BFFVariable::VAR_STRING );
return false;
}
}
// handle regular assignment of string
BFFStackFrame::SetVarString( name, value, frame );
FLOG_INFO( "Registered <string> variable '%s' with value '%s'", name.Get(), value.Get() );
return true;
}
示例6: GetOtherLibrary
// GetOtherLibrary
//------------------------------------------------------------------------------
bool LinkerNode::GetOtherLibrary( NodeGraph & nodeGraph,
const BFFIterator & iter,
const Function * function,
Dependencies & libs,
const AString & path,
const AString & lib,
bool & found ) const
{
found = false;
AStackString<> potentialNodeName( path );
if ( !potentialNodeName.IsEmpty() )
{
PathUtils::EnsureTrailingSlash( potentialNodeName );
}
potentialNodeName += lib;
AStackString<> potentialNodeNameClean;
NodeGraph::CleanPath( potentialNodeName, potentialNodeNameClean );
// see if a node already exists
Node * node = nodeGraph.FindNode( potentialNodeNameClean );
if ( node )
{
// aliases not supported - must point to something that provides a file
if ( node->IsAFile() == false )
{
Error::Error_1103_NotAFile( iter, function, ".LinkerOptions", potentialNodeNameClean, node->GetType() );
return false;
}
// found existing node
libs.Append( Dependency( node ) );
found = true;
return true; // no error
}
// see if the file exists on disk at this location
if ( FileIO::FileExists( potentialNodeNameClean.Get() ) )
{
node = nodeGraph.CreateFileNode( potentialNodeNameClean );
libs.Append( Dependency( node ) );
found = true;
FLOG_INFO( "Additional library '%s' assumed to be '%s'\n", lib.Get(), potentialNodeNameClean.Get() );
return true; // no error
}
return true; // no error
}
示例7: 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
}
示例8: Generate
// Generate
//------------------------------------------------------------------------------
void Report::Generate( const FBuildStats & stats )
{
Timer t;
// pre-allocate a large string for output
m_Output.SetReserved( MEGABYTE );
m_Output.SetLength( 0 );
// generate some common data used in reporting
GetLibraryStats( stats );
// build the report
CreateHeader();
CreateTitle();
CreateOverview( stats );
DoCPUTimeByType( stats );
DoCacheStats( stats );
DoCPUTimeByLibrary();
DoCPUTimeByItem( stats );
DoIncludes();
CreateFooter();
// patch in time take
const float time = t.GetElapsed();
AStackString<> timeTakenBuffer;
stats.FormatTime( time, timeTakenBuffer );
char * placeholder = m_Output.Find( "^^^^ " );
memcpy( placeholder, timeTakenBuffer.Get(), timeTakenBuffer.GetLength() );
}
示例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 );
}
示例10: 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;
}
示例11: lock
// StartBuild
//------------------------------------------------------------------------------
/*static*/ void FLog::StartBuild()
{
if ( FBuild::Get().GetOptions().m_EnableMonitor )
{
// TODO:B Change the monitoring log path
// - it's not uniquified per instance
// - we already have a .fbuild.tmp folder we should use
AStackString<> fullPath;
FileIO::GetTempDir( fullPath );
fullPath += "FastBuild/FastBuildLog.log";
ASSERT( g_MonitorFileStream == nullptr );
MutexHolder lock( g_MonitorMutex );
g_MonitorFileStream = new FileStream();
if ( g_MonitorFileStream->Open( fullPath.Get(), FileStream::WRITE_ONLY ) == false )
{
delete g_MonitorFileStream;
g_MonitorFileStream = nullptr;
}
Monitor( "START_BUILD %u %u\n", FBUILD_MONITOR_VERSION, Process::GetCurrentId() );
}
Tracing::AddCallbackOutput( &TracingOutputCallback );
}
示例12: Load
// Load
//------------------------------------------------------------------------------
void WorkerSettings::Load()
{
AStackString<> settingsPath;
Env::GetExePath( settingsPath );
settingsPath += ".settings";
FileStream f;
if ( f.Open( settingsPath.Get(), FileStream::READ_ONLY ) )
{
char header[ 4 ] = { 0 };
f.Read( &header, 4 );
if ( ( header[ 3 ] < FBUILDWORKER_SETTINGS_MIN_VERSION ) ||
( header[ 3 ] > FBUILDWORKER_SETTINGS_CURRENT_VERSION ) )
{
return; // version is too old, or newer, and cannot be read
}
// settings
uint32_t mode;
f.Read( mode );
m_Mode = (Mode)mode;
f.Read( m_NumCPUsToUse );
f.Read( m_StartMinimized );
}
}
示例13: defined
// GetNumProcessors
//------------------------------------------------------------------------------
/*static*/ uint32_t Env::GetNumProcessors()
{
#if defined( __WINDOWS__ )
// Default to NUMBER_OF_PROCESSORS
uint32_t numProcessors = 1;
AStackString< 32 > var;
if ( GetEnvVariable( "NUMBER_OF_PROCESSORS", var ) )
{
if ( sscanf_s( var.Get(), "%u", &numProcessors ) != 1 )
{
numProcessors = 1;
}
}
return numProcessors;
#elif defined( __LINUX__ ) || defined( __APPLE__ )
long numCPUs = sysconf( _SC_NPROCESSORS_ONLN );
if ( numCPUs <= 0 )
{
ASSERT( false ); // this should never fail
numCPUs = 1;
}
return ( uint32_t )numCPUs;
#else
#error Unknown platform
#endif
}
示例14: 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
}
示例15: WriteNestedProjects
// 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" );
}