|
CIntegerRange class |
Pipelines v1.6 |
|
Description |
The CIntegerRange class object is
used by the ParseForIntegerRange() function to extract an integer range from a
stage command argument. The integer range takes the form of a from and to combination of integer strings. However, this is transparent to
the stage designer; the format of a range only applies to the way it is
specified as a stage command argument. The ParseForIntegerRange() function,
which determines this format automatically; extracts the range, converts the from and to integer strings to (long) integer values and stores them in the m_lFrom
and m_lTo
members, respectively.
|
Definition |
The following class definition is
an edited version; it details only those members which are accessible and of
use to you. In addition; any examples that may be shown are only intended as a
demonstration of how certain functions might be used, they do not represent
best practice nor do they take into account the scope and de-allocation of
class objects.
enum eIntegerRange { eTo, eFor, eSingle, eInput, eOutput }; class CIntegerRange{ public: CIntegerRange( CProcess &a_Process ) : m_Process( a_Process ), m_bRequired( false ), m_nReturnCode( _RC_SUCCESS_ ), m_pszSource( NULL ), m_lFrom( 1 ), m_bFromSigned( true ), m_lTo( 1 ), m_bToSigned( true ), m_nType( eInput ), m_bSkipLeading( true ), m_szLeadingDelim( " \n\t" ), m_bSkipTrailing( true ), m_szTrailingDelim( " \n\t" ) {} void Reset( void ) { m_bRequired = false; m_lFrom = 1; m_bFromSigned = true; m_lTo = 1; m_bToSigned = true; m_nType = eInput; m_bSkipLeading = true; m_szLeadingDelim = " \n\t"; m_bSkipTrailing = true; m_szTrailingDelim = m_szLeadingDelim; } CProcess &m_Process; bool m_bRequired; int m_nReturnCode; const char **m_pszSource; long m_lFrom; bool m_bFromSigned; long m_lTo; bool m_bToSigned; int m_nType; bool m_bSkipLeading; CString m_szLeadingDelim; bool m_bSkipTrailing; CString m_szTrailingDelim;};
|
Member variables |
|
Member functions |
CIntegerRange::CIntegerRange( _in CProcess &a_Process ); |
|
● |
Purpose Use
CIntegerRange() to create an integer range parser object. The
CIntegerRange class object is used by the ParseForIntegerRange() function to
extract an integer range from your stage command argument. Simply initialise
the members as you require and call the ParseForIntegerRange() function to
extract the range. |
||
|
● |
Parameters |
||
|
|
|
||
|
● |
Returns n/a |
||
|
● |
Messages None |
||
|
● |
Usage bool CMyStage::Initialise( void ) { // Access the manager.CStageManager *pManager = Manager(); // Access my stage. CStage *pStage = pManager->GetStage( *this ); ... // Point to my stage command argument. const char *pszArgument = pStage->Argument(); // My stage requires an unsigned input integer range as its // stage command argument. CIntegerRange *pIntRange = new CIntegerRange( *this ); // Extract a column range. pIntRange->m_pszSource = &pszArgument; pIntRange->m_bFromSigned = false; pIntRange->m_bToSigned = false; pIntRange->m_bRequired = true; if( !pManager->ParseForIntegerRange( pIntRange ) ) return( false ); long lInpFrom = pIntRange->m_lFrom; long lInpTo = pIntRange->m_lTo; long nType = m_pIntRange->m_nType; ... return( true );} |
void CIntegerRange::Reset( void ); |
|
● |
Purpose Use Reset() to
reset the default extraction settings. The function
will reset the extraction switches and re-initialise the delimiter
definitions with their default values, but, leaving the m_Process and m_pszSource members
unchanged; you can re-use a CIntegerRange parser object when extracting
integer range arguments, one after another. |
||
|
● |
Parameters
|
||
|
● |
Returns
|
||
|
● |
Messages None |
||
|
● |
Usage bool CMyStage::Initialise( void ) { // Access the manager.CStageManager *pManager = Manager(); // Access my stage. CStage *pStage = pManager->GetStage( *this ); ... // Point to my stage command argument. const char *pszArgument = pStage->Argument(); // My stage requires two integer ranges; the first is a signed // input range, the second is an unsigned output range, which // is optional. CIntegerRange *pIntRange = new CIntegerRange( *this ); // // Extract the first integer range. // // Extract an integer range pIntRange->m_pszSource = &pszArgument; pIntRange->m_bRequired = true; if( !pManager->ParseForIntegerRange( pIntRange ) ) return( false ); long lInFrom = pIntRange->m_lFrom; long lInTo = pIntRange->m_lTo; long nInType = m_pIntRange->m_nType; // // Extract the second (optional) integer range. // pIntegerRange->Reset();// Extract an integer range. pIntRange->m_nType = eOutput; pIntRange->m_bFromSigned = false; pIntRange->m_bToSigned = false; if( pManager->ParseForIntegerRange( pIntRange ) ) { ... } ... return( true );} |
|
|