library/src/blockclass/BP-BlockClass.cc
// Generates constraints suitable for use in queries (where clause)
Generates constraints suitable for use in queries (where clause)
Generates constraints suitable for use in queries ( where clause )
BP_ERROR_T Block::webResultStackWhereClauses()
{
	if(!this->web_result_stack_n)
		return ERR_FAILURE;
	this->destroyWebResultStackWhereClauses();
	BP_StringUtils * id_builder            = new BP_StringUtils(NULL);
	BP_StringUtils * assessment_id_builder = new BP_StringUtils(NULL);
	BP_StringUtils * base_builder          = new BP_StringUtils(NULL);
	BP_StringUtils * path_builder          = new BP_StringUtils(NULL);
	BP_StringUtils * script_builder        = new BP_StringUtils(NULL);
	id_builder->duplicate_unique_strings            = true;
	assessment_id_builder->duplicate_unique_strings = true;
	base_builder->duplicate_unique_strings          = true;
	path_builder->duplicate_unique_strings          = true;
	script_builder->duplicate_unique_strings        = true;
	char id[128];
	char assessment_id[128];
	char base[128];
	char path[128];
	char script[128];
	size_t n = 0;
	for(; n < this->web_result_stack_n; n++)
	{
		memset((void *)&id, 0x00, sizeof(id));
		memset((void *)&assessment_id, 0x00, sizeof(assessment_id));
		memset((void *)&base, 0x00, sizeof(base));
		memset((void *)&path, 0x00, sizeof(path));
		memset((void *)&script, 0x00, sizeof(script));
		snprintf((char *) &id, sizeof(id)-1, "%zu", this->web_result_stack[n].result_id);
		snprintf((char *) &assessment_id, sizeof(assessment_id)-1, "%zu", this->web_result_stack[n].assessment_id);
		snprintf((char *) &base, sizeof(base)-1, "%zu", this->web_result_stack[n].base);
		snprintf((char *) &path, sizeof(path)-1, "%zu", this->web_result_stack[n].path);
		snprintf((char *) &script, sizeof(script)-1, "%zu", this->web_result_stack[n].script);
		if(this->web_result_stack[n].result_id)
			id_builder->AddUniqueString((char *) &id);
		if(this->web_result_stack[n].assessment_id)
			assessment_id_builder->AddUniqueString((char *) &assessment_id);
		if(this->web_result_stack[n].base)
			base_builder->AddUniqueString((char *) &base);
		if(this->web_result_stack[n].path)
			path_builder->AddUniqueString((char *) &path);
		if(this->web_result_stack[n].script)
			script_builder->AddUniqueString((char *) &script);
	}
	if(id_builder->unique_str_cnt)
	{
		id_builder->BuildString(" `results`.`id` in ( ");
		id_builder->buildUniqueStringStackAsCSV(BP_STRINGUTILS_BUILD_UNQUOTED_CSV);
		id_builder->BuildString(" ) ");
		this->results_in_id_clause = (char *) tq_strdup(this->tq, id_builder->build_str, BPLN);
		this->id_n = id_builder->unique_str_cnt;
		delete id_builder;
	}
	if(assessment_id_builder->unique_str_cnt)
	{
		assessment_id_builder->BuildString(" `results`.`assessment_id` in ( ");
		assessment_id_builder->buildUniqueStringStackAsCSV(BP_STRINGUTILS_BUILD_UNQUOTED_CSV);
		assessment_id_builder->BuildString(" ) ");
		this->results_in_assessment_id_clause = (char *) tq_strdup(this->tq, assessment_id_builder->build_str, BPLN);
		this->assessment_id_n = assessment_id_builder->unique_str_cnt;
		delete assessment_id_builder;
	}
	if(base_builder->unique_str_cnt)
	{
		base_builder->BuildString(" `results`.`base` in ( ");
		base_builder->buildUniqueStringStackAsCSV(BP_STRINGUTILS_BUILD_UNQUOTED_CSV);
		base_builder->BuildString(" ) ");
		this->results_in_base_clause = (char *) tq_strdup(this->tq, base_builder->build_str, BPLN);
		this->base_n = base_builder->unique_str_cnt;
		delete base_builder;
	}
	if(path_builder->unique_str_cnt)
	{
		path_builder->BuildString(" `results`.`path` in ( ");
		path_builder->buildUniqueStringStackAsCSV(BP_STRINGUTILS_BUILD_UNQUOTED_CSV);
		path_builder->BuildString(" ) ");
		this->results_in_path_clause = (char *) tq_strdup(this->tq, path_builder->build_str, BPLN);
		this->path_n = path_builder->unique_str_cnt;
		delete path_builder;
	}
	if(script_builder->unique_str_cnt)
	{
		script_builder->BuildString(" `results`.`script` in ( ");
		script_builder->buildUniqueStringStackAsCSV(BP_STRINGUTILS_BUILD_UNQUOTED_CSV);
		script_builder->BuildString(" ) ");
		this->results_in_script_clause = (char *) tq_strdup(this->tq, script_builder->build_str, BPLN);
		this->script_n = script_builder->unique_str_cnt;
		delete script_builder;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T Block :: webResultStackWhereClauses ( ) { if ( ! this -> web_result_stack_n ) return ERR_FAILURE ; this -> destroyWebResultStackWhereClauses ( ) ; BP_StringUtils * id_builder = new BP_StringUtils ( NULL ) ; BP_StringUtils * assessment_id_builder = new BP_StringUtils ( NULL ) ; BP_StringUtils * base_builder = new BP_StringUtils ( NULL ) ; BP_StringUtils * path_builder = new BP_StringUtils ( NULL ) ; BP_StringUtils * script_builder = new BP_StringUtils ( NULL ) ; id_builder -> duplicate_unique_strings = true ; assessment_id_builder -> duplicate_unique_strings = true ; base_builder -> duplicate_unique_strings = true ; path_builder -> duplicate_unique_strings = true ; script_builder -> duplicate_unique_strings = true ; char id [ 128 ] ; char assessment_id [ 128 ] ; char base [ 128 ] ; char path [ 128 ] ; char script [ 128 ] ; size_t n = 0 ; for ( ; n < this -> web_result_stack_n ; n ++ ) { memset ( ( void * ) & id , 0x00 , sizeof ( id ) ) ; memset ( ( void * ) & assessment_id , 0x00 , sizeof ( assessment_id ) ) ; memset ( ( void * ) & base , 0x00 , sizeof ( base ) ) ; memset ( ( void * ) & path , 0x00 , sizeof ( path ) ) ; memset ( ( void * ) & script , 0x00 , sizeof ( script ) ) ; snprintf ( ( char * ) & id , sizeof ( id ) - 1 , " " , this -> web_result_stack [ n ] . result_id ) ; snprintf ( ( char * ) & assessment_id , sizeof ( assessment_id ) - 1 , " " , this -> web_result_stack [ n ] . assessment_id ) ; snprintf ( ( char * ) & base , sizeof ( base ) - 1 , " " , this -> web_result_stack [ n ] . base ) ; snprintf ( ( char * ) & path , sizeof ( path ) - 1 , " " , this -> web_result_stack [ n ] . path ) ; snprintf ( ( char * ) & script , sizeof ( script ) - 1 , " " , this -> web_result_stack [ n ] . script ) ; if ( this -> web_result_stack [ n ] . result_id ) id_builder -> AddUniqueString ( ( char * ) & id ) ; if ( this -> web_result_stack [ n ] . assessment_id ) assessment_id_builder -> AddUniqueString ( ( char * ) & assessment_id ) ; if ( this -> web_result_stack [ n ] . base ) base_builder -> AddUniqueString ( ( char * ) & base ) ; if ( this -> web_result_stack [ n ] . path ) path_builder -> AddUniqueString ( ( char * ) & path ) ; if ( this -> web_result_stack [ n ] . script ) script_builder -> AddUniqueString ( ( char * ) & script ) ; } if ( id_builder -> unique_str_cnt ) { id_builder -> BuildString ( " " ) ; id_builder -> buildUniqueStringStackAsCSV ( BP_STRINGUTILS_BUILD_UNQUOTED_CSV ) ; id_builder -> BuildString ( " " ) ; this -> results_in_id_clause = ( char * ) tq_strdup ( this -> tq , id_builder -> build_str , BPLN ) ; this -> id_n = id_builder -> unique_str_cnt ; delete id_builder ; } if ( assessment_id_builder -> unique_str_cnt ) { assessment_id_builder -> BuildString ( " " ) ; assessment_id_builder -> buildUniqueStringStackAsCSV ( BP_STRINGUTILS_BUILD_UNQUOTED_CSV ) ; assessment_id_builder -> BuildString ( " " ) ; this -> results_in_assessment_id_clause = ( char * ) tq_strdup ( this -> tq , assessment_id_builder -> build_str , BPLN ) ; this -> assessment_id_n = assessment_id_builder -> unique_str_cnt ; delete assessment_id_builder ; } if ( base_builder -> unique_str_cnt ) { base_builder -> BuildString ( " " ) ; base_builder -> buildUniqueStringStackAsCSV ( BP_STRINGUTILS_BUILD_UNQUOTED_CSV ) ; base_builder -> BuildString ( " " ) ; this -> results_in_base_clause = ( char * ) tq_strdup ( this -> tq , base_builder -> build_str , BPLN ) ; this -> base_n = base_builder -> unique_str_cnt ; delete base_builder ; } if ( path_builder -> unique_str_cnt ) { path_builder -> BuildString ( " " ) ; path_builder -> buildUniqueStringStackAsCSV ( BP_STRINGUTILS_BUILD_UNQUOTED_CSV ) ; path_builder -> BuildString ( " " ) ; this -> results_in_path_clause = ( char * ) tq_strdup ( this -> tq , path_builder -> build_str , BPLN ) ; this -> path_n = path_builder -> unique_str_cnt ; delete path_builder ; } if ( script_builder -> unique_str_cnt ) { script_builder -> BuildString ( " " ) ; script_builder -> buildUniqueStringStackAsCSV ( BP_STRINGUTILS_BUILD_UNQUOTED_CSV ) ; script_builder -> BuildString ( " " ) ; this -> results_in_script_clause = ( char * ) tq_strdup ( this -> tq , script_builder -> build_str , BPLN ) ; this -> script_n = script_builder -> unique_str_cnt ; delete script_builder ; } return ERR_SUCCESS ; }
Generates constraints suitable for use in queries (where clause)
Generates constraints suitable for use in queries ( where clause )
// destroy the where clauses where necessary // create string builder // enable unique string duplication // conversion buffers // walk result stack // zero out the id string // embed the result id in the string // add unique strings // build unquoted csv // assessment_id_builder unquoted csv // base unquoted csv // path unquoted csv // script unquoted csv // return indicating success