osrfAppRegisterMethod( MODULENAME, OSRF_BUFFER_C_STR(method_name),
"rollbackSavepoint", "", 1, 0 );
- buffer_free(method_name);
-
static const char* global_method[] = {
"create",
"retrieve",
osrfStringArray* classes = osrfHashKeys( oilsIDL() );
osrfLogDebug(OSRF_LOG_MARK, "%d classes loaded", classes->size );
osrfLogDebug(OSRF_LOG_MARK,
- "At least %d methods will be generated", classes->size * global_method_count);
+ "At most %d methods will be generated", classes->size * global_method_count);
// For each class in IDL...
while ( (classname = osrfStringArrayGetString(classes, c_index++)) ) {
( *method_type == 'c' || *method_type == 'u' || *method_type == 'd')
) continue;
- osrfHash* method_meta = osrfNewHash();
- osrfHashSet(method_meta, idlClass, "class");
-
- method_name = buffer_init(64);
+ buffer_reset( method_name );
#ifdef PCRUD
buffer_fadd(method_name, "%s.%s.%s", MODULENAME, method_type, classname);
#else
free(_fm);
#endif
- char* method = buffer_release(method_name);
-
- osrfHashSet( method_meta, method, "methodname" );
- osrfHashSet( method_meta, strdup(method_type), "methodtype" );
+ char* method = buffer_data(method_name);
int flags = 0;
if (*method_type == 'i' || *method_type == 's') {
flags = flags | OSRF_METHOD_STREAMING;
}
- osrfAppRegisterExtendedMethod(
+ osrfHash* method_meta = osrfNewHash();
+ osrfHashSet( method_meta, idlClass, "class");
+ osrfHashSet( method_meta, method, "methodname" );
+ osrfHashSet( method_meta, strdup(method_type), "methodtype" );
+
+ osrfAppRegisterExtendedMethod(
MODULENAME,
method,
"dispatchCRUDMethod",
} // end for each global method
} // end for each class in IDL
+ buffer_free( method_name );
osrfStringArrayFree( classes );
return 0;
osrfLogInfo(OSRF_LOG_MARK, "%s successfully connected to the database", MODULENAME);
- unsigned short type;
int i = 0;
char* classname;
osrfStringArray* classes = osrfHashKeys( oilsIDL() );
int columnIndex = 1;
const char* columnName;
osrfHash* _f;
- while( (columnName = dbi_result_get_field_name(result, columnIndex++)) ) {
+ while( (columnName = dbi_result_get_field_name(result, columnIndex)) ) {
osrfLogInternal(OSRF_LOG_MARK, "Looking for column named [%s]...", (char*)columnName);
/* fetch the fieldmapper index */
if( (_f = osrfHashGet(fields, (char*)columnName)) ) {
- osrfLogDebug(OSRF_LOG_MARK, "Found [%s] in IDL hash...", (char*)columnName);
+ osrfLogDebug(OSRF_LOG_MARK, "Found [%s] in IDL hash...", (char*)columnName);
- /* determine the field type and storage attributes */
- type = dbi_result_get_field_type(result, columnName);
+ /* determine the field type and storage attributes */
- switch( type ) {
+ switch( dbi_result_get_field_type_idx(result, columnIndex) ) {
case DBI_TYPE_INTEGER : {
if ( !osrfHashGet(_f, "primitive") )
osrfHashSet(_f,"number", "primitive");
- int attr = dbi_result_get_field_attribs(result, columnName);
+ int attr = dbi_result_get_field_attribs_idx(result, columnIndex);
if( attr & DBI_INTEGER_SIZE8 )
osrfHashSet(_f,"INT8", "datatype");
else
osrfHashGet(_f, "datatype")
);
}
- }
- dbi_result_free(result);
+ ++columnIndex;
+ } // end while loop for traversing result
+ dbi_result_free(result);
} else {
osrfLogDebug(OSRF_LOG_MARK, "No data found for class [%s]...", (char*)classname);
}
const char* columnName;
/* cycle through the column list */
- while( (columnName = dbi_result_get_field_name(result, columnIndex++)) ) {
+ while( (columnName = dbi_result_get_field_name(result, columnIndex)) ) {
osrfLogInternal(OSRF_LOG_MARK, "Looking for column named [%s]...", (char*)columnName);
fmIndex = -1; // reset the position
/* determine the field type and storage attributes */
- type = dbi_result_get_field_type(result, columnName);
- attr = dbi_result_get_field_attribs(result, columnName);
+ type = dbi_result_get_field_type_idx(result, columnIndex);
+ attr = dbi_result_get_field_attribs_idx(result, columnIndex);
/* fetch the fieldmapper index */
if( (_f = osrfHashGet(fields, (char*)columnName)) ) {
continue;
}
- if (dbi_result_field_is_null(result, columnName)) {
+ if (dbi_result_field_is_null_idx(result, columnIndex)) {
jsonObjectSetIndex( object, fmIndex, jsonNewObject(NULL) );
} else {
if( attr & DBI_INTEGER_SIZE8 )
jsonObjectSetIndex( object, fmIndex,
- jsonNewNumberObject(dbi_result_get_longlong(result, columnName)));
+ jsonNewNumberObject(dbi_result_get_longlong_idx(result, columnIndex)));
else
jsonObjectSetIndex( object, fmIndex,
- jsonNewNumberObject(dbi_result_get_int(result, columnName)));
+ jsonNewNumberObject(dbi_result_get_int_idx(result, columnIndex)));
break;
case DBI_TYPE_DECIMAL :
jsonObjectSetIndex( object, fmIndex,
- jsonNewNumberObject(dbi_result_get_double(result, columnName)));
+ jsonNewNumberObject(dbi_result_get_double_idx(result, columnIndex)));
break;
case DBI_TYPE_STRING :
jsonObjectSetIndex(
object,
fmIndex,
- jsonNewObject( dbi_result_get_string(result, columnName) )
+ jsonNewObject( dbi_result_get_string_idx(result, columnIndex) )
);
break;
memset(dt_string, '\0', sizeof(dt_string));
memset(&gmdt, '\0', sizeof(gmdt));
- _tmp_dt = dbi_result_get_datetime(result, columnName);
+ _tmp_dt = dbi_result_get_datetime_idx(result, columnIndex);
if (!(attr & DBI_DATETIME_DATE)) {
case DBI_TYPE_BINARY :
osrfLogError( OSRF_LOG_MARK,
- "Can't do binary at column %s : index %d", columnName, columnIndex - 1);
+ "Can't do binary at column %s : index %d", columnName, columnIndex);
}
}
+ ++columnIndex;
}
return object;
const char* columnName;
/* cycle through the column list */
- while( (columnName = dbi_result_get_field_name(result, columnIndex++)) ) {
+ while( (columnName = dbi_result_get_field_name(result, columnIndex)) ) {
osrfLogInternal(OSRF_LOG_MARK, "Looking for column named [%s]...", (char*)columnName);
fmIndex = -1; // reset the position
/* determine the field type and storage attributes */
- type = dbi_result_get_field_type(result, columnName);
- attr = dbi_result_get_field_attribs(result, columnName);
+ type = dbi_result_get_field_type_idx(result, columnIndex);
+ attr = dbi_result_get_field_attribs_idx(result, columnIndex);
- if (dbi_result_field_is_null(result, columnName)) {
+ if (dbi_result_field_is_null_idx(result, columnIndex)) {
jsonObjectSetKey( object, columnName, jsonNewObject(NULL) );
} else {
case DBI_TYPE_INTEGER :
if( attr & DBI_INTEGER_SIZE8 )
- jsonObjectSetKey( object, columnName, jsonNewNumberObject(dbi_result_get_longlong(result, columnName)) );
+ jsonObjectSetKey( object, columnName,
+ jsonNewNumberObject(dbi_result_get_longlong_idx(result, columnIndex)) );
else
- jsonObjectSetKey( object, columnName, jsonNewNumberObject(dbi_result_get_int(result, columnName)) );
+ jsonObjectSetKey( object, columnName,
+ jsonNewNumberObject(dbi_result_get_int_idx(result, columnIndex)) );
break;
case DBI_TYPE_DECIMAL :
- jsonObjectSetKey( object, columnName, jsonNewNumberObject(dbi_result_get_double(result, columnName)) );
+ jsonObjectSetKey( object, columnName,
+ jsonNewNumberObject(dbi_result_get_double_idx(result, columnIndex)) );
break;
case DBI_TYPE_STRING :
- jsonObjectSetKey( object, columnName, jsonNewObject(dbi_result_get_string(result, columnName)) );
+ jsonObjectSetKey( object, columnName,
+ jsonNewObject(dbi_result_get_string_idx(result, columnIndex)) );
break;
case DBI_TYPE_DATETIME :
memset(dt_string, '\0', sizeof(dt_string));
memset(&gmdt, '\0', sizeof(gmdt));
- _tmp_dt = dbi_result_get_datetime(result, columnName);
+ _tmp_dt = dbi_result_get_datetime_idx(result, columnIndex);
if (!(attr & DBI_DATETIME_DATE)) {
case DBI_TYPE_BINARY :
osrfLogError( OSRF_LOG_MARK,
- "Can't do binary at column %s : index %d", columnName, columnIndex - 1);
+ "Can't do binary at column %s : index %d", columnName, columnIndex );
}
}
- }
+ ++columnIndex;
+ } // end while loop traversing result
return object;
}