Slice Tools
  • Home
  • SourceForge Page


  • libFoundation
  • Home
  • Class Hierarchy
  • Class List
  • Class Members
  • Examples


  • SourceForge.net Logo
     

    OptionResult Class Reference

    #include <OptionResult.hh>

    Inheritance diagram for OptionResult:

    FloatOptionResult IntOptionResult StringOptionResult List of all members.

    Detailed Description

    Abstract Base class for managing setting results of option data.

    Managed and created by the Options class


    Public Member Functions

     OptionResult (const std::string &optionHelp)
     Sets defaults for all results.

    virtual ~OptionResult ()
     Empty Deconstructor.

    void addNameOrAlias (const std::string &name, bool hasNegation)
     Adds a name or alias to a result class.

    void verifyType (char optionType)
     Verifies that the type of the class matches the requested type.

    std::string getName () const
     Returns the main name of the object.

    std::string getNextAlias ()
     Gets the next alias from map using the class iterator.

    void resetAliasIter ()
     Resets the object iterator for getNextAlias.

    bool isNegation (const std::string &name)
     Returns if a given name is a negation.

    int has_arg ()
     Simple getter to check if option takes an argument in positive form.

    void setHas_arg (int has_arg)
     Simple setter for if option takes an argument in positive form.

    virtual void setVal (const std::string &name, const std::string &val)=0
     Pure virtual function for converting a value into its resultant type.

    int resultSet (const std::string &name)
     Returns the number of times an option was set.

    std::string getRawValue () const
     Gets the raw value that was set.

    void printHelp (bool isStandardOption)
     Iterates through each alias and prints the option help.

    virtual void writeDefault ()=0
     Pure virtual function for write the value of the resultpointer.


    Protected Member Functions

    void incrementCount (const std::string &name)
     Increments the proper counter for the name.

    void validateArgumentCount (const std::string &name, const std::string &val)
     Validates that the option name should or should not take an argument.


    Protected Attributes

    char m_type
     Type of resultant.

    std::string m_rawval
     Raw value for option from command line.


    Constructor & Destructor Documentation

    OptionResult::OptionResult const std::string &  optionHelp  ) 
     

    Sets defaults for all results.

    OptionResult::~OptionResult  )  [virtual]
     

    Empty Deconstructor.


    Member Function Documentation

    void OptionResult::addNameOrAlias const std::string &  name,
    bool  hasNegation
     

    Adds a name or alias to a result class.

    The first time this is called, it adds it as its name. If it has a negation, then it adds "no"name as well.

    Also resets the iterator for getNextAlias()

    Parameters:
    name 
    hasNegation 

    std::string OptionResult::getName  )  const
     

    Returns the main name of the object.

    std::string OptionResult::getNextAlias  ) 
     

    Gets the next alias from map using the class iterator.

    std::string OptionResult::getRawValue  )  const
     

    Gets the raw value that was set.

    int OptionResult::has_arg  ) 
     

    Simple getter to check if option takes an argument in positive form.

    Uses same syntax as getopt

    See also:
    setHas_arg

    void OptionResult::incrementCount const std::string &  name  )  [protected]
     

    Increments the proper counter for the name.

    bool OptionResult::isNegation const std::string &  name  ) 
     

    Returns if a given name is a negation.

    void OptionResult::printHelp bool  isStandardOption  ) 
     

    Iterates through each alias and prints the option help.

    Parameters:
    isStandardOption Standard options should not print their defaults

    void OptionResult::resetAliasIter  ) 
     

    Resets the object iterator for getNextAlias.

    int OptionResult::resultSet const std::string &  name  ) 
     

    Returns the number of times an option was set.

    Note: Separate counters are maintained for positive or negative options, so caller may need to call resultSet("option") and resultSet("nooption") to find out what was really specified.

    void OptionResult::setHas_arg int  has_arg  ) 
     

    Simple setter for if option takes an argument in positive form.

    Uses same syntax as getopt

    See also:
    has_arg

    virtual void OptionResult::setVal const std::string &  name,
    const std::string &  val
    [pure virtual]
     

    Pure virtual function for converting a value into its resultant type.

    Implemented in IntOptionResult, FloatOptionResult, and StringOptionResult.

    void OptionResult::validateArgumentCount const std::string &  name,
    const std::string &  val
    [protected]
     

    Validates that the option name should or should not take an argument.

    Exceptions:
    InvalidOptionError If option was given an argument but takes none
    InvalidOptionError If option wasnt given a required argument

    void OptionResult::verifyType char  optionType  ) 
     

    Verifies that the type of the class matches the requested type.

    Exceptions:
    InvalidOptionError If there is a type mismatch

    virtual void OptionResult::writeDefault  )  [pure virtual]
     

    Pure virtual function for write the value of the resultpointer.

    Implemented in IntOptionResult, FloatOptionResult, and StringOptionResult.


    Member Data Documentation

    std::string OptionResult::m_rawval [protected]
     

    Raw value for option from command line.

    char OptionResult::m_type [protected]
     

    Type of resultant.


    The documentation for this class was generated from the following files: