/* Licensed Materials - Property of IBM IBM Cognos Products: crx (C) Copyright IBM Corp. 2003, 2010 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /// COPYRIGHT_DATA { 'YEAR':[2010, 2009, 2003], 'RELEASE':['colorado_wave1'], 'VISIBLE':'YES', 'COMPONENT':'crx' } ///All lines above the COPYRIGHT_DATA line will be replaced when copyright notices are generated. // crxSDKSample.cpp // #include "crxSDK.h" #include // <- RandomInt #include #include // <- memset, strcpy #include // <- sprintf #if defined( _MSC_VER ) # define crxSDKSampleExport __declspec( dllexport ) #else # define crxSDKSampleExport #endif //------------------------------------------------------------ // Custom Report Functions //------------------------------------------------------------ // The crxSDKSampleTree.xml must contain the list of custom report functions // and must specify the type of their return value. // use "crxDTypeString" to return a CCL_char* // use "crxDTypeInt8" to return a CCL_int8 // ... // Note the exact spelling in: // use "crxDTypeDate" to return a CCLDate2 // use "crxDTypeTime" to return a CCLTime2 // use "crxDTypeTimeTZ" to return a CCLTimeTZ // use "crxDTypeDatetimeTZ" to return a CCLTimestampTZ // use "crxDTypeDatetime" to return a CCLTimestamp2 // use "crxDTypeDTInterval" to return a CCLInterval2 // use "crxDTypeYMInterval" to return a CCLIntervalYM //------------------------------------------------------------ // extern "C" { //------------------------------------------------------------ crxSDKSampleExport CCLDBColumnState SDKRandomInt ( void* result, CCL_uint32 resultSize, const crxDataI* context ) { srand( (unsigned)time( NULL ) ); *( (CCL_int32*)result ) = rand(); return( CCL_DB_COLSTATE_OK ); }// RandomInt //------------------------------------------------------------ crxSDKSampleExport CCLDBColumnState SDKArea ( void* result, CCL_uint32 resultSize, const crxDataI* context, const CCL_float64* arg1, const CCL_float64* arg2, const char* arg3 ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; switch( arg3[0] ) { case( 'T' ): case( 't' ): { *(CCL_float64*)result = (*arg1)*(*arg2)/2; break; } case( 'P' ): case( 'p' ): { *(CCL_float64*)result = (*arg1)*(*arg2); break; } default: { *(CCL_float64*)result = 0; state = CCL_DB_COLSTATE_ERROR; } } return( state ); }// Area //------------------------------------------------------------ crxSDKSampleExport CCLDBColumnState SDKDateToString ( void* result, CCL_uint32 resultSize, const crxDataI* context, const CCLDate2* arg1 ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; CCL_int32 year, month, day; year = month = day = 0; try { year = arg1->year; month = arg1->month; day = arg1->day; char yearStr[5]; char monthStr[5]; char dayStr[5]; memset( yearStr, 0, 5 ); memset( monthStr, 0, 5 ); memset( dayStr, 0, 5 ); sprintf( yearStr, "%04ld", year); sprintf( monthStr, "%02ld", month); sprintf( dayStr, "%02ld", day); strcpy( (CCL_char*)result, yearStr ); strcat( (CCL_char*)result, "-" ); strcat( (CCL_char*)result, monthStr ); strcat( (CCL_char*)result, "-" ); strcat( (CCL_char*)result, monthStr ); } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// DateToString // Trakker 535408 (SDK DOCS) begin crxSDKSampleExport CCLDBColumnState SDKtestReturnUint32 ( void* result, CCL_uint32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_uint32*)result = (CCL_uint32) 33; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnUint32 crxSDKSampleExport CCLDBColumnState SDKtestReturnInt32 ( void* result, CCL_int32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_int32*)result = (CCL_int32) 33; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnInt32 crxSDKSampleExport CCLDBColumnState SDKtestReturnUint64 ( void* result, CCL_uint32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_uint64*)result = (CCL_uint64) 33; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnUint64 crxSDKSampleExport CCLDBColumnState SDKtestReturnInt64 ( void* result, CCL_int32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_int64*)result = (CCL_int64) 33; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnInt64 crxSDKSampleExport CCLDBColumnState SDKtestReturnFloat32 ( void* result, CCL_int32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_float32*)result = (CCL_float32) 33.0; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnFloat32 crxSDKSampleExport CCLDBColumnState SDKtestReturnFloat64 ( void* result, CCL_uint32 resultSize, const crxDataI* context ) { CCLDBColumnState state = CCL_DB_COLSTATE_OK; try { *(CCL_float64*)result = (CCL_float64) 33; } catch( ... ) { state = CCL_DB_COLSTATE_ERROR; } return( state ); }// SDKtestReturnFloat64 // Trakker 535408 (SDK DOCS) end }