idaeim studio
 PVL: Parameter Value Language

Value Class Reference

A Value is a general-purpose, abstract value entity. More...

#include <Value.hh>

Inheritance diagram for Value:

Inheritance graph
[legend]
Collaboration diagram for Value:

Collaboration graph
[legend]

List of all members.

Public Types

enum  {
  MIN_BASE = 2,
  MAX_BASE = 36
}
 The range of allowable radix base values. More...

Public Member Functions

virtual Valuebase (const int base)
 Sets the numeric base.
virtual int base () const
 Gets the numeric base.
virtual Valueclone () const =0
 Creates a Value clone of the Value.
virtual int compare (const Value &value) const =0
 Logically compares another Value to this Value.
Valuedigits (const int digits)
 Sets the number of digits for the Value representation.
int digits () const
 Gets the number of digits for the Value representation.
virtual bool is_Array () const
 Tests if the Value is an Array.
virtual bool is_Date_Time () const
 Tests if the Value is a DATE_TIME String.
virtual bool is_Identifier () const
 Tests if the Value is an IDENTIFIER String.
virtual bool is_Integer () const
 Tests if the Value is an Integer type.
virtual bool is_Numeric () const
 Tests if the Value is an Integer or Real.
virtual bool is_Real () const
 Tests if the Value is a Real type.
virtual bool is_Sequence () const
 Tests if the Value is a SEQUENCE Array.
virtual bool is_Set () const
 Tests if the Value is a SET Array.
virtual Valueis_signed (const bool signedness)
 Sets the signed-ness of the Value.
virtual bool is_signed () const
 Tests if the Value is signed.
virtual bool is_String () const
 Tests if the Value is a String type.
virtual bool is_Symbol () const
 Tests if the Value is a SYMBOL String.
virtual bool is_Text () const
 Tests if the Value is a TEXT String.
std::string nearest_units () const
 Gets the "nearest" units description for the Value.
virtual operator int () const =0
 Casts the Value to an int.
virtual operator Integer_type () const =0
 Casts the Value to an Integer_type.
virtual operator Real_type () const =0
 Casts the Value to a Real_type.
virtual operator String_type () const =0
 Casts the Value to a String_type.
 operator unsigned int () const
 Casts the Value to an unsigned int.
 operator Unsigned_Integer_type () const
 Casts the Value to an Unsigned_Integer_type.
bool operator!= (const Value &value) const
 Test if a Value is logically not equivalent to another Value.
virtual Valueoperator+= (const Value &value)=0
 Adds another Value to this Value.
bool operator< (const Value &value) const
 Test if this Value is logically less than another Value.
bool operator<= (const Value &value) const
 Test if a Value is logically less than or equal to another Value.
virtual Valueoperator= (const char *value)=0
 Assigns a C-string (char*) value to this Value.
virtual Valueoperator= (const String_type &value)=0
 Assigns a String_type value to this Value.
virtual Valueoperator= (const Real_type value)=0
 Assigns a Real_type value to this Value.
virtual Valueoperator= (const unsigned int value)=0
 Assigns an unsigned int value to this Value.
virtual Valueoperator= (const Integer_type value)=0
 Assigns an Integer_type value to this Value.
virtual Valueoperator= (const int value)=0
 Assigns an int value to this Value.
virtual Valueoperator= (const Value &value)=0
 Assigns another Value to this Value.
bool operator== (const Value &value) const
 Test if this Value is logically equivalent to another Value.
bool operator> (const Value &value) const
 Test if a Value is logically greater than another Value.
bool operator>= (const Value &value) const
 Test if a Value is logically greater than or equal to another Value.
virtual const Valueoperator[] (unsigned int index) const
 Array notation accessor.
virtual Valueoperator[] (unsigned int index)
 Array notation accessor.
Arrayparent () const
 Gets the Value's parent.
std::ostream & print (std::ostream &out) const
 Prints the Value ot an ostream.
void read (Parser &parser)
 Assigns the next Value from a Parser to this Value.
void read (std::istream &in=std::cin)
 Reads an input stream parsed as PVL syntax into this Value.
Arrayroot () const
 Gets the root Array enclosing this Value.
virtual Type type () const =0
 Gets the Type of the Value.
virtual Valuetype (const Type type_code)
 Sets the Type of the Value.
virtual std::string type_name () const =0
 Gets the name for the Type of the Value.
