本文整理汇总了C++中DateTime::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::Get方法的具体用法?C++ DateTime::Get怎么用?C++ DateTime::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::Get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fnLog
// ===============
void Log::Initialise
// ===============
(
EngineSetting* pSetting // pointer to Setting object
)
{
// Set the log name to the name of the cluster; place the '@' character
// after it.
m_strLogName = pSetting->Get( "CLUSTER", "FileName" ) + "@";
// Make a string out of the current date and time (separated by an
// underscore), and add this to the back of the file name.
DateTime dt;
m_strLogName += dt.Get( "YYYYMMDD_hhmmss" );
// Replace all characters that are not allowed in a file name by underscores.
string::size_type nChar;
while ( (nChar = m_strLogName.find_first_of( NOT_ALLOWED_IN_FILE )) != string::npos )
{
m_strLogName.replace( nChar, 1, "_" );
}
// Create a FileName object of the log name; set its extension;
// set its location as specified in the settings.
FileName fnLog( m_strLogName );
fnLog.ChangeExtension( LOG_EXTENSION );
fnLog.ChangeLocation( pSetting->Get( "LOG", "Path" ) );
// Determine if the file name is unique.
int nCounter = 0;
bool bUnique = false;
while ( !bUnique )
{
// If the name was already once found to be not unique, add
// another '#' character to the back of the name.
if ( nCounter > 0 )
{
fnLog.ChangeName( fnLog.GetName() + "#" );
}
// Get the new log file.
m_strLogName = fnLog.GetFile();
// Determine if a file with this name/location already exists.
if( FileExists( m_strLogName ) )
{
// File name already exists; update counter.
nCounter++;
}
else
{
bUnique = true;
}
}
// Open the output medium for writing, and check if this succeeds.
if ( Open( m_strLogName, WRITE ) )
{
m_bGood = true;
}
}