GL Studio C++ Runtime API
DistiAttribDict Class Referencefinal

#include <disti_metadata.h>

Public Types

typedef DistiAttributeBaseAttr_t
 
typedef std::list< Attr_tList_t
 Typedef for a list of attribute pointers.
 
typedef std::multimap< long, Attr_tMap_t
 Typedef for a map ot attribute pointers.
 
typedef List_t::const_iterator const_iterator
 Shorthand for List_t::const_iterator.
 
typedef List_t::iterator iterator
 Shorthand for List_t::iterator.
 

Public Member Functions

 DistiAttribDict ()
 
 ~DistiAttribDict ()
 
 DistiAttribDict (DistiAttribDict &&other)
 
DistiAttribDictoperator= (DistiAttribDict &&other)
 
DistiAttribDictoperator= (const DistiAttribDict &dict)
 
void CopyCommonValues (const DistiAttribDict &dict)
 
bool operator== (const DistiAttribDict &other)
 
void Add (DistiAttributeBase *attr)
 
const_iterator Begin () const
 
const_iterator End () const
 
iterator Begin ()
 
iterator End ()
 
int Count () const
 
int Count (const AttributeName &name) const
 
void Clear ()
 
void Delete (const AttributeName &name)
 
void ReadStrings (std::istream &instr)
 
void Write (std::ostream &outstr, bool changedDataOnly=false)
 
bool Read (std::istream &instr)
 
bool ReadAndCaptureMissing (std::istream &instr, std::stringstream *missingStream)
 
std::string ValueString (const AttributeName &name) const
 
void ValueString (const AttributeName &name, const std::string &val)
 
long ValueInt (const AttributeName &name) const
 
void ValueInt (const AttributeName &name, long val)
 
std::ostream & WriteValue (const AttributeName &name, std::ostream &outstr)
 
std::istream & ReadValue (const AttributeName &name, std::istream &instr)
 
DistiAttributeBaseGet (const AttributeName &name) const
 
bool IsEqual (const AttributeName &name, const long val) const
 
void Remove (const AttributeName &name)
 

Static Public Member Functions

static void SpacingInc ()
 
static void SpacingDec ()
 
static void SpacingZero ()
 
static std::string SpacingString ()
 
static bool ScanToken (std::istream &instr, std::string &result)
 

Static Public Attributes

static unsigned int _currentFileVersionMajor
 
static unsigned int _currentFileVersionMinor
 
static unsigned int _currentFileVersionBuild
 
static double _currentFileVersionPrimary
 
static long _currentFileVersionSecondary
 
static int currentOutputSpacing
 

Detailed Description

The Attribute Dictionary is a container for DistiAttributeBase derived objects

Member Typedef Documentation

◆ Attr_t

Allows for easy access to the contained class type

Constructor & Destructor Documentation

◆ DistiAttribDict() [1/2]

Constructor

◆ ~DistiAttribDict()

Destructor

◆ DistiAttribDict() [2/2]

DistiAttribDict ( DistiAttribDict &&  other)
inline

Move constructor

Parameters
otherThe object to move.

Member Function Documentation

◆ Add()

void Add ( DistiAttributeBase attr)

Adds the specified Attribute to the list. The object passed in becomes the responsibility of this class, and should NOT be deleted by the caller. It will be deleted by this class as needed.

Parameters
attrThe attribute to add.

◆ Begin() [1/2]

iterator Begin ( )
inline
Returns
A iterator to the beginning of the list.

◆ Begin() [2/2]

const_iterator Begin ( ) const
inline
Returns
A const iterator to the beginning of the list.

◆ Clear()

void Clear ( )

Removes all elements in the list, deleting the data as it goes

◆ CopyCommonValues()

void CopyCommonValues ( const DistiAttribDict dict)

Copies the values for all items which have matching names between this object and dict. All other values are ignored.

Parameters
dictThe dictionary to copy from.

◆ Count() [1/2]

int Count ( ) const
Returns
The current number of elements in the dictionary.

◆ Count() [2/2]

int Count ( const AttributeName name) const
Parameters
nameThe name of the element(s) to count up.
Returns
The number of elements with the same name in the dictionary.

◆ Delete()

void Delete ( const AttributeName name)

Removes the attribute specified by name from the dictionary and deletes the data.

Parameters
nameThe name of the attribute to remove.
Note
This does actually delete the attribute.

◆ End() [1/2]

iterator End ( )
inline
Returns
A iterator to the end of the list.

◆ End() [2/2]

const_iterator End ( ) const
inline
Returns
A const iterator to the end of the list.

◆ Get()

DistiAttributeBase * Get ( const AttributeName name) const
Parameters
nameThe name of the attribute to return.
Returns
The DistiAttributeBase* for the specified name, if not found it returns NULL.

◆ IsEqual()

bool IsEqual ( const AttributeName name,
const long  val 
) const
Parameters
nameThe name of the attribute to compare.
valThe value to compare the attribute value with.
Returns
A comparison of val with ValueInt() of the attribute looked up by name, false if not found.

◆ operator=() [1/2]

DistiAttribDict & operator= ( const DistiAttribDict dict)
inline

Copies the values for all items which have matching names between this object and dict. All other values are ignored.

