Пример #1
0
// 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);
}
Пример #2
0
// 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;
}
Пример #3
0
// 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;
}