![]() |
PVL: Parameter Value Language
|
An Assignment implements a Parameter than contains a Value. More...
#include <Parameter.hh>
Public Member Functions | |
Assignment (const std::string name="") | |
Constructs an Assignment with a Default_Value. | |
Assignment (const Assignment &assignment) | |
Copy constructor. | |
Assignment (Parser &parser, const std::string name="") | |
Construct an Assignment from a Parser. | |
Assignment (const Parameter ¶meter) | |
Copy constructor from a Parameter. | |
Assignment * | clone () const |
Clones the Assignment by making a copy of itself. | |
int | compare (const Parameter ¶meter) const |
Compares this Assignment with another Parameter. | |
bool | is (const Type type) const |
Test if the Parameter is of some Type. | |
bool | is_Assignment () const |
Test if this is an Assignment. | |
bool | is_Token () const |
Test if this is a token Parameter. | |
Assignment & | operator= (const Value &value) |
Assigns a Value to this Assignment. | |
Assignment & | operator= (const Parameter ¶meter) |
Assigns a Parameter to this Assignment. | |
void | read (Parser &parser) |
Assigns the next Parameter from a Parser to this Parameter. | |
void | read (std::istream &in=std::cin) |
Reads an input stream parsed as PVL syntax into this Assignment. | |
Type | type () const |
Gets the Type specification. | |
Assignment & | type (const int type) |
Sets the Type specification. | |
std::string | type_name () const |
Gets the name for this Assignment's Type specification. | |
Value & | value () const |
Gets the Value of the Assignment. | |
~Assignment () | |
Destructor: deletes the Assignment's Value. |
An Assignment implements a Parameter than contains a Value.
The Assignment class is very lightweight: Objects of this class only add the Type specification code and a pointer to the assigned Value obect to the base Parameter class characteristics. No new methods beyond those declared for the base Parameter class for implmentation or override are defined here.
Assignment | ( | const std::string | name = "" | ) | [explicit] |
Constructs an Assignment with a Default_Value.
name | The Parameter name string. |
Assignment | ( | const Assignment & | assignment | ) |
Copy constructor.
Copies the Type specification and clones the Value.
assignment | The Assignment Parameter to be copied. |
Assignment | ( | const Parameter & | parameter | ) |
Copy constructor from a Parameter.
parameter | The Parameter to be copied. |
Invalid_Argument | If the Parameter to be copied is not an Assignment. The resulting Assignment is valid, but it will have a NULL Value. |
Assignment | ( | Parser & | parser, |
const std::string | name = "" |
||
) |
Construct an Assignment from a Parser.
A single Assignment is read using the Paser's get_parameter method. If a valid Assignment Parameter is obtained from the Parser it is assigned to this newly constructed Assignment Parameter. Otherwise this Assignement is given the TOKEN Type specification and a Default_Value.
If a non-empty name is specified, the new Parameter is given that name.
parser | The Parser from which to read an Assignment definition. |
name | A name for the new Parameter. [Default: the name of the parsed Parameter, or ""] |
~Assignment | ( | ) | [inline] |
Destructor: deletes the Assignment's Value.
Assignment* clone | ( | ) | const [inline, virtual] |
Clones the Assignment by making a copy of itself.
Implements Parameter.
References Parameter::Assignment.
bool is_Assignment | ( | ) | const [inline, virtual] |
bool is_Token | ( | ) | const [inline, virtual] |
Test if this is a token Parameter.
A token Parameter is an Assignment without an effective Value.
Reimplemented from Parameter.
References Parameter::TOKEN.
bool is | ( | const Type | type | ) | const [inline] |
Test if the Parameter is of some Type.
The test is the logical AND of the Parameter Subtype and the specified Type value. Thus, conceptually, the test is if the Parameter is any one of a possible combination of Types. For example, parameter.is (GROUP| OBJECT)
will be false for any ASSIGNMENT parameter, which could just as easily be tested by parameter.is (AGGREGATE)
; and parameter.is (ASSIGNMENT | AGGREGATE)
can be expected to always be true.
type | The Type specification code against which to test the Parameter. |
References Parameter::type().
Type type | ( | ) | const [inline, virtual] |
Gets the Type specification.
Implements Parameter.
Assignment& type | ( | const int | type | ) | [virtual] |
Sets the Type specification.
If the Type specification is ASSIGNMENT or TOKEN, then it applies to this Assignment. Otherwise the value is passed to the Assignment's Value.
type | The Type specification for the Assignment or its Value. |
Invalid_Argument | If the type value is not valid for an an Assignment nor a Value. |
Implements Parameter.
std::string type_name | ( | ) | const [inline, virtual] |
Gets the name for this Assignment's Type specification.
Implements Parameter.
References Parameter::type_name().
Value& value | ( | ) | const [inline, virtual] |
Gets the Value of the Assignment.
Implements Parameter.
Assignment& operator= | ( | const Parameter & | parameter | ) | [virtual] |
Assigns a Parameter to this Assignment.
If the Parameter is an Assignment its name, comment and Type specification are copied, but not its parent. It's Value is cloned and replaces this Assignment's Value, which is deleted.
Nothing is done when assigning a Parameter to itself.
parameter | The Parameter to be assigned. |
Invalid_Argument | if the Parameter is not an Assignment. |
Implements Parameter.
Assignment& operator= | ( | const Value & | value | ) | [virtual] |
Assigns a Value to this Assignment.
The current Value is deleted and the new value is cloned in its place. The Type specification is set to ASSIGNMENT.
value | The Value to be assigned. |
Implements Parameter.
int compare | ( | const Parameter & | parameter | ) | const [virtual] |
Compares this Assignment with another Parameter.
A Parameter compared with itself is, of course, identical.
The Parameter names are compared and, if they are different, the result of this comparison is returned.
When the Parameter names are the same, an Assignment is less than an Aggregate, and a TOKEN is less than an ASSIGNMENT.
When all else is the same (regardless of any comment) the result of comparing the Values is returned.
parameter | The Parameter to compare against. |
Implements Parameter.
void read | ( | std::istream & | in = std::cin | ) | [virtual] |
Reads an input stream parsed as PVL syntax into this Assignment.
A Parser is constructed from the input stream and passed to the read(Parser&) method. A single Assignment Parameter is parsed from the input stream
in | The istream to be parsed for PVL syntax. |
Implements Parameter.
void read | ( | Parser & | parser | ) | [virtual] |
Assigns the next Parameter from a Parser to this Parameter.
A single Assignment Parameter is obtained from the Parser and assigned to this Parameter. If no Assignment Parameter is obtained from the Parser, this Assignment Parameter remains unchanged.
N.B: Only an Assignment Parameter will be parsed even if the PVL syntax contains a name for the next parameter that is a special_type keyword. Thus, for example, where the PVL syntax defines a GROUP parameter which begins an Aggregate Parameter an Assignment Parameter will be obtained instead which will be named "GROUP" having a value that would otherwise be the name of the Aggregate Parameter. Similarly, where the end of PVL syntax is marked a TOKEN Assignment named "END" will be obtained instead. As a result it is possible for subsequent operations of the Parser to become confused about the structural context of the PVL syntax having lost track of a structural marker parameter. This method should only be used when direct, individual processing of each parameter defined in the PVL syntax is intended. In most cases use of the Parser::get_parameter method is preferable.
Implements Parameter.