C++ API Reference
Index Class Reference

Lightweight class handling index values. More...

#include <adskDataIndex.h>

Public Types

typedef Index(* IndexCreator) (const std::string &)
 Further data for complex index types.
 

Public Member Functions

 Index (IndexCount value)
 Conversion constructor. More...
 
 Index (const Index &rhs)
 Copy constructor, simplest level. More...
 
 Index (const IndexType &rhs)
 Conversion constructor. More...
 
 Index (const std::string &indexValue)
 Constructor based on an index value in a string. More...
 
 ~Index ()
 Default destructor, release the ComplexIndex if there is one.
 
Indexoperator= (IndexCount rhs)
 IndexCount assignment operator. More...
 
Indexoperator= (const Index &rhs)
 Class assignment operator. More...
 
 operator IndexCount () const
 IndexCount cast operator.
 
IndexCount index () const
 IndexCount extraction. More...
 
 operator IndexType * ()
 IndexType* cast operator.
 
std::string asString () const
 Get the Index in string form. More...
 
IndexTypecomplexIndex ()
 Quick access to the complex index, if it's used. More...
 
bool supportsDenseMode () const
 Notifies users that this index type can be packed densely. More...
 
IndexCount denseSpaceBetween (const Index &rhs) const
 Calculate the dense space occupied between two indices. More...
 
bool operator== (const Index &rhs) const
 Equality operator, checks if this Index is the same as another. More...
 
bool operator!= (const Index &rhs) const
 Inequality operator, checks if this Index is not the same as another. More...
 
bool operator< (const Index &rhs) const
 Less-than operator, checks if this Index is less than another Put simple index types before complex ones. More...
 
bool operator<= (const Index &rhs) const
 Less-or-equal operator, checks if this Index is <= another Put simple index types before complex ones. More...
 
bool operator> (const Index &rhs) const
 Greater-than operator, checks if this Index is greater than another Put simple index types before complex ones. More...
 
bool operator>= (const Index &rhs) const
 Greater-or-equal operator, checks if this Index is >= another Put simple index types before complex ones. More...
 
std::string typeName () const
 Get the type name of this object. More...
 

Static Public Member Functions

static bool Debug (const Index *me, Debug::Print &request)
 Answer a Print request for an Index object. More...
 
static bool Debug (const Index *me, Debug::Footprint &request)
 Answer a footprint request for an Index object. More...
 
static Index doCreate (const std::string &, const std::string &)
 Create an Index of a given type from a string description of the value. More...
 
static IndexCreator creator (const std::string &)
 Get a function for construction of a given index type. More...
 
static std::string theTypeName ()
 Get the type name of the simple index type. More...
 

Detailed Description

Lightweight class handling index values.

adsk::Data::Stream objects contain a list of data elements. Each element has to be accessed by index. In the simplest case the index is an array index (of type IndexCount, whose typedef appears above) but there can be more complex cases as well, such as a pair of integers, or a string.

This is the base class used by the adsk::Data:Stream indexing system. It is configured to be as efficient as possible in the simple index case while allowing extension to arbitrary index types. The simple integer index value is contained within this class. More complex index types are stored in a letter class of type "IndexType".

It can be used as the basis of a mapping from a general index type onto an adsk::Data::Index value, used for data referencing. Its purpose is to overload the concept of a general std::map<Index, Index> so that in the simple case where Index is the same as Index no mapping is required. The calling classes are responsible for creating that relationship, the methods in this class are defined to support that use.

Examples:
MetadataXML/streamSerializerXML.cpp.

Constructor & Destructor Documentation

Index ( IndexCount  rhs)

Conversion constructor.

Parameters
[in]rhsIndexCount value to be copied
Index ( const Index rhs)

Copy constructor, simplest level.

Parameters
[in]rhsIndex data to be copied
Index ( const IndexType rhs)

Conversion constructor.

Parameters
[in]rhsComplexIndex value to be copied
Index ( const std::string &  value)

Constructor based on an index value in a string.

Parameters
[in]valueIndex value for construction, must be a single numeric value
Exceptions
Index::kBadSyntaxNon-numeric values present, or no number present
Index::kExcessDataMore than just a single number present

Member Function Documentation

Index & operator= ( IndexCount  rhs)

IndexCount assignment operator.

Parameters
[in]rhsIndexCount value to be copied
Index & operator= ( const Index rhs)

Class assignment operator.

Parameters
[in]rhsIndex data to be copied
IndexCount index ( ) const

IndexCount extraction.

Returns
Single array index associated with this Index
Examples:
MetadataXML/streamSerializerXML.cpp.
std::string asString ( ) const

Get the Index in string form.

Returns
String representing the index value (in the same form expected by the creator functions)
Examples:
MetadataXML/streamSerializerXML.cpp.
IndexType * complexIndex ( )
inline

Quick access to the complex index, if it's used.

Returns
Pointer to the complex index type, or NULL if the index is simple
bool supportsDenseMode ( ) const

Notifies users that this index type can be packed densely.

Returns
ComplexIndex dense support if it exists, otherwise true since the default index type supports density.
IndexCount denseSpaceBetween ( const Index rhs) const

Calculate the dense space occupied between two indices.

Dense packing of a linear index requires the number of elements between the two indices - easy peasy.

Parameters
[in]rhsThe Index from which the density is to be calculated
Returns
Number of elements betweeen this one and the parameter, including both of the endpoints. Returns 0 if the dense packing cannot be supported.
bool operator== ( const Index rhs) const

Equality operator, checks if this Index is the same as another.

Parameters
[in]rhsIndex to be compared
Returns
true if the two Index objects have the same underlying IndexCount
bool operator!= ( const Index rhs) const

Inequality operator, checks if this Index is not the same as another.

Parameters
[in]rhsIndex to be compared
Returns
true if the two Index objects have a different underlying IndexCount
bool operator< ( const Index rhs) const

Less-than operator, checks if this Index is less than another Put simple index types before complex ones.

Parameters
[in]rhsIndex to be compared
Returns
true if this Index's counter is less than rhs's
bool operator<= ( const Index rhs) const

Less-or-equal operator, checks if this Index is <= another Put simple index types before complex ones.

Parameters
[in]rhsIndex to be compared
Returns
true if this Index's counter is less than or equal to rhs's
bool operator> ( const Index rhs) const

Greater-than operator, checks if this Index is greater than another Put simple index types before complex ones.

Parameters
[in]rhsIndex to be compared
Returns
true if this Index's counter is greater than rhs's
bool operator>= ( const Index rhs) const

Greater-or-equal operator, checks if this Index is >= another Put simple index types before complex ones.

Parameters
[in]rhsIndex to be compared
Returns
true if this Index's counter is greater than or equal to rhs's
bool Debug ( const Index me,
Debug::Print request 
)
static

Answer a Print request for an Index object.

Use the request object to dump all information on the "me" Index, or all static Index information if "me" is NULL.

Parameters
[in]mePointer to object to debug, NULL means class static
[out]requestPrint request object
Returns
True if the request was successfully processed.
bool Debug ( const Index me,
Debug::Footprint request 
)
static

Answer a footprint request for an Index object.

Populate the Footprint request with the information on all data stored within this class if "me" is NULL, otherwise the information stored in the Index object pointed at by "me".

Parameters
[in]mePointer to object to footprint, NULL means class static
[out]requestFootprint object to populate
Returns
True if the request was successfully processed. The Footprint object will have all information added to it.
Index doCreate ( const std::string &  typeName,
const std::string &  value 
)
static

Create an Index of a given type from a string description of the value.

If the creation failed for any reason, e.g. unrecognized type or invalid string value, then an exception is thrown.

Parameters
[in]typeNameName of the Index type
[in]valueString which defines the Index value
Returns
True if the request was successfully processed.
Index::IndexCreator creator ( const std::string &  typeName)
static

Get a function for construction of a given index type.

Although the doCreate() method will create any type of index from a pair of strings when you are processing a whole series of index values of the same type there is no need to re-parse the type name for every index. In those cases you can access the creation function directly with this method and then call it repeatedly with the set of value strings. (e.g. in file I/O)

Parameters
[in]typeNameName of the Index type for eventual construction
Returns
Function that will construct an index of the given type from a string with its value.
Examples:
MetadataXML/streamSerializerXML.cpp.
std::string theTypeName ( )
static

Get the type name of the simple index type.

Other index types require creation of a complex member.

Returns
String with the simple index type name
std::string typeName ( ) const

Get the type name of this object.

If it's a simple type then the type name is this object's name, otherwise it's the name of the fComplexIndex member.

Returns
String with this index type's name

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