MOAB: Mesh Oriented datABase  (version 5.2.1)
CLArgs::KeyWordArg Class Reference

String arugment that is limited to a list of acceptable keywords. More...

#include <CLArgs.hpp>

+ Inheritance diagram for CLArgs::KeyWordArg:
+ Collaboration diagram for CLArgs::KeyWordArg:

Public Member Functions

 KeyWordArg (const char *keyword_list[], int list_length)
 KeyWordArg (const char *default_val, const char *keyword_list[], int list_length)
virtual bool value (const std::string &val)
virtual std::string brief () const
 Get short description string for usage output or empty string for default.
virtual std::string manstr () const
 Get short description string for UNIX man page output or empty string for default.

Static Public Member Functions

static bool compare_no_case (const char *s1, const char *s2)

Private Member Functions

void initialize (const char *keyword_list[], int list_length)

Private Attributes

std::vector< std::string > mKeyWords

Detailed Description

String arugment that is limited to a list of acceptable keywords.

A specialized string arugment implementation that limits the acceptable string argument to one of a list of keywords. A case-insensitive comparison is done with the allowed keywords. The "value" has the case of the keyword rather than the case used in the literal value specified in the command line argument.

Definition at line 218 of file CLArgs.hpp.


Constructor & Destructor Documentation

CLArgs::KeyWordArg::KeyWordArg ( const char *  keyword_list[],
int  list_length 
) [inline]

Definition at line 225 of file CLArgs.hpp.

References initialize().

        {
            initialize( keyword_list, list_length );
        }
CLArgs::KeyWordArg::KeyWordArg ( const char *  default_val,
const char *  keyword_list[],
int  list_length 
) [inline]

Definition at line 229 of file CLArgs.hpp.

References initialize().

                                                                                           : StringArg( default_val )
        {
            initialize( keyword_list, list_length );
        }

Member Function Documentation

std::string CLArgs::KeyWordArg::brief ( ) const [virtual]

Get short description string for usage output or empty string for default.

Reimplemented from CLArgs::ArgIBase.

Definition at line 429 of file CLArgs.cpp.

{
    std::ostringstream ss;
    std::vector< std::string >::const_iterator i = mKeyWords.begin();
    if( i == mKeyWords.end() ) return std::string();

    ss << '{' << *i;
    for( ++i; i != mKeyWords.end(); ++i )
        ss << '|' << *i;
    ss << '}';
    return ss.str();
}
bool CLArgs::KeyWordArg::compare_no_case ( const char *  s1,
const char *  s2 
) [static]

Definition at line 456 of file CLArgs.cpp.

{
    for( ; *s1; ++s1, ++s2 )
        if( toupper( *s1 ) != toupper( *s2 ) ) return false;
    return !*s2;
}
void CLArgs::KeyWordArg::initialize ( const char *  keyword_list[],
int  list_length 
) [private]

Definition at line 414 of file CLArgs.cpp.

References mKeyWords.

Referenced by KeyWordArg().

{
    mKeyWords.resize( list_length );
    std::copy( keyword_list, keyword_list + list_length, mKeyWords.begin() );
}
std::string CLArgs::KeyWordArg::manstr ( ) const [virtual]

Get short description string for UNIX man page output or empty string for default.

Reimplemented from CLArgs::ArgIBase.

Definition at line 442 of file CLArgs.cpp.

References ManPage::bold().

{
    if( mKeyWords.empty() ) return std::string();

    std::ostringstream ss;
    ManPage::bold( ss, mKeyWords[0].c_str() );
    for( unsigned i = 1; i < mKeyWords.size(); ++i )
    {
        ss << "|";
        ManPage::bold( ss, mKeyWords[i].c_str() );
    }
    return ss.str();
}
bool CLArgs::KeyWordArg::value ( const std::string &  val) [virtual]

Definition at line 420 of file CLArgs.cpp.

References compare_no_case(), and value().

{
    std::vector< std::string >::const_iterator i;
    for( i = mKeyWords.begin(); i != mKeyWords.end(); ++i )
        if( compare_no_case( i->c_str(), val.c_str() ) ) { return value( *i ); }

    return false;
}

Member Data Documentation

std::vector< std::string > CLArgs::KeyWordArg::mKeyWords [private]

Definition at line 221 of file CLArgs.hpp.

Referenced by initialize().

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