123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- /*
- 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 <stdlib.h> // <- RandomInt
- #include <time.h>
- #include <string.h> // <- memset, strcpy
- #include <stdio.h> // <- 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
- }
|