Parameters
dictThe dictionary to copy from.
Returns
The combined dictionary (this).
Deprecated:
Use CopyCommonValues() instead.

◆ operator=() [2/2]

DistiAttribDict & operator= ( DistiAttribDict &&  other)
inline

Move Assignment

Parameters
otherThe object to move.
Returns
This object, post move.

◆ operator==()

bool operator== ( const DistiAttribDict other)

Equality operator Compares length, names and values, order does not matter.

Parameters
otherThe other dictionary to compare.
Returns
Whether or not the dictionaries are equivalent.

◆ Read()

bool Read ( std::istream &  instr)

Reads multiple attributes from the stream expecting the form: "NAME: VALUE"

Parameters
instrThe stream to read from.
Returns
True if something was found and set..

◆ ReadAndCaptureMissing()

bool ReadAndCaptureMissing ( std::istream &  instr,
std::stringstream *  missingStream 
)

Reads multiple attributes from the stream expecting the form: "NAME: VALUE" missing stream is filled with attributes that were not in the dictionary

Parameters
instrThe stream to read from.
missingStreamThe return stream to write attributes that were not found.
Returns
True if something was found and set.

◆ ReadStrings()

void ReadStrings ( std::istream &  instr)

Reads a stream, expecting each line to be of the form: NAME: SomeStringValue For each line a new DistiAttribute<std::string> is created, and the remaining line is placed as it's value. This is intended for special uses and is not considered the 'normal' mode of operation.

Parameters
instrThe stream to read from.

◆ ReadValue()

std::istream & ReadValue ( const AttributeName name,
std::istream &  instr 
)

Calls ReadValue() for the attribute specified by name.

Parameters
nameThe name of the attribute to read in.
instrThe stream to read from.
Returns
The stream that was read from, in its current state.

◆ Remove()

void Remove ( const AttributeName name)

Removes the attribute specified by name.

Parameters
nameThe name of the attribute to remove.
Note
This does NOT actually delete the attribute, just removes it from the dictionary.

◆ ScanToken()

static bool ScanToken ( std::istream &  instr,
std::string &  result 
)
static

Static method used for parsing a stream. Used internally and exposed here so others can use it.

Parameters
instrThe stream to read from.
resultThe returned string that was parsed.
Returns
True if parse was successful.

◆ SpacingDec()

static void SpacingDec ( )
static

Static, Decrements the current spacing

◆ SpacingInc()

static void SpacingInc ( )
static

Static, Increments the current spacing

◆ SpacingString()

static std::string SpacingString ( )
static
Note
static
Returns
A string containing the current spacing.

◆ SpacingZero()

static void SpacingZero ( )
static

Static, Sets the spacing to zero

◆ ValueInt() [1/2]

long ValueInt ( const AttributeName name) const
Parameters
nameThe name of the attribute whose value is to be returned.
Returns
The ValueInt() of the named attribute.

◆ ValueInt() [2/2]

void ValueInt ( const AttributeName name,
long  val 
)

Sets the ValueInt() of the named attribute.

Parameters
nameThe attribute name whose value is to be set.
valThe int value to set.

◆ ValueString() [1/2]

std::string ValueString ( const AttributeName name) const
Parameters
nameThe name of the attribute whose value is to be returned.
Returns
The std::string value of the attribute specified by name, "" if not found.
Note
Internally it uses ValueString() from the attribute

◆ ValueString() [2/2]

void ValueString ( const AttributeName name,
const std::string &  val 
)

Sets the attribute of named 'name' to the value of 'val'.

Parameters
nameThe attribute name whose value is to be set.
valThe string value to set.
Note
If name is not found, there is no indication or error given.

◆ Write()

void Write ( std::ostream &  outstr,
bool  changedDataOnly = false 
)

Writes all items in the dictionary to the stream in the form: "NAME: VALUE" If changedDataOnly is true, only items which return ValueChanged() == true will be written.

Parameters
outstrThe stream to write to.
changedDataOnlyWhether or not to only write items where ValueChanged() == true.

◆ WriteValue()

std::ostream & WriteValue ( const AttributeName name,
std::ostream &  outstr 
)

Calls WriteValue() for the attribute specified by name.

Parameters
nameThe name of the attribute to write out.
outstrThe stream to write to.
Returns
The stream that was written to, in its current state.

Member Data Documentation

◆ _currentFileVersionBuild

unsigned int _currentFileVersionBuild
static

◆ _currentFileVersionMajor

unsigned int _currentFileVersionMajor
static

Used as needed for version specific parsing Whenever a version is parsed, the results should be stored here. This does add order dependency.

Note: These are not set or used by the DistiAttribDict class they are here to be set and accessed by the derived Attributes. Since they are shared by all instances of DistiAttribDict, they are only valid while the dictionary is parsing a file.

◆ _currentFileVersionMinor

unsigned int _currentFileVersionMinor
static

◆ _currentFileVersionPrimary

double _currentFileVersionPrimary
static
Deprecated:
Do not use. Will be removed in a later version.

◆ _currentFileVersionSecondary

long _currentFileVersionSecondary
static
Deprecated:
Do not use. Will be removed in a later version.

◆ currentOutputSpacing

int currentOutputSpacing
static

Static, data for formating output


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