diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 19:45:36 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 19:45:36 +0200 |
commit | bfa452a375ea0a0a3f95304a69186936567e5263 (patch) | |
tree | aade062a143c1afcc4ea06ee27905ffc34a9217b /src/core/xbfilter.cpp | |
parent | dd70ff8bf32c2d7ed365004b1770058265db1978 (diff) |
New upstream version 4.1.4
Diffstat (limited to 'src/core/xbfilter.cpp')
-rwxr-xr-x | src/core/xbfilter.cpp | 544 |
1 files changed, 0 insertions, 544 deletions
diff --git a/src/core/xbfilter.cpp b/src/core/xbfilter.cpp deleted file mode 100755 index 0fb643d..0000000 --- a/src/core/xbfilter.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* xbfilter.cpp - -XBase64 Software Library - -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel - -The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. - -Email Contact: - - XDB-devel@lists.sourceforge.net - XDB-users@lists.sourceforge.net - - -This module handles uda (user data area) methods - -*/ - -#include "xbase.h" - - -// might need to change thisto XB_EXPRESSION_SUPPORT -#ifdef XB_FILTER_SUPPORT - - -namespace xb{ - -/************************************************************************/ -xbFilter::xbFilter( xbDbf *dbf ) { - this->dbf = dbf; - this->exp = NULL; - lLimit = 0; // max number of responses - lCurQryCnt = 0; // current number, this query + = moving fwd - // - = moving backwards - - #ifdef XB_INDEX_SUPPORT - pIx = NULL; // if index is set, the class uses the index tag, otherwise table - vpTag = NULL; - #endif // XB_INDEX_SUPPORT - -} -/************************************************************************/ -xbFilter::~xbFilter() { - if( exp ) - delete exp; -} -/************************************************************************/ -xbInt32 xbFilter::GetLimit() const { - return lLimit; -} -/************************************************************************/ -xbInt32 xbFilter::GetQryCnt() const { - return lCurQryCnt; -} -/************************************************************************/ -void xbFilter::SetLimit( xbInt32 lLimit ){ - this->lLimit = lLimit; -} -/************************************************************************/ -void xbFilter::ResetQryCnt(){ - this->lCurQryCnt = 0; -} - -/************************************************************************/ -xbInt16 xbFilter::Set( const char *sFilter ) { - xbString sFilt( sFilter ); - return Set( sFilt ); -} - -/************************************************************************/ -xbInt16 xbFilter::Set( xbString &sFilter ) { - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( exp ) - delete exp; - - exp = new xbExp( dbf->GetXbasePtr(), dbf ); - if(( iRc = exp->ParseExpression( sFilter.Str() )) != XB_NO_ERROR ){ - iErrorStop = 100; - throw iRc; - } - if( exp->GetReturnType() != XB_EXP_LOGICAL ){ - iErrorStop = 110; - iRc = XB_INVALID_EXPRESSION; - delete exp; - exp = NULL; - throw iRc; - } - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::SetExpression() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetFirstRecord( xbInt16 iOption ) { - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - lCurQryCnt = 0; - if(( iRc = dbf->GetFirstRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EMPTY || iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - if(( iRc = dbf->GetNextRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt++; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetFirstRecord() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetNextRecord( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - if( lLimit != 0 && abs( lCurQryCnt ) >= lLimit ) - return XB_LIMIT_REACHED; - - if(( iRc = dbf->GetNextRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - if(( iRc = dbf->GetNextRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt++; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetNextRecord() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetPrevRecord( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - if( lLimit != 0 && abs( lCurQryCnt ) >= lLimit ) - return XB_LIMIT_REACHED; - - if(( iRc = dbf->GetPrevRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - if(( iRc = dbf->GetPrevRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt--; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetPrevRecord() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetLastRecord( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - lCurQryCnt = 0; - if(( iRc = dbf->GetLastRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - if(( iRc = dbf->GetPrevRecord( iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt--; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetLastRecord() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} - -/************************************************************************/ - -#ifdef XB_INDEX_SUPPORT - -/************************************************************************/ -xbInt16 xbFilter::GetFirstRecordIx( xbInt16 iOption ) { - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - lCurQryCnt = 0; - if(( iRc = dbf->GetCurIx()->GetFirstKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EMPTY || iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - // if(( iRc = pIx->GetNextKey( vpTag, iOption )) != XB_NO_ERROR ){ - if(( iRc = dbf->GetCurIx()->GetNextKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt++; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetFirstRecordIx() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetNextRecordIx( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - if( lLimit != 0 && abs( lCurQryCnt ) >= lLimit ) - return XB_LIMIT_REACHED; - - if(( iRc = dbf->GetCurIx()->GetNextKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - // if(( iRc = pIx->GetNextKey( vpTag, iOption )) != XB_NO_ERROR ){ - if(( iRc = dbf->GetCurIx()->GetNextKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt++; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetNextRecordIx() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetPrevRecordIx( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - - if( lLimit != 0 && abs( lCurQryCnt ) >= lLimit ) - return XB_LIMIT_REACHED; - - if(( iRc = dbf->GetCurIx()->GetPrevKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - //if(( iRc = pIx->GetPrevKey( vpTag, iOption )) != XB_NO_ERROR ){ - if(( iRc = dbf->GetCurIx()->GetPrevKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt--; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetPrevRecordIx() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -/************************************************************************/ -xbInt16 xbFilter::GetLastRecordIx( xbInt16 iOption ){ - - xbInt16 iRc = XB_NO_ERROR; - xbInt16 iErrorStop = 0; - try{ - - if( !exp ){ - iErrorStop = 100; - throw iRc; - } - lCurQryCnt = 0; - if(( iRc = dbf->GetCurIx()->GetLastKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_EOF ) - return iRc; - else{ - iErrorStop = 110; - throw iRc; - } - } - xbBool bFound = xbFalse; - while( !bFound && iRc == XB_NO_ERROR ){ - if(( iRc = exp->ProcessExpression()) != XB_NO_ERROR ){ - iErrorStop = 120; - throw iRc; - } - if(( iRc = exp->GetBoolResult( bFound )) != XB_NO_ERROR ){ - iErrorStop = 130; - throw iRc; - } - if( !bFound ){ - if(( iRc = dbf->GetCurIx()->GetPrevKey( dbf->GetCurTag(), iOption )) != XB_NO_ERROR ){ - if( iRc == XB_BOF ){ - return iRc; - } else { - iErrorStop = 140; - throw iRc; - } - } - } - } - lCurQryCnt--; - } - catch (xbInt16 iRc ){ - xbString sMsg; - sMsg.Sprintf( "xbFilter::GetLastRecordIx() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc ); - dbf->GetXbasePtr()->WriteLogMessage( sMsg.Str() ); - dbf->GetXbasePtr()->WriteLogMessage( dbf->GetXbasePtr()->GetErrorMessage( iRc )); - } - return iRc; -} -#endif // XB_INDEX_SUPPORT - - -/************************************************************************/ -} /* namespace */ -#endif /* XB_FILTER_SUPPORT */
\ No newline at end of file |