Example #1
0
//++
// Details: Recursively remove from a string doubled up characters so only one
// set left.
//          Characters are only removed if the previous character is already a
//          same
//          character.
// Type:    Method.
// Args:    vChar   - (R) The character to search for and remove adjacent
// duplicates.
//          vnPos   - Character position in the string.
// Return:  CMIUtilString - New version of the string.
// Throws:  None.
//--
CMIUtilString CMIUtilString::RemoveRepeatedCharacters(size_t vnPos,
                                                      const char vChar) {
  const char cQuote = '"';

  // Look for first quote of two
  const size_t nPos = find(cQuote, vnPos);
  if (nPos == std::string::npos)
    return *this;

  const size_t nPosNext = nPos + 1;
  if (nPosNext > length())
    return *this;

  if (at(nPosNext) == cQuote) {
    *this = substr(0, nPos) + substr(nPosNext, length());
    RemoveRepeatedCharacters(nPosNext, vChar);
  }

  return *this;
}
Example #2
0
//++ ------------------------------------------------------------------------------------
// Details: Remove from a string doubled up characters so only one set left. Characters
//          are only removed if the previous character is already a same character.
// Type:    Method.
// Args:    vChar   - (R) The character to search for and remove adjacent duplicates.
// Return:  CMIUtilString - New version of the string.
// Throws:  None.
//--
CMIUtilString
CMIUtilString::RemoveRepeatedCharacters(const char vChar)
{
    return RemoveRepeatedCharacters(0, vChar);
}