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


C++ t_Str::size方法代码示例

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


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

示例1: SetValue

// SetValue
// Given a key, a value and a section, this function will attempt to locate the
// Key within the given section, and if it finds it, change the keys value to
// the new value. If it does not locate the key, it will create a new key with
// the proper value and place it in the section requested.
bool CDataFile::SetValue(t_Str szKey, t_Str szValue, t_Str szComment, t_Str szSection)
{
	t_Key* pKey = GetKey(szKey, szSection);
	t_Section* pSection = GetSection(szSection);

	if (pSection == NULL)
	{
		if ( !(m_Flags & AUTOCREATE_SECTIONS) || !CreateSection(szSection,""))
			return false;

		pSection = GetSection(szSection);
	}

	// Sanity check...
	if ( pSection == NULL )
		return false;

	// if the key does not exist in that section, and the value passed 
	// is not t_Str("") then add the new key.
	if ( pKey == NULL && szValue.size() > 0 && (m_Flags & AUTOCREATE_KEYS))
	{
		t_Key Key;

		Key.szKey = szKey;
		Key.szValue = szValue;
		Key.szComment = szComment;
		
		m_bDirty = true;
		
		pSection->Keys.PushBack(Key);
		pKey = GetKey(szKey, szSection);

		return true;
	}

	if ( pKey != NULL )
	{
		pKey->szValue = szValue;
		pKey->szComment = szComment;

		m_bDirty = true;
		
		return true;
	}

	return false;
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:52,代码来源:CDataFile.cpp

示例2: CommentStr

t_Str CDataFile::CommentStr(t_Str szComment)
{
   t_Str szNewStr = t_Str("");

   Trim(szComment);

   if ( szComment.size() == 0 )
      return szComment;

   if ( szComment.find_first_of(CommentIndicators) != 0 )
      {
         szNewStr = CommentIndicators[0];
         szNewStr += " ";
      }

   szNewStr += szComment;

   return szNewStr;
}
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:19,代码来源:cdatafile.cpp

示例3: CommentStr

t_Str CDataFile::CommentStr(t_Str szComment)
{
	t_Str szNewStr = t_Str("");

	Trim(szComment);

        if ( szComment.size() == 0 )
          return szComment;
	
	if ( szComment.find(CommentIndicators[0]) == gedString::npos && szComment.find(CommentIndicators[1]) == gedString::npos)
	{
		szNewStr = (char)CommentIndicators[0];
		szNewStr += " ";
	}

	szNewStr += szComment;

	return szNewStr;
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:19,代码来源:CDataFile.cpp

示例4: Trim

// Trim
// Trims whitespace from both sides of a string.
void Trim(t_Str& szStr)
{
   t_Str szTrimChars = WhiteSpace;

   szTrimChars += EqualIndicators;
   int nPos, rPos;

   // trim left
   nPos = szStr.find_first_not_of(szTrimChars);

   if ( nPos > 0 )
      szStr.erase(0, nPos);

   // trim right and return
   nPos = szStr.find_last_not_of(szTrimChars);
   rPos = szStr.find_last_of(szTrimChars);

   if ( rPos > nPos && rPos > -1)
      szStr.erase(rPos, szStr.size()-rPos);
}
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:22,代码来源:cdatafile.cpp


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