Valueunits (const std::string &units)
 Sets the units description for the Value.
std::string units () const
 Gets the units description for the Value.
 Value (const Value &value)
 Constructs a Value as a copy of another Value.
 Value (const int digits, const int base=10)
 Constructs a Value with specified representation digits.
 Value (const std::string &units="", const int digits=0, const int base=10)
 Constructs a Value with optional units and digits specifications.
unsigned int write (std::ostream &out=std::cout, int depth=-1) const
 Writes the Value to an ostream.
virtual ~Value ()
 Virtual destructor.

Static Public Member Functions

static std::string integer_to_string (const Integer_type value, const bool is_signed=SIGNED, const int base=10, const int digits=0)
 Converts an integer value to its string representation.
static std::string real_to_string (const Real_type value, std::ios::fmtflags format=std::ios::showpoint, unsigned int precision=0)
 Converts a floating point Real_type value to its string representation using optional format controls.
static unsigned int string_numeric_base (const std::string &value)
 Attemps to intuit the numeric base of string.
static Integer_type string_to_integer (const std::string &value, const int base=0)
 Converts a string to the integer value it represents.
static Real_type string_to_real (const std::string &value)
 Converts a string to the floating point value it represents.
static std::string type_name (const Type type_code)
 Gets the name for a Type.

Static Public Attributes

static const char *const ID
 Class identification name with source code version and date.
static const bool SIGNED = idaeim::Strings::String::SIGNED
static const bool UNSIGNED = idaeim::Strings::String::UNSIGNED
 Convience constants for setting/testing is_signed.

Protected Attributes

int Base
 The numeric base of the Value.
int Digits
 The number of digits in the Value representation.
ArrayParent
 The Array of which this Value is a member, or NULL if not a member of an Array.
std::string Units
 The units description string.

Friends

class Array


Detailed Description

A Value is a general-purpose, abstract value entity.

There are two Value categories: a primitive Value - Integer, Real or String - has a corresponding type of datum; an Array is a list of Values. A digits member is provided for use in creating a text representation of a primitive Value: the precision of a Numeric Value or the field width of a String. A base member is also provided for specifying the radix in creating a text representation of a numeric Value. A pointer to a parent value is provided for navigating Array hierachies; a Value with no parent is not a member of an Array. Arrays list may have Values of mixed types and contain Arrays of mixed sizes.

Numeric Values can be directly converted to/from their primitive datum types. This enables them to be used in mathematical expressions. A String, when it represents a numerical value, can also be converted to an integer or real data type. And, of course, a String can be directly converted to/from a std::string. A set of logical operators is also provided for all Values so they can be meaningfully compared.

N.B.: The storage precision of Integer and Real values is determined at the time the PVL library is compiled by the High_Precision_Integer_type (and High_Precision_Unsigned_Integer_type) and High_Precision_Floating_Point_type typedefs defined in the Utility/Types.hh file. These are expected to be either long or long long and double or long double, respectively. To ensure complete type conversion coverage is provided the idaeim_LONG_LONG_INTEGER is defined if long long is used and idaeim_LONG_DOUBLE is defined if long double is used. The storage precision of an Integer Value is independent of the storage precision of a Real Value.

Any Value, including an Array, may have a units string that provides an arbitrary description for the Value. Provision is made for a Value to inherit the units of its parent.

A Parser is used for interpreting the Parameter Value Language syntax from text into Value objects. A Lister is used for generating Parameter Value Language syntax from Value objects.

See also:
Integer

Real

String

Array

Parameter

Parser

Lister

Author:
Bradford Castalia
1.39

Member Typedef Documentation

Integer Value Datum type.

See also:
Types.hh

typedef std::string String_type

String Value datum type.


Member Enumeration Documentation

enum Type

Subtype identifiers.

There are four specific implementations of Value: Integer, Real, String and Array. However, a String and Array can also be distinguished in the way they are represented with the PVL syntax. Since this distinction is not functional - in fact is a characteristic that can be readily changed within the specific type

  • additional subclasses are not used. Instead, a Type code is provided and used as a "subtype" characteristic, in addition to offering a convenient means of identifying the general type (class) of a Value.

The STRING Type codes are:

