library/src/blockclass/subclasses/BP_StringUtils.cc
// Adds a find/replace set to the stack.  Find is regular expression.
Adds a find/replace set to the stack.  Find is regular expression.
Adds a find / replace set to the stack . Find is regular expression .
bool BP_StringUtils::AddRegFind(char *replace_this, char *replace_with)
{
	if(!replace_this)
		return false;
	if(!replace_with)
		return false;
	this->find_item_count++;
	this->find_strs    = (char **) tq_realloc(this->tq, this->find_strs,    sizeof(char *) * (this->find_item_count+1), BPLN);
	this->replace_strs = (char **) tq_realloc(this->tq, this->replace_strs, sizeof(char *) * (this->find_item_count+1), BPLN);
	this->find_strs[this->find_item_count-1]    = tq_strdup(this->tq, replace_this, BPLN);
	this->find_strs[this->find_item_count]    = NULL;
	if(replace_with)
	{
		this->replace_strs[this->find_item_count-1] = tq_strdup(this->tq, replace_with, BPLN);
		this->replace_strs[this->find_item_count]   = NULL;
	}
	else
		this->replace_strs[this->find_item_count-1] = NULL;
	return true;
}
bool BP_StringUtils :: AddRegFind ( char * replace_this , char * replace_with ) { if ( ! replace_this ) return false ; if ( ! replace_with ) return false ; this -> find_item_count ++ ; this -> find_strs = ( char * * ) tq_realloc ( this -> tq , this -> find_strs , sizeof ( char * ) * ( this -> find_item_count + 1 ) , BPLN ) ; this -> replace_strs = ( char * * ) tq_realloc ( this -> tq , this -> replace_strs , sizeof ( char * ) * ( this -> find_item_count + 1 ) , BPLN ) ; this -> find_strs [ this -> find_item_count - 1 ] = tq_strdup ( this -> tq , replace_this , BPLN ) ; this -> find_strs [ this -> find_item_count ] = NULL ; if ( replace_with ) { this -> replace_strs [ this -> find_item_count - 1 ] = tq_strdup ( this -> tq , replace_with , BPLN ) ; this -> replace_strs [ this -> find_item_count ] = NULL ; } else this -> replace_strs [ this -> find_item_count - 1 ] = NULL ; return true ; }
Adds a find/replace set to the stack.
Adds a find / replace set to the stack .
// replace this and replace with are required parameters // array of strings to use as input to find and replace // bpreallocate space for find/replace strings // set the find/replace item in the array // terminate the array // return indicating success