void TALIB::getIndicatorList (QStringList &l) { l.clear(); TA_StringTable *table; int loop; QStringList cl; TA_RetCode retCode = TA_GroupTableAlloc(&table); if (retCode == TA_SUCCESS) { for (loop = 0; loop < (int) table->size; loop++) cl.append(table->string[loop]); TA_GroupTableFree(table); } for (loop = 0; loop < (int) cl.count(); loop++) { retCode = TA_FuncTableAlloc(cl[loop], &table); if (retCode == TA_SUCCESS) { int loop2; for (loop2 = 0; loop2 < (int) table->size; loop2++ ) l.append(table->string[loop2]); TA_FuncTableFree(table); } } l.sort(); }
void init_tables() { // temporary variable return code TA_RetCode ret_code; // functions group table TA_StringTable *group_table; // define class variable @@groups - array of function groups // define class variable @@functions - hash of array of functions ret_code = TA_GroupTableAlloc( &group_table ); if( ret_code == TA_SUCCESS ) { // functions table TA_StringTable *function_table; // ruby array for functions group table VALUE rb_group_table = rb_ary_new(); // ruby hash for functions VALUE rb_function_table = rb_hash_new(); unsigned i, j; for( i=0; i < group_table->size; i++ ) { // temporary ruby array for group's function table VALUE rb_temp_func_table = rb_ary_new(); rb_ary_push(rb_group_table, rb_str_new2(group_table->string[i])); ret_code = TA_FuncTableAlloc( group_table->string[i], &function_table ); if( ret_code == TA_SUCCESS ) { for ( j=0; j < function_table->size; j++) rb_ary_push(rb_temp_func_table, rb_str_new2(function_table->string[j])); rb_hash_aset(rb_function_table, rb_str_new2(group_table->string[i]), rb_temp_func_table); TA_FuncTableFree ( function_table ); } } rb_define_class_variable( rb_cTAFunction, "@@groups", rb_group_table ); rb_define_class_variable( rb_cTAFunction, "@@functions", rb_function_table ); TA_GroupTableFree( group_table ); } }
TA_RetCode TA_ForEachFunc( TA_CallForEachFunc functionToCall, void *opaqueData ) { TA_StringTable *tableGroup; TA_StringTable *tableFunc; const TA_FuncDef *funcDef; const TA_FuncHandle *funcHandle; TA_RetCode retCode; unsigned int i, j; const TA_FuncInfo *funcInfo; if( functionToCall == NULL ) { return TA_BAD_PARAM; } /* Get all the group to iterate. */ retCode = TA_GroupTableAlloc( &tableGroup ); if( retCode == TA_SUCCESS ) { for( i=0; i < tableGroup->size; i++ ) { if( !tableGroup->string[i] ) { TA_GroupTableFree( tableGroup ); return TA_INTERNAL_ERROR(2); } /* Get all the symbols to iterate for this category. */ retCode = TA_FuncTableAlloc( tableGroup->string[i], &tableFunc ); if( retCode == TA_SUCCESS ) { if( !tableFunc ) { TA_GroupTableFree( tableGroup ); TA_FuncTableFree( tableFunc ); return TA_INTERNAL_ERROR(2); } for( j=0; j < tableFunc->size; j++ ) { if( !tableFunc->string[j] ) { TA_GroupTableFree( tableGroup ); TA_FuncTableFree( tableFunc ); return TA_INTERNAL_ERROR(2); } /* Get the function handle, and then the TA_FuncDef, * and then the TA_FuncInfo... */ retCode = TA_GetFuncHandle( tableFunc->string[j], &funcHandle ); if( retCode != TA_SUCCESS ) continue; if( !funcHandle ) { TA_GroupTableFree( tableGroup ); TA_FuncTableFree( tableFunc ); return TA_INTERNAL_ERROR(2); } funcDef = (const TA_FuncDef *)funcHandle; if( !funcDef ) { TA_GroupTableFree( tableGroup ); TA_FuncTableFree( tableFunc ); return TA_INTERNAL_ERROR(2); } funcInfo = funcDef->funcInfo; if( !funcInfo ) { TA_GroupTableFree( tableGroup ); TA_FuncTableFree( tableFunc ); return TA_INTERNAL_ERROR(2); } /* Call user provided function. */ (*functionToCall)( funcInfo, opaqueData ); } } TA_FuncTableFree( tableFunc ); } TA_GroupTableFree( tableGroup ); } else { return TA_INTERNAL_ERROR(2); } return TA_SUCCESS; }
TA_RetCode TA_ForEachFunc( TA_Libc *libHandle, TA_CallForEachFunc functionToCall, void *opaqueData ) { TA_PROLOG; TA_StringTable *tableGroup; TA_StringTable *tableFunc; const TA_FuncDef *funcDef; const TA_FuncHandle *funcHandle; TA_RetCode retCode; unsigned int i, j; const TA_FuncInfo *funcInfo; TA_TRACE_BEGIN( libHandle, TA_ForEachFunc ); if( functionToCall == NULL ) { TA_TRACE_RETURN( TA_BAD_PARAM ); } /* Get all the group to iterate. */ retCode = TA_GroupTableAlloc( libHandle, &tableGroup ); if( retCode == TA_SUCCESS ) { TA_ASSERT( libHandle, tableGroup != NULL ); for( i=0; i < tableGroup->size; i++ ) { TA_DEBUG_ASSERT( libHandle, tableGroup->string[i] != NULL ); /* Get all the symbols to iterate for this category. */ retCode = TA_FuncTableAlloc( libHandle, tableGroup->string[i], &tableFunc ); if( retCode == TA_SUCCESS ) { TA_DEBUG_ASSERT( libHandle, tableFunc != NULL ); for( j=0; j < tableFunc->size; j++ ) { TA_DEBUG_ASSERT( libHandle, tableFunc->string[j] != NULL ); /* Get the function handle, and then the TA_FuncDef, * and then the TA_FuncInfo... */ retCode = TA_GetFuncHandle( libHandle, tableFunc->string[j], &funcHandle ); if( retCode != TA_SUCCESS ) continue; TA_DEBUG_ASSERT( libHandle, funcHandle != NULL ); funcDef = (const TA_FuncDef *)funcHandle; TA_DEBUG_ASSERT( libHandle, funcDef != NULL ); funcInfo = funcDef->funcInfo; TA_DEBUG_ASSERT( libHandle, funcInfo != NULL ); /* Call user provided function. */ (*functionToCall)( libHandle, funcInfo, opaqueData ); } } TA_FuncTableFree( tableFunc ); } TA_GroupTableFree( tableGroup ); } else { TA_TRACE_RETURN( TA_INTERNAL_ERROR(2) ); } TA_TRACE_RETURN( TA_SUCCESS ); }