>
IDENTIFIER
Unquoted
SYMBOL
Single-quoted (')
TEXT
Double-quoted (")
DATE_TIME
Contains a dash (-) or colon (:)

The ARRAY Type codes are:

>
SET
Enclosed by curly braces ('{' and '}') or no enclosing characters
SEQUENCE
Enclosed by parentheses ('(' and ')')

INTEGER and REAL Type codes are also provided for the Integer and Real classes for consistency. These latter two classes are both categorized as NUMERIC as an aid to the application in identifying how it will use a Value.

Type specification codes are bit flags. These are organized such that the general Type bit is present for all specific members: Both INTEGER and REAL contain the NUMERIC bit; IDENTIFIER, SYMBOL, TEXT and DATE_TIME contain the STRING bit; and both SET and SEQUENCE contain the ARRAY bit.

Note: Value Type codes are guaranteed to be distinct from Parameter Type codes: they occupy completely separate bit fields and can not be accidently confused.

Enumerator:
NUMERIC 
INTEGER 
REAL 
STRING 
IDENTIFIER 
SYMBOL 
TEXT 
DATE_TIME 
ARRAY 
SET 
SEQUENCE 

anonymous enum

The range of allowable radix base values.

Enumerator:
MIN_BASE 
MAX_BASE 


Constructor & Destructor Documentation

Value ( const std::string &  units = "",
const int  digits = 0,
const int  base = 10 
) [inline]

Constructs a Value with optional units and digits specifications.

Parameters:
units The units string.
digits The precision of the value text representation. Zero means unpadded (6 digit floatingpoint).
base The numeric base of value text representation. If the base is not in the range MIN_BASE (2) to MAX_BASE (36), inclusive, base 0 (no base) will be used.

Value ( const int  digits,
const int  base = 10 
) [inline, explicit]

Constructs a Value with specified representation digits.

Parameters:
digits The precision of the value text representation. Zero means unpadded (6 digit floatingpoint).
base The numeric base of value text representation. If the base is not in the range MIN_BASE (2) to MAX_BASE (36), inclusive, base 0 (no base) will be used.

Value ( const Value value  )  [inline]

Constructs a Value as a copy of another Value.

N.B.: The Parent is not copied; the new Value has no parent.

Parameters:
value The Value to copy.

virtual ~Value (  )  [inline, virtual]

Virtual destructor.


Member Function Documentation

virtual Value* clone (  )  const [pure virtual]

Creates a Value clone of the Value.

This method is required by the Array Vectal.

See also:
Vectal

Implemented in Integer, Real, String, and Array.

Array* parent (  )  const [inline]

Gets the Value's parent.

Note: The parent of a Value should only be set by entering the Value into an Array Value; it should only be cleared by removing the Value from its Array.

Returns:
A pointer to the parent Array (NULL if the value has no parent).
See also:
Array::entering(Value*)

Array::removing(Value*)

References Value::Parent.

Referenced by Value::root(), and idaeim::PVL::sort().

Array * root (  )  const

Gets the root Array enclosing this Value.

Returns:
A pointer to the root parent Array; i.e. the base of the parent hierarchy for this Value. This will be NULL if this Value has no parent.

References Value::Parent, and Value::parent().

virtual operator int (  )  const [pure virtual]

Casts the Value to an int.

See also:
Integer::operator int

Real::operator int

String::operator int

Array::operator int

Implemented in Integer, Real, String, and Array.

Referenced by Value::operator unsigned int().

operator unsigned int (  )  const [inline]

Casts the Value to an unsigned int.

See also:
operator int()

References Value::operator int().

virtual operator Integer_type (  )  const [pure virtual]

Casts the Value to an Integer_type.

See also:
Integer::operator Integer_type

Real::operator Integer_type

String::operator Integer_type

Array::operator Integer_type

Implemented in Integer, Real, String, and Array.

Referenced by String::operator int(), and Value::operator Unsigned_Integer_type().

operator Unsigned_Integer_type (  )  const [inline]

Casts the Value to an Unsigned_Integer_type.

See also:
operator Integer_type()

References Value::operator Integer_type().

virtual operator Real_type (  )  const [pure virtual]

Casts the Value to a Real_type.

See also:
Integer::operator Real_type

Real::operator Real_type

String::operator Real_type

Array::operator Real_type

Implemented in Integer, Real, String, and Array.

virtual operator String_type (  )  const [pure virtual]

Casts the Value to a String_type.

See also:
Integer::operator String_type

Real::operator String_type

String::operator String_type

Array::operator String_type

Implemented in Integer, Real, String, and Array.

virtual bool is_Numeric (  )  const [inline, virtual]

Tests if the Value is an Integer or Real.

Returns:
true if the implementing class is Numeric; false otherwise.

Reimplemented in Integer, and Real.

virtual bool is_Integer (  )  const [inline, virtual]

Tests if the Value is an Integer type.

Returns:
true if the implementing class is an Integer; false otherwise.

Reimplemented in Integer.

Referenced by Lister::write().

virtual bool is_Real (  )  const [inline, virtual]

Tests if the Value is a Real type.

Returns:
true if the implementing class is a Real; false otherwise.

Reimplemented in Real.

Referenced by Real::Real(), and Lister::write().

virtual bool is_String (  )  const [inline, virtual]

Tests if the Value is a String type.

Returns:
true if the implementing class is a String; false otherwise.

Reimplemented in String.

Referenced by Parser::get_parameter(), String::operator=(), Integer::operator=(), String::String(), and Lister::write().

virtual bool is_Identifier (  )  const [inline, virtual]

Tests if the Value is an IDENTIFIER String.

Returns:
true if the implementing class has an IDENTIFIER Type specification; false otherwise.

Reimplemented in String.

virtual bool is_Symbol (  )  const [inline, virtual]

Tests if the Value is a SYMBOL String.

Returns:
true if the implementing class has a SYMBOL Type specification; false otherwise.

Reimplemented in String.

virtual bool is_Text (  )  const [inline, virtual]

Tests if the Value is a TEXT String.

Returns:
true if the implementing class has a TEXT Type specification; false otherwise.

Reimplemented in String.

virtual bool is_Date_Time (  )  const [inline, virtual]

Tests if the Value is a DATE_TIME String.

Returns:
true if the implementing class has a DATE_TIME Type specification; false otherwise.

Reimplemented in String.

virtual bool is_Array (  )  const [inline, virtual]

Tests if the Value is an Array.

Returns:
true if the implementing class is an Array; false otherwise.

Reimplemented in Array.

Referenced by Array::Array(), Array::compare(), String::compare(), Real::compare(), Integer::compare(), Array::operator+=(), String::operator+=(), Real::operator+=(), Integer::operator+=(), Array::operator=(), and Lister::write().

virtual bool is_Set (  )  const [inline, virtual]

Tests if the Value is a SET Array.

Returns:
true if the implementing class has a SET Type specification; false otherwise.

Reimplemented in Array.

virtual bool is_Sequence (  )  const [inline, virtual]

Tests if the Value is a SEQUENCE Array.

Returns:
true if the implementing class has a SEQUENCE Type specification; false otherwise.

Reimplemented in Array.

Value & type ( const Type  type_code  )  [virtual]

Sets the Type of the Value.

Parameters:
type_code The Type to be set.
Returns:
This Value.
See also:
Integer::type(const Type)

Real::type(const Type)

String::type(const Type)

Array::type(const Type)

Reimplemented in String, and Array.

Referenced by Array::Array(), Parser::get_datum(), Array::operator=(), String::operator=(), and String::String().

virtual Type type (  )  const [pure virtual]

Gets the Type of the Value.

See also:
Integer::type()

Real::type()

String::type()

Array::type()

Implemented in Integer, Real, String, and Array.

virtual std::string type_name (  )  const [pure virtual]

string type_name ( const Type  type_code  )  [static]

Gets the name for a Type.

The name of Type is identical to its enum symbol except only the first character is uppercase. If the argument is not a recognized Type, then the name returned will be "Invalid".

Parameters:
type_code A Type code value.
Returns:
A name string for the value.

virtual int base (  )  const [inline, virtual]

Gets the numeric base.

Returns:
The numeric base.

References Value::Base.

Referenced by String::operator=(), Integer::operator=(), String::String(), and Lister::write().

Value & base ( const int  base  )  [virtual]

Sets the numeric base.

As a special case, a base of 0 is accepted for a String. This is interpreted to mean that the base should be intuited from the string representation.

Parameters:
base The numeric base value.
Returns:
This Value.
Exceptions:
Out_of_Range If the base argument is not within the allowable range of MIN_BASE (2) to MAX_BASE (36).
See also:
string_numeric_base(const string&)

Reimplemented in Real, and Array.

virtual bool is_signed (  )  const [inline, virtual]

Tests if the Value is signed.

Returns:
true (SIGNED) if the Value is to be treated as signed; false (UNSIGNED) if the value is to be treated as unsigned. Unless a specific class overrides this method it will always return true.

Reimplemented in Integer.

Referenced by Integer::operator=().

virtual Value& is_signed ( const bool  signedness  )  [inline, virtual]

Sets the signed-ness of the Value.

Unless a specific class overrides this method it does nothing.

Parameters:
signedness true (SIGNED) or false (UNSIGNED).
Returns:
This Value.

Reimplemented in Integer.

std::string units (  )  const [inline]

Gets the units description for the Value.

Returns:
The units string for the Value. The string will be empty if the Value has no units associated with it.

References Value::Units.

Referenced by Parser::get_value(), Array::operator=(), String::operator=(), Real::operator=(), Integer::operator=(), and Lister::write().

std::string nearest_units (  )  const

Gets the "nearest" units description for the Value.

The units string of the Value is returned. However, if the units string is empty and the Value is a member of an Array, then the units of the parent Array will be recursively sought. The effect is to return the "nearest" non-empty units string, if there is one.

Returns:
The units string for the Value or, recursively for the parent Array (if there is one) if the units string is empty. The string will be empty if, and only if, neither the Value nor any of its parents have units associated with it.

References Value::nearest_units(), Value::Parent, and Value::Units.

Referenced by Value::nearest_units(), and Lister::value_units().

Value& units ( const std::string &  units  )  [inline]

Sets the units description for the Value.

Parameters:
units The units string to be associated with the Value. The string is copied into the Value.
Returns:
This Value.

References Value::Units.

int digits (  )  const [inline]

Gets the number of digits for the Value representation.

Returns:
The number of digits.

References Value::Digits.

Referenced by String::operator=(), Real::operator=(), Integer::operator=(), and Lister::write().

Value& digits ( const int  digits  )  [inline]

Sets the number of digits for the Value representation.

How the number of digits is used is the responsibility of the specific type of Value.

Parameters:
digits The number of Value digits.
Returns:
This Value.
See also:
integer_to_string

real_to_string

References Value::Digits.

Value & operator[] ( unsigned int  index  )  [virtual]

Array notation accessor.

Parameters:
index The Array element to reference.
Returns:
A reference to the index-th Array element.
Exceptions:
Invalid_Argument If the Value is not an Array.
See also:
Array::operator[]

Reimplemented in Array.

Referenced by Array::operator[]().

const Value & operator[] ( unsigned int  index  )  const [virtual]

Array notation accessor.

Parameters:
index The Array element to reference.
Returns:
A const reference to the index-th Array element.
Exceptions:
Invalid_Argument If the Value is not an Array.
See also:
Array::operator[]

Reimplemented in Array.

virtual Value& operator= ( const Value value  )  [pure virtual]

virtual Value& operator= ( const int  value  )  [pure virtual]

Assigns an int value to this Value.

Parameters:
value The int value to be assigned.
See also:
Integer::operator=(const int)

Real::operator=(const int)

String::operator=(const int)

Array::operator=(const int)

Implemented in Integer, Real, String, and Array.

virtual Value& operator= ( const Integer_type  value  )  [pure virtual]

Assigns an Integer_type value to this Value.

Parameters:
value The Integer_type value to be assigned.
See also:
Integer::operator=(const Integer_type)

Real::operator=(const Integer_type)

String::operator=(const Integer_type)

Array::operator=(const Integer_type)

Implemented in Integer, Real, String, and Array.

virtual Value& operator= ( const unsigned int  value  )  [pure virtual]

Assigns an unsigned int value to this Value.

Parameters:
value The unsigned int value to be assigned.
See also:
Integer::operator=(const unsigned int)

Real::operator=(const unsigned int)

String::operator=(const unsigned int)

Array::operator=(const unsigned int)

Implemented in Integer, Real, String, and Array.

virtual Value& operator= ( const Real_type  value  )  [pure virtual]

Assigns a Real_type value to this Value.

Parameters:
value The Real_type value to be assigned.
See also:
Integer::operator=(const Real_type)

Real::operator=(const Real_type)

String::operator=(const Real_type)

Array::operator=(const Real_type)

Implemented in Integer, Real, String, and Array.

virtual Value& operator= ( const String_type value  )  [pure virtual]

Assigns a String_type value to this Value.

Parameters:
value The String_type value to be assigned.
See also:
Integer::operator=(const String_type)

Real::operator=(const String_type)

String::operator=(const String_type)

Array::operator=(const String_type)

Implemented in Integer, Real, String, and Array.

virtual Value& operator= ( const char *  value  )  [pure virtual]

Assigns a C-string (char*) value to this Value.

Parameters:
value The C-string value to be assigned.
See also:
Integer::operator=(const char*)

Real::operator=(const char*)

String::operator=(const char*)

Array::operator=(const char*)

Implemented in Integer, Real, String, and Array.

virtual Value& operator+= ( const Value value  )  [pure virtual]

Adds another Value to this Value.

The meaning of addition is the responsibility of the specific type of Value.

Parameters:
value The Value to be added.
See also:
Integer::operator+=(const Value&)

Real::operator+=(const Value&)

String::operator+=(const Value&)

Array::operator+=(const Value&)

Implemented in Integer, Real, String, and Array.

virtual int compare ( const Value value  )  const [pure virtual]

Logically compares another Value to this Value.

The meaning of the comparison is the responsibility of the specific type of Value.

Parameters:
value The Value to be compared against.
Returns:
An int that is less than, equal to, or greater than 0 if this Value is logically less than, equal to, or greater than, respectively, the other Value.
See also:
Integer::compare(const Value&) const

Real::compare(const Value&) const

String::compare(const Value&) const

Array::compare(const Value&) const

Implemented in Integer, Real, String, and Array.

Referenced by Value::operator!=(), Value::operator<(), Value::operator<=(), Value::operator==(), Value::operator>(), and Value::operator>=().

bool operator== ( const Value value  )  const [inline]

Test if this Value is logically equivalent to another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

bool operator< ( const Value value  )  const [inline]

Test if this Value is logically less than another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

bool operator!= ( const Value value  )  const [inline]

Test if a Value is logically not equivalent to another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

bool operator> ( const Value value  )  const [inline]

Test if a Value is logically greater than another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

bool operator<= ( const Value value  )  const [inline]

Test if a Value is logically less than or equal to another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

bool operator>= ( const Value value  )  const [inline]

Test if a Value is logically greater than or equal to another Value.

Parameters:
value The Value to compare against.
Returns:
true or false based on how the Values compare.
See also:
compare(const Value&) const

References Value::compare().

unsigned int write ( std::ostream &  out = std::cout,
int  depth = -1 
) const

Writes the Value to an ostream.

N.B.: The output is not terminated with an end-of-line. It is, however, flushed to the ostream.

Parameters:
out The ostream to which the PVL syntax will be written.
depth The indent depth to be applied to Array Values. A negative depth disables indenting.
Returns:
The number of characters written.
See also:
Lister::write(const Value&, int)

References Lister::flush(), and Lister::write().

Referenced by Value::print().

std::ostream& print ( std::ostream &  out  )  const [inline]

Prints the Value ot an ostream.

The Value is written to the stream with no indenting.

Parameters:
out The ostream to which the PVL syntax will be written.
Returns:
The ostream.
See also:
write(std::ostream&, int) const

References Value::write().

void read ( std::istream &  in = std::cin  ) 

Reads an input stream parsed as PVL syntax into this Value.

A Parser is constructuced from the input stream and used to obtain the next Value interpreted from PVL syntax in the stream.

Parameters:
in The istream to be parsed for PVL syntax.
See also:
read(Parser&)

Referenced by idaeim::PVL::operator>>().

void read ( Parser parser  ) 

Assigns the next Value from a Parser to this Value.

The next Value interpreted from PVL syntax is obtained from the Parser. The Value obtained is assigned to this Value.

Warning: Unless the next PVL item available to the Parser is a Value, this method will fail. Also, the type of Value obtained by the must be assignable to this Value or the method will fail. Any type of Value may be assigned to an Array.

Parameters:
parser The Parser from which to obtain a Value.
See also:
operator=(const Value&)

Parser.get_value()

References Parser::get_value().

string integer_to_string ( const Integer_type  value,
const bool  is_signed = SIGNED,
const int  base = 10,
const int  digits = 0 
) [static]

Converts an integer value to its string representation.

Parameters:
value The Integer_type value to be converted.
is_signed Either SIGNED or UNSIGNED.
base The numeric base interpretation of the string representation. A base of 0 is the same as base 10.
digits The number of digits in the representation. The string will be padded with leading 0's as needed.
See also:
is_signed(bool)

idaeim::Strings::String(long, bool, int, int)

Referenced by Integer::operator String_type(), and Lister::write().

Value::Integer_type string_to_integer ( const std::string &  value,
const int  base = 0 
) [static]

Converts a string to the integer value it represents.

If the numeric base is 0, it will be intuited from the string: a leading sign is ignored; a leading "0x" or "0X" indicates hexadecimal (base 16) notation, a leading '0' alone indicates octal (base 8) notation, while anything else is taken to be decimal notation. To prevent padding with leading '0' characters to be interpreted as octal specify the base.

A conversion that succeeds up to a decimal point character ('.') is accepted as a real number representation truncated to an integer. Thus the conversion can be fooled by an otherwise invalid string.

Leading and trailing whitespace in the string is ignored.

Parameters:
value The string representation of the value to be converted.
base The numeric base interpretation of the string representation.
Returns:
The Integer_type that the string represents.
Exceptions:
Out_of_Range If the value represented is out of the range of what can be represented by an Integer_type.
Invalid_Value If the value does not represent a numeric value.
See also:
string_numeric_base

References Value::ID, and STRTOL.

Referenced by String::operator Integer_type().

unsigned int string_numeric_base ( const std::string &  value  )  [static]

Attemps to intuit the numeric base of string.

Leading whitespace is ignored and, after any whitespace, a leading sign character ('+' or '-') is also ignored; a leading "0x" or "0X" indicates hexadecimal (base 16) notation, a leading '0' alone indicates octal (base 8) notation, while anything else is taken to be decimal notation.

An internal test conversion based on the tentative surmise of the base representation is attempted. If the conversion fails a value of 0 is returned indicating that the string does not represent a numeric value. An empty string is defined as base 10.

Parameters:
value The string to interpret.
Returns:
The numeric base of the value the string represents, or 0 if the string does not represent a value.
See also:
string_to_integer

References Parser::WHITESPACE.

string real_to_string ( const Real_type  value,
std::ios::fmtflags  format = std::ios::showpoint,
unsigned int  precision = 0 
) [static]

Converts a floating point Real_type value to its string representation using optional format controls.

The real value representation is generated by an ostringstream. If format flags and/or a precision value is specified they are applied to the ostringstream. N.B.: The showpoint format flag is always applied. If a non-zero precision is specified, it is also applied; otherwise, if neither the fixed nor scientific format flags are specified, at least one digit after the decimal point will be used.

Parameters:
value The Real_type value to be converted.
format The fmtflags to be applied to the conversion.
precision An unsigned int precision value to be applied to the conversion (0 implies default precision).
Returns:
A string representation of the value.

Referenced by Real::operator String_type(), and Lister::write().

Value::Real_type string_to_real ( const std::string &  value  )  [static]

Converts a string to the floating point value it represents.

Leading and trailing whitespace in the string is ignored.

Parameters:
value The string value to be converted.
Returns:
The Real_type that the string represents.
Exceptions:
Out_of_Range If the value represented is out of the range of what can be represented by an Real_type.
Invalid_Value If the value does not represent a numeric value.

References Value::ID, and STRTOD.

Referenced by String::operator Real_type().


Friends And Related Function Documentation

friend class Array [friend]

Referenced by Array::clone().


Member Data Documentation

const char *const ID [static]

Convience constants for setting/testing is_signed.

Referenced by Integer::operator=(), and Lister::write().

const bool SIGNED = idaeim::Strings::String::SIGNED [static]

Array* Parent [protected]

The Array of which this Value is a member, or NULL if not a member of an Array.

Referenced by Array::entering(), Value::nearest_units(), Value::parent(), Array::removing(), and Value::root().

std::string Units [protected]

The units description string.

See also:
units(const std::string&)

Referenced by Value::nearest_units(), and Value::units().

int Digits [protected]

The number of digits in the Value representation.

See also:
digits(const int)

Referenced by Value::digits(), Real::operator String_type(), and Integer::operator String_type().

int Base [protected]


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

Generated on Mon Oct 12 19:59:47 2009 for PVL by  doxygen 1.5.8