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


C++ DateTime::Get方法代码示例

本文整理汇总了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;
	}
}
开发者ID:MathoeraTestingConsultancy,项目名称:TFSources,代码行数:62,代码来源:Log.cpp


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