MOAB: Mesh Oriented datABase  (version 5.4.1)
CLArgToggle Class Reference

#include <CLArgFlag.hpp>

+ Inheritance diagram for CLArgToggle:
+ Collaboration diagram for CLArgToggle:

Public Member Functions

 CLArgToggle (char pflag, const char *pdesc, bool value, CLArgs::ToggleArgI *pcallback)
 CLArgToggle (char pflag, const char *pdesc, CLArgToggle *opposite)
virtual const CLArgs::ArgIBasecallback () const
virtual bool is_toggle () const
virtual bool parse (const char *option) const
virtual std::string brief () const
virtual std::string manstr () const

Private Attributes

bool mValue
 value to pass to callback when flag is encountered
CLArgs::ToggleArgImCallback
CLArgTogglemOpposite

Detailed Description

Definition at line 89 of file CLArgFlag.hpp.


Constructor & Destructor Documentation

CLArgToggle::CLArgToggle ( char  pflag,
const char *  pdesc,
bool  value,
CLArgs::ToggleArgI pcallback 
) [inline]

Definition at line 97 of file CLArgFlag.hpp.

        : CLArgFlag( pflag, pdesc ), mValue( value ), mCallback( pcallback ), mOpposite( 0 )
    {
    }
CLArgToggle::CLArgToggle ( char  pflag,
const char *  pdesc,
CLArgToggle opposite 
) [inline]

Definition at line 101 of file CLArgFlag.hpp.

References mOpposite.

        : CLArgFlag( pflag, pdesc ), mValue( !opposite->mValue ), mCallback( opposite->mCallback ),
          mOpposite( opposite )
    {
        mOpposite->mOpposite = this;
    }

Member Function Documentation

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

Get brief format of option

Implements CLArgFlag.

Definition at line 102 of file CLArgFlag.cpp.

References CLArgFlag::flag(), and mOpposite.

{
    if( !mOpposite )
    {
        const char result[] = { '-', flag(), '\0' };
        return result;
    }
    else if( mOpposite->flag() < flag() )
    {
        return std::string();
    }
    else
    {
        const char result[] = { '-', flag(), '|', '-', mOpposite->flag(), '\0' };
        return result;
    }
}
virtual const CLArgs::ArgIBase* CLArgToggle::callback ( ) const [inline, virtual]

Implements CLArgFlag.

Definition at line 108 of file CLArgFlag.hpp.

References mCallback.

    {
        return mCallback;
    }
virtual bool CLArgToggle::is_toggle ( ) const [inline, virtual]

Reimplemented from CLArgFlag.

Definition at line 113 of file CLArgFlag.hpp.

    {
        return true;
    }
std::string CLArgToggle::manstr ( ) const [virtual]

Get UNIX man-page formated synposis of flag

Implements CLArgFlag.

Definition at line 120 of file CLArgFlag.cpp.

References ManPage::begin_bold(), ManPage::end_bold(), CLArgFlag::flag(), CLArgFlag::make_man_string(), and mOpposite.

{
    if( !mOpposite )
    {
        return make_man_string();
    }
    else if( mOpposite->flag() > flag() )
    {
        std::ostringstream result;
        ManPage::begin_bold( result );
        result << "-" << flag();
        ManPage::end_bold( result );
        result << "|";
        ManPage::begin_bold( result );
        result << "-" << mOpposite->flag();
        ManPage::end_bold( result );
        return result.str();
    }
    else
    {
        return std::string();
    }
}
bool CLArgToggle::parse ( const char *  option) const [virtual]

Implements CLArgFlag.

Definition at line 95 of file CLArgFlag.cpp.

References mCallback, mValue, CLArgs::ArgIBase::set_seen(), and CLArgs::ArgTemplateI< T >::value().

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

Member Data Documentation

Definition at line 93 of file CLArgFlag.hpp.

Referenced by callback(), and parse().

Definition at line 94 of file CLArgFlag.hpp.

Referenced by brief(), CLArgToggle(), and manstr().

bool CLArgToggle::mValue [private]

value to pass to callback when flag is encountered

Definition at line 92 of file CLArgFlag.hpp.

Referenced by parse().

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