PSCF v1.1
Public Member Functions | List of all members
Util::FlagSet Class Reference

A set of boolean variables represented by characters. More...

#include <FlagSet.h>

Public Member Functions

 FlagSet ()
 Default constructor. More...
 
 FlagSet (std::string allowed)
 Constructor. More...
 
void setAllowed (std::string allowed)
 Set or reset the string of allowed flags. More...
 
void setActualOrdered (std::string actual)
 Set the string of actual flag characters. More...
 
bool isActive (char c) const
 Is the flag associated with character c active? More...
 
const std::string & allowed () const
 Return the string of allowed characters. More...
 
const std::string & actual () const
 Return the string of character for which flags are set. More...
 

Detailed Description

A set of boolean variables represented by characters.

A FlagSet has a string of allowed characters, each of which which represents a boolean variable (i.e., a flag), and a string of actual characters containing the subset of the allowed characters that should be set on (i.e., true).

Definition at line 28 of file FlagSet.h.

Constructor & Destructor Documentation

◆ FlagSet() [1/2]

Util::FlagSet::FlagSet ( )

Default constructor.

Definition at line 17 of file FlagSet.cpp.

◆ FlagSet() [2/2]

Util::FlagSet::FlagSet ( std::string  allowed)

Constructor.

This function calls setAllowed(string) internally.

Parameters
allowedstring of all allowed characters.

Definition at line 23 of file FlagSet.cpp.

References allowed(), and setAllowed().

Member Function Documentation

◆ setAllowed()

void Util::FlagSet::setAllowed ( std::string  allowed)

Set or reset the string of allowed flags.

This function sets isActive false for all flags and clears the actual string.

Parameters
allowedstring of all allowed characters

Definition at line 29 of file FlagSet.cpp.

References allowed().

Referenced by FlagSet().

◆ setActualOrdered()

void Util::FlagSet::setActualOrdered ( std::string  actual)

Set the string of actual flag characters.

This function requires that the characters in the actual string appear in the same order as they do in the allowed string, but allows some allowed characters to be absent.

An Exception is thrown if actual contains a character that is not allowed, or if it is not in order.

Parameters
actualstring containing a subset of allowed characters

Definition at line 47 of file FlagSet.cpp.

References actual(), and UTIL_THROW.

◆ isActive()

bool Util::FlagSet::isActive ( char  c) const
inline

Is the flag associated with character c active?

Parameters
ccharacter to be tested.

Definition at line 110 of file FlagSet.h.

References UTIL_THROW.

◆ allowed()

const std::string & Util::FlagSet::allowed ( ) const
inline

Return the string of allowed characters.

Definition at line 123 of file FlagSet.h.

Referenced by FlagSet(), and setAllowed().

◆ actual()

const std::string & Util::FlagSet::actual ( ) const
inline

Return the string of character for which flags are set.

Definition at line 130 of file FlagSet.h.

Referenced by setActualOrdered().


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