• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ t_Str类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CompareNoCase

// CompareNoCase
// it's amazing what features std::string lacks.  This function simply
// does a lowercase compare against the two strings, returning 0 if they
// match.
int CompareNoCase(t_Str str1, t_Str str2)
{
#ifdef WIN32
   return stricmp(str1.c_str(), str2.c_str());
#else
   return strcasecmp(str1.c_str(), str2.c_str());
#endif
}
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:12,代码来源:cdatafile.cpp


示例2:

bool t_Str::operator!=(const t_Str &s1) const
{
        if(compare(s1.getText()) != 0)
                return true;

        return false;
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:7,代码来源:string++.cpp


示例3: t_Str

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


示例4: t_Str

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


示例5: GetNextWord

// GetNextWord
// Given a key +delimiter+ value string, pulls the key name from the string,
// deletes the delimiter and alters the original string to contain the
// remainder.  Returns the key
t_Str GetNextWord(t_Str& CommandLine)
{
   int nPos = CommandLine.find_first_of(EqualIndicators);
   t_Str sWord = t_Str("");

   if ( nPos > -1 )
      {
         sWord = CommandLine.substr(0, nPos);
         CommandLine.erase(0, nPos+1);
      }
   else
      {
         sWord = CommandLine;
         CommandLine = t_Str("");
      }

   Trim(sWord);
   return sWord;
}
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:23,代码来源:cdatafile.cpp


示例6: SetFileName

// SetFileName
// Set's the m_szFileName member variable. For use when creating the CDataFile
// object by hand (-vs- loading it from a file
void CDataFile::SetFileName(t_Str szFileName)
{
   if (m_szFileName.size() != 0 && CompareNoCase(szFileName, m_szFileName) != 0)
      {
         m_bDirty = true;

         Report(E_WARN, "[CDataFile::SetFileName] The filename has changed from <%s> to <%s>.",
                m_szFileName.c_str(), szFileName.c_str());
      }

   m_szFileName = szFileName;
}
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:15,代码来源:cdatafile.cpp


示例7: GetNextWord

// GetNextWord
// Given a key +delimiter+ value string, pulls the key name from the string,
// deletes the delimiter and alters the original string to contain the
// remainder.  Returns the key
t_Str GetNextWord(t_Str& CommandLine)
{
	int nPos = CommandLine.find(EqualIndicators[0]);

	if(nPos == gedString::npos)
		nPos = CommandLine.find(EqualIndicators[1]);

	t_Str sWord = t_Str("");

	if ( nPos > -1 )
	{
		sWord = CommandLine.substr(0, nPos);
		CommandLine.erase(0, nPos+1);
	}
	else
	{
		sWord = CommandLine;
		CommandLine = t_Str("");
	}

	Trim(sWord);
	return sWord;
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:27,代码来源:CDataFile.cpp


示例8: GetKey

// 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


示例9: copy

void t_Str::copy(const t_Str &original)
{
	clear();

	if(original.getLength() < minsize)
	{
		content.ministring.length = (unsigned)original.getLength();
		memmove(content.ministring.text, original.getText(), original.getLength() + 1);
		content.ministring.big = false;
		return;
	}

//	ptr = original.getText();
	content.bigstring.length = original.getLength();
	content.bigstring.size = setSize(original.getLength() + 1);
	content.bigstring.text = getSpace(content.bigstring.size);
	content.ministring.big = true;
	memmove(content.bigstring.text, original.getText(), original.getLength() + 1);
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:19,代码来源:string++.cpp


示例10: strprintf

int strprintf(t_Str &str, size_t size, const char *format, ...)
{
	va_list args;
	va_start(args, format);
	int rtn;

	if(!size)
		size = str.getSize();

	if(size > str.getSize())
		str.resize(size);

	char *ptr = str.getText();
	str.setLength(0);
	ptr[0] = 0;
	rtn = vsnprintf(ptr, size, format, args);
	str.setLength(strlen(ptr));
	va_end(args);
	return rtn;
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:20,代码来源:string++.cpp


示例11: 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


示例12: search

bool t_Str::operator*=(const t_Str &s1) const
{
	return search(s1.getText(), s1.getLength()) != npos;
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例13: Trim

// Trim
// Trims whitespace from both sides of a string.
void Trim(t_Str& szStr)
{
	szStr.trimLeft();
	szStr.trimRight();
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:7,代码来源:CDataFile.cpp


示例14: rfind

size_t t_Str::rfind(const t_Str &str, size_t ind) const
{
	return rfind(str.getText(), ind, str.getLength());
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例15: find

size_t t_Str::find(const t_Str &str, size_t ind, unsigned instance) const
{
	return find(str.getText(), ind, str.getLength(), instance);
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例16: count

unsigned t_Str::count(const t_Str &str, size_t ind) const
{
	return count(str.getText(), ind, str.getLength());
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例17: append

void t_Str::append(const t_Str &str)
{
	append(str.getText(), str.getLength());
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例18: set

void t_Str::set(const t_Str &str)
{
	set(str.getText(), str.getLength());
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例19: insert

void t_Str::insert(size_t start, const t_Str &s)
{
	insert(start, s.getText(), s.getLength());
}
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:4,代码来源:string++.cpp


示例20: File

// Load
// Attempts to load in the text file. If successful it will populate the
// Section list with the key/value pairs found in the file. Note that comments
// are saved so that they can be rewritten to the file later.
bool CDataFile::Load(t_Str szFileName)
{
   // We dont want to create a new file here.  If it doesn't exist, just
   // return false and report the failure.
   std::fstream File(szFileName.c_str(), std::ios_base::in);
   // |std::ios_base::nocreate
   if ( File.is_open() )
      {
         bool bDone = false;
         bool bAutoKey = (m_Flags & AUTOCREATE_KEYS) == AUTOCREATE_KEYS;
         bool bAutoSec = (m_Flags & AUTOCREATE_SECTIONS) == AUTOCREATE_SECTIONS;

         t_Str szLine;
         t_Str szComment;
         char buffer[MAX_BUFFER_LEN];
         t_Section* pSection = GetSection("");

         // These need to be set, we'll restore the original values later.
         m_Flags |= AUTOCREATE_KEYS;
         m_Flags |= AUTOCREATE_SECTIONS;

         while ( !bDone )
            {
               memset(buffer, 0, MAX_BUFFER_LEN);
               File.getline(buffer, MAX_BUFFER_LEN);

               szLine = buffer;
               Trim(szLine);

               bDone = ( File.eof() || File.bad() || File.fail() );

               if ( szLine.find_first_of(CommentIndicators) == 0 )
                  {
                     szComment += "\n";
                     szComment += szLine;
                  }
               else
                  if ( szLine.find_first_of('[') == 0 ) // new section
                     {
                        szLine.erase( 0, 1 );
                        szLine.erase( szLine.find_last_of(']'), 1 );

                        CreateSection(szLine, szComment);
                        pSection = GetSection(szLine);
                        szComment = t_Str("");
                     }
                  else
                     if ( szLine.size() > 0 ) // we have a key, add this key/value pair
                        {
                           t_Str szKey = GetNextWord(szLine);
                           t_Str szValue = szLine;

                           if ( szKey.size() > 0 && szValue.size() > 0 )
                              {
                                 SetValue(szKey, szValue, szComment, pSection->szName);
                                 szComment = t_Str("");
                              }
                        }
            }

         // Restore the original flag values.
         if ( !bAutoKey )
            m_Flags &= ~AUTOCREATE_KEYS;

         if ( !bAutoSec )
            m_Flags &= ~AUTOCREATE_SECTIONS;
      }
   else
      {
         Report(E_INFO, "[CDataFile::Load] Unable to open file. Does it exist?");
         return false;
      }

   File.close();

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ t_mapEntitiesFromRoot类代码示例发布时间:2022-05-31
下一篇:
C++ tTJSVariant类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap