CIntegerRange class

Pipelines v1.6

 

Member variables, Member functions

Home

 

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

 

    

CProcess &m_Process

[in] Your CStage (*this ) pointer.

 

    

bool m_bRequired

[in,opt] Set this option to true if the integer range is a required stage command argument and must be present, otherwise false; which indicates that the integer range is an optional argument and may or may not be present.

 

    

int m_nReturnCode

[out] The returncode set by the function which uses this object.

 

    

const char **m_pszSource

[in,out] The address of a pointer to your stage command argument.

  

    

long m_lFrom
[out] The start of the integer range.

 

    

bool m_bFromSigned

[in,opt] Set this option to true if m_lFrom can be a signed value.

 

    

long m_lTo
[out] The end or length of the integer range.

 

    

bool m_bToSigned
[in,opt] Set this option to true if m_lTo can be a signed value.
 

    

int m_nType
[in,out] The type of integer range.
 

 

[in] An input integer range; which specifies that the stage command argument signifies an input position and optional length of the data to be extracted from a record, or an output integer range; which specifies that the stage command argument signifies an output position and optional length of the data to be written to a record. The following enumerations describe these types:

 
enum eIntegerRange { eTo, eFor, eSingle, eInput, eOutput };

 

[out] The type of integer range that has been extracted; this can be a to, for or single integer range. The following enumerations describe these types:

 
enum eIntegerRange { eTo, eFor, eSingle, eInput, eOutput };

 

 

The type of integer range which can be specified as a stage command argument depends on the type of integer range specified in the member; m_nType. A range type of eInput will only allow a valid input integer range specification and a range type of eOutput will only allow a valid output integer range specification.

 

The eTo and eFor [out] m_nTypes represent an absolute and relative position, respectively. eTo represents an absolute position and eFor represents the zero based index of a position (this allows you to use direct indexing or pointer arithmetic to isolate sections of a record).

 

The following table shows some examples of input and output values.

 

 

Stage argument

Pattern

m_nType

m_lFrom

m_lTo

 

 

[in]

[out]

m_bFromSigned

(true)

m_bFromSigned

(false)

m_bToSigned

(true)

m_bToSigned

(false)

 

 

 

 

 

 

 

 

9-12

loc-loc

loc;loc

eInput/

eOutput

eTo

-

9

-

12

-10;3

-loc;loc

eInput

eTo

-10

-

-

3

25;-3

loc;-loc

eInput

eTo

-

25

-3

-

-1;-1

-loc;-loc

eInput

eSingle

-1

-

-1

-

23

Loc

eInput/

eOutput

eSingle

-

23

-

-

-99

-loc

eInput

eSingle

-99

-

-

-

15-*

loc-*

loc;*

eInput

eTo

-

15

-

2147483647

*;24

*-loc

*;loc

eInput/

eOutput

eTo

-

1

-

24

*;-10

*;-loc

eInput

eTo

-

1

-10

-

-13;*

-loc;*

eInput

eTo

-13

-

2147483647

-

*-*

*;*

*-*

*;*

eInput

eTo

-

1

n/a

2147483647

10.55

loc.n

eInput/

eOutput

eFor

-

10

-

64

 

    

bool m_bSkipLeading

[in,opt] Set this option to true if leading delimiters are to be skipped.

 

    

CString m_szLeadingDelim

[in,opt] A list of characters; any of which are considered to be leading delimiters. By default; the list contains a space, a tab character and new-line character.

 

    

bool m_bSkipTrailing

[in,opt] Set this option to true if trailing delimiters are to be skipped.

 

    

CString m_szTrailingDelim

[in,opt] A list of characters; any of which are considered to be trailing delimiters. By default; the list contains a space, a tab character and a new-line character.

 

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

 

 

CProcess &a_Process

[in] Your CStage (*this ) pointer.

 

    

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

 

void

 

    

Returns

 

void

 

    

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 );
}