library/src/javascript/JSON/BP-JSON.cc
// lookup entry by table index and table path query
lookup entry by table index and table path query
lookup entry by table index and table path query
P_BP_HASH_TABLE_KEYED_ENTRY BP_JSONLookupEntryByTableIndexAndTablePathQuery(P_BP_JSON json, char *table_lookup_query, char *table_data_index)
{
	if(!json)
		return NULL;
	if(!json->json_out_hreg)
		return NULL;
	if(!table_lookup_query)
		return NULL;
	if(!table_data_index)
		return NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY looked_up_entry = BP_HashRegLookupTableEntryByDataKeyIndexAndTablePathQuery
	(
		json->json_out_hreg,
		table_lookup_query,
		table_data_index
	);
	if(looked_up_entry)
		return looked_up_entry;
	char ** path_array = BP_HashRegStringLookupToPathArray(table_lookup_query, bpstrlen(table_lookup_query));
	if(!path_array)
		return NULL;
	size_t entry_count = BP_CountNullTerminatedPtrArray(path_array);
	if(!entry_count)
		return NULL;
	char *extended_path[entry_count+10];
	BP_ZERO_STACK(extended_path);
	size_t iter_n = 0;
	for(; iter_n < entry_count; iter_n++)
	{
		extended_path[iter_n] = path_array[iter_n];
	}
	extended_path[iter_n]   = table_data_index;
	extended_path[iter_n+1] = NULL;
	looked_up_entry = BP_HashRegLookupTableByPath(json->json_out_hreg, (char **) &extended_path);
	if(!looked_up_entry)
		return NULL;
	return looked_up_entry;
}
P_BP_HASH_TABLE_KEYED_ENTRY BP_JSONLookupEntryByTableIndexAndTablePathQuery ( P_BP_JSON json , char * table_lookup_query , char * table_data_index ) { if ( ! json ) return NULL ; if ( ! json -> json_out_hreg ) return NULL ; if ( ! table_lookup_query ) return NULL ; if ( ! table_data_index ) return NULL ; P_BP_HASH_TABLE_KEYED_ENTRY looked_up_entry = BP_HashRegLookupTableEntryByDataKeyIndexAndTablePathQuery ( json -> json_out_hreg , table_lookup_query , table_data_index ) ; if ( looked_up_entry ) return looked_up_entry ; char * * path_array = BP_HashRegStringLookupToPathArray ( table_lookup_query , bpstrlen ( table_lookup_query ) ) ; if ( ! path_array ) return NULL ; size_t entry_count = BP_CountNullTerminatedPtrArray ( path_array ) ; if ( ! entry_count ) return NULL ; char * extended_path [ entry_count + 10 ] ; BP_ZERO_STACK ( extended_path ) ; size_t iter_n = 0 ; for ( ; iter_n < entry_count ; iter_n ++ ) { extended_path [ iter_n ] = path_array [ iter_n ] ; } extended_path [ iter_n ] = table_data_index ; extended_path [ iter_n + 1 ] = NULL ; looked_up_entry = BP_HashRegLookupTableByPath ( json -> json_out_hreg , ( char * * ) & extended_path ) ; if ( ! looked_up_entry ) return NULL ; return looked_up_entry ; }
lookup entry by table index and table path query
lookup entry by table index and table path query
// run basic null checks // attempt to lookup entry in the hash registry // lookup the entry // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Attempt to Lookup Table (requires path) %%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // determine path array // retrieve entry count // zero out the extended path // iterate through path array and build query // set index and truncate // set the looked up entry from table if we couldn't find an entry // return the looked up entry (or null if lookup fails)