fragmentcollector_mpd.cpp
/**
 * @brief Replace matching token with given string
 *
 * @param[in] str      String in which operation to be performed
 * @param[in] from     Token
 * @param[in] toString String to replace token
 *
 * @retval position
 */
@brief Replace matching token with given string
@param[in] str      String in which operation to be performed
@param[in] from     Token
@param[in] toString String to replace token

@retval position
@brief Replace matching token with given string @param [ in ] str String in which operation to be performed @param [ in ] from Token @param [ in ] toString String to replace token @retval position
static int replace(std::string& str, const std::string& from, const std::string& toString )
{
	int rc = 0;
	size_t tokenLength = from.length();
	for (;;)
	{
		bool done = true;
		size_t pos = 0;
		for (;;)
		{
			pos = str.find('$', pos);
			if (pos == std::string::npos)
			{
				break;
			}
			size_t next = str.find('$', pos + 1);
			if (str.substr(pos + 1, tokenLength) == from)
			{
				str.replace(pos, tokenLength + 2, toString);
				done = false;
				rc++;
				break;
			}
			pos = next + 1;
		}
		if (done) break;
	}
	return rc;
}
static int replace ( std :: string & str , const std :: string & from , const std :: string & toString ) { int rc = 0 ; size_t tokenLength = from . length ( ) ; for ( ; ; ) { bool done = true ; size_t pos = 0 ; for ( ; ; ) { pos = str . find ( ' ' , pos ) ; if ( pos == std :: string :: npos ) { break ; } size_t next = str . find ( ' ' , pos + 1 ) ; if ( str . substr ( pos + 1 , tokenLength ) == from ) { str . replace ( pos , tokenLength + 2 , toString ) ; done = false ; rc ++ ; break ; } pos = next + 1 ; } if ( done ) break ; } return rc ; }
@brief Replace matching token with given string
 @param[in] str      String in which operation to be performed
 @param[in] from     Token
 @param[in] toString String to replace token
@brief Replace matching token with given string @param [ in ] str String in which operation to be performed @param [ in ] from Token @param [ in ] toString String to replace token