MOAB: Mesh Oriented datABase  (version 5.3.1)
CLArgIDList Class Reference

#include <CLArgFlag.hpp>

+ Inheritance diagram for CLArgIDList:
+ Collaboration diagram for CLArgIDList:

Public Member Functions

 CLArgIDList (char fl, const char *pdesc, CLArgs::IntListArgI *pcallback)
virtual const CLArgs::ArgIBasecallback () const
virtual bool parse (const char *str) const
virtual std::string brief () const
virtual std::string manstr () const

Public Attributes

CLArgs::IntListArgImCallback

Detailed Description

Definition at line 215 of file CLArgFlag.hpp.


Constructor & Destructor Documentation

CLArgIDList::CLArgIDList ( char  fl,
const char *  pdesc,
CLArgs::IntListArgI pcallback 
) [inline]

Definition at line 221 of file CLArgFlag.hpp.

        : CLArgFlag( fl, pdesc ), mCallback( pcallback )
    {
    }

Member Function Documentation

std::string CLArgIDList::brief ( ) const [virtual]

Get brief format of option

Implements CLArgFlag.

Definition at line 239 of file CLArgFlag.cpp.

{
    const char str[] = { '-', flag(), '\0' };
    std::string result( str );
    result += " <id_list>";
    return result;
}
virtual const CLArgs::ArgIBase* CLArgIDList::callback ( ) const [inline, virtual]

Implements CLArgFlag.

Definition at line 226 of file CLArgFlag.hpp.

References mCallback.

    {
        return mCallback;
    }
std::string CLArgIDList::manstr ( ) const [virtual]

Get UNIX man-page formated synposis of flag

Implements CLArgFlag.

Definition at line 246 of file CLArgFlag.cpp.

{
    return make_man_string( "id_list" );
}
bool CLArgIDList::parse ( const char *  str) const [virtual]

Implements CLArgFlag.

Definition at line 251 of file CLArgFlag.cpp.

{
    std::vector< int > list;
    long v;
    int i, j;
    char* endptr;
    for( ;; )
    {
        while( isspace( *str ) )
            ++str;
        if( !*str ) break;

        v = strtol( str, &endptr, 10 );
        if( endptr == str || v <= 0 ) return false;

        i = (int)v;
        if( (long)i != v ) return false;

        list.push_back( i );
        str = endptr;

        while( isspace( *str ) )
            ++str;

        if( *str == '-' )
        {
            do
            {
                ++str;
            } while( isspace( *str ) );
            v = strtol( str, &endptr, 10 );
            if( endptr == str || v < i ) return false;
            j = (int)v;
            if( (long)j != v ) return false;
            for( ++i; i < j; ++j )
                list.push_back( i );

            str = endptr;
            while( isspace( *str ) )
                ++str;
        }

        if( !*str ) break;
        if( *str != ',' ) return false;
        ++str;
    }

    if( list.empty() ) return false;

    if( !mCallback->value( list ) ) return false;
    mCallback->set_seen();
    return true;
}

Member Data Documentation

Definition at line 218 of file CLArgFlag.hpp.

Referenced by callback().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines