HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFSharedStringTuple Class Referenceabstract

A specialization of GA_AIFStringTuple to access "shared strings". More...

#include <GA_AIFSharedStringTuple.h>

+ Inheritance diagram for GA_AIFSharedStringTuple:

Classes

class  iterator
 Class to iterate over all the strings in the shared string table. More...
 
class  StringBuffer
 Temporary container to hold references to multiple strings. More...
 

Public Member Functions

 GA_AIFSharedStringTuple ()
 
 ~GA_AIFSharedStringTuple () override
 
virtual bool getStatistics (const GA_Attribute *attrib, GA_StringTableStatistics &stats) const =0
 Query information about the string storage. More...
 
virtual bool compactStorage (GA_Attribute *attrib) const =0
 Compact the string storage. More...
 
virtual bool extractStrings (const GA_Attribute *attrib, UT_StringArray &strings, UT_IntArray &handles) const =0
 
virtual bool extractStrings (const GA_Attribute *attrib, UT_StringArray &strings, UT_IntArray &handles, exint maxstrings) const =0
 Stop after reaching a maximum. More...
 
virtual bool extractHandles (const GA_Attribute *attrib, UT_IntArray &handles) const =0
 
GA_Size getTableEntries (const GA_Attribute *attrib) const
 Return the number of entries in the shared string table. More...
 
virtual GA_StringIndexType validateTableHandle (const GA_Attribute *attrib, GA_StringIndexType index) const =0
 
virtual const char * getTableString (const GA_Attribute *attrib, GA_StringIndexType handle) const =0
 Get a string from the string table (without going through an attribute) More...
 
virtual GA_StringIndexType getTableHandle (const GA_Attribute *attrib, const char *string) const =0
 
virtual const char * getTableOrderedString (const GA_Attribute *a, exint index) const =0
 
virtual bool replaceTableString (GA_Attribute *attrib, GA_StringIndexType handle, const char *string) const =0
 
iterator begin (const GA_Attribute *a) const
 
iterator end () const
 
int getTupleSize (const GA_Attribute *attrib) const override=0
 Query the tuple size. More...
 
bool setTupleSize (GA_Attribute *attrib, int size) const override=0
 Set the tuple size. More...
 
const char * getString (const GA_Attribute *attrib, GA_Offset ai, int tuple_index=0) const override
 Get a single string from the array for a single tuple of an element. More...
 
virtual GA_StringIndexType getHandle (const GA_Attribute *attrib, GA_Offset ai, int tuple_index=0) const =0
 Get the handle from the array for a single tuple of an element. More...
 
virtual bool getHandles (const GA_Attribute *attrib, GA_Offset ai, GA_StringIndexType *handles, int count, int start=0) const
 Get the full tuple of indices for a single element. More...
 
bool setString (GA_Attribute *attrib, GA_Offset ai, const char *string, int tuple_index) const override
 Set a single component for a single element. More...
 
bool setString (GA_Attribute *attrib, const GA_Range &ai, const char *string, int tuple_index) const override
 Set a single component for a range of elements. More...
 
virtual bool setHandle (GA_Attribute *attrib, GA_Offset ai, GA_StringIndexType handle, int tuple_index) const =0
 Set a single component for a single element. More...
 
virtual bool setHandle (GA_Attribute *attrib, const GA_Range &ai, GA_StringIndexType handle, int tuple_index) const
 Set a single component for a range of elements. More...
 
virtual bool setHandles (GA_Attribute *attrib, GA_Offset ai, const GA_StringIndexType *handles, int count, int start=0) const
 Set multiple components for a single element. More...
 
virtual bool setHandles (GA_Attribute *attrib, const GA_Range &ai, const GA_StringIndexType *handles, int count, int start=0) const
 Set multiple components for a range of elements. More...
 
int arrayGetLength (const GA_Attribute *attrib, GA_Offset element_index=GA_Offset(0)) const override
 
int arrayFindString (const GA_Attribute *attrib, const char *string, GA_Offset element_index=GA_Offset(0)) const override
 
bool arrayDestroyString (GA_Attribute *attrib, int string_index, GA_Offset element_index=GA_Offset(0)) const override
 
StringBuffer addStrings (GA_Attribute *attribute, const UT_StringArray &strings) const
 
StringBuffer addStrings (GA_Attribute *attribute, const UT_Array< const char * > &strings) const
 
- Public Member Functions inherited from GA_AIFStringTuple
 GA_AIFStringTuple ()
 
virtual ~GA_AIFStringTuple ()
 
virtual bool getStrings (const GA_Attribute *attrib, GA_Offset ai, UT_StringArray &strings, int count, int start=0) const
 Get the full tuple of string values for a single element. More...
 
virtual bool setStrings (GA_Attribute *attrib, GA_Offset ai, const char **strings, int count, int start=0) const
 Set multiple components for a single element. More...
 
virtual bool setStrings (GA_Attribute *attrib, const GA_Range &ai, const char **strings, int count, int start=0) const
 Set multiple components for a range of elements. More...
 
virtual bool arrayReserve (GA_Attribute *attrib, int length) const
 Reserve space in the array. More...
 
virtual bool arrayTruncate (GA_Attribute *attrib, int length) const
 Truncate the array to the given entries. More...
 
virtual int arrayTrim (GA_Attribute *attrib) const
 
virtual int arrayAppendString (GA_Attribute *attrib, const char *string, GA_Offset element_index=GA_Offset(0)) const
 
virtual int arrayAppendUniqueString (GA_Attribute *attrib, const char *string, GA_Offset element_index=GA_Offset(0)) const
 
virtual int arrayGetMaxLength (const GA_Attribute *attrib, const GA_Range &range) const
 Find the maximum length of all elements in the range. More...
 
virtual const char * arrayGetString (const GA_Attribute *attrib, int string_index, GA_Offset element_index=GA_Offset(0)) const
 
virtual int arrayGetStrings (UT_StringArray &strings, const GA_Attribute *attrib, GA_Offset element_index=GA_Offset(0)) const
 
virtual int arrayRemoveDuplicates (GA_Attribute *attrib, GA_Offset element_index=GA_Offset(0)) const
 

Protected Member Functions

virtual GA_StringIndexType addStringReference (GA_Attribute *attribute, const char *string) const =0
 Add (or increment) reference to a string. More...
 
virtual void delHandleReference (GA_Attribute *attribute, GA_StringIndexType handle) const =0
 Decrement reference to a handle. More...
 

Friends

class StringBuffer
 

Detailed Description

A specialization of GA_AIFStringTuple to access "shared strings".

This class provides the interface to access string table data. Each attribute type may provide this interface if it makes sense.

Definition at line 60 of file GA_AIFSharedStringTuple.h.

Constructor & Destructor Documentation

GA_AIFSharedStringTuple::GA_AIFSharedStringTuple ( )
GA_AIFSharedStringTuple::~GA_AIFSharedStringTuple ( )
override

Member Function Documentation

virtual GA_StringIndexType GA_AIFSharedStringTuple::addStringReference ( GA_Attribute attribute,
const char *  string 
) const
protectedpure virtual

Add (or increment) reference to a string.

StringBuffer GA_AIFSharedStringTuple::addStrings ( GA_Attribute attribute,
const UT_StringArray strings 
) const

Method to add multiple strings in a batch process. The strings will be temporarily added to the attribute for as long as the StringBuffer exists. When the StringBuffer is deleted, the strings will be deleted from the attribute unless referenced by elements in the attribute array.

Information about the strings (i.e. the handles) can be retriefed from the StringBuffer. For example:

handles = a->getAIFSharedStringTuple()->addStrings(s);
for (GA_Size i = 0; i < handles.entries(); ++i)
cerr << s(i) << " handle=" << handles.getStringIndex(i) << endl;
StringBuffer GA_AIFSharedStringTuple::addStrings ( GA_Attribute attribute,
const UT_Array< const char * > &  strings 
) const

Method to add multiple strings in a batch process. The strings will be temporarily added to the attribute for as long as the StringBuffer exists. When the StringBuffer is deleted, the strings will be deleted from the attribute unless referenced by elements in the attribute array.

Information about the strings (i.e. the handles) can be retriefed from the StringBuffer. For example:

handles = a->getAIFSharedStringTuple()->addStrings(s);
for (GA_Size i = 0; i < handles.entries(); ++i)
cerr << s(i) << " handle=" << handles.getStringIndex(i) << endl;
bool GA_AIFSharedStringTuple::arrayDestroyString ( GA_Attribute attrib,
int  string_index,
GA_Offset  element_index = GA_Offset(0) 
) const
overridevirtual

Array API, select functions can be more efficiently implemented using shared strings. Please see GA_AIFStringTuple for remainder of interface

Reimplemented from GA_AIFStringTuple.

int GA_AIFSharedStringTuple::arrayFindString ( const GA_Attribute attrib,
const char *  string,
GA_Offset  element_index = GA_Offset(0) 
) const
overridevirtual

Array API, select functions can be more efficiently implemented using shared strings. Please see GA_AIFStringTuple for remainder of interface

Reimplemented from GA_AIFStringTuple.

int GA_AIFSharedStringTuple::arrayGetLength ( const GA_Attribute attrib,
GA_Offset  element_index = GA_Offset(0) 
) const
overridevirtual

Array API, select functions can be more efficiently implemented using shared strings. Please see GA_AIFStringTuple for remainder of interface

Reimplemented from GA_AIFStringTuple.

iterator GA_AIFSharedStringTuple::begin ( const GA_Attribute a) const
inline

Definition at line 231 of file GA_AIFSharedStringTuple.h.

virtual bool GA_AIFSharedStringTuple::compactStorage ( GA_Attribute attrib) const
pure virtual

Compact the string storage.

virtual void GA_AIFSharedStringTuple::delHandleReference ( GA_Attribute attribute,
GA_StringIndexType  handle 
) const
protectedpure virtual

Decrement reference to a handle.

iterator GA_AIFSharedStringTuple::end ( void  ) const
inline

Definition at line 233 of file GA_AIFSharedStringTuple.h.

virtual bool GA_AIFSharedStringTuple::extractHandles ( const GA_Attribute attrib,
UT_IntArray handles 
) const
pure virtual

Extract all of the unique string handles of the attribute. The string handles are guaranteed to be in ascending order, but may or may not be contiguous.

virtual bool GA_AIFSharedStringTuple::extractStrings ( const GA_Attribute attrib,
UT_StringArray strings,
UT_IntArray handles 
) const
pure virtual

Extract data from the string table. This will extract all the unique strings which are referenced by the attribute. The string handles are guaranteed to be in ascending order, but may or may not be contiguous.

virtual bool GA_AIFSharedStringTuple::extractStrings ( const GA_Attribute attrib,
UT_StringArray strings,
UT_IntArray handles,
exint  maxstrings 
) const
pure virtual

Stop after reaching a maximum.

virtual GA_StringIndexType GA_AIFSharedStringTuple::getHandle ( const GA_Attribute attrib,
GA_Offset  ai,
int  tuple_index = 0 
) const
pure virtual

Get the handle from the array for a single tuple of an element.

virtual bool GA_AIFSharedStringTuple::getHandles ( const GA_Attribute attrib,
GA_Offset  ai,
GA_StringIndexType handles,
int  count,
int  start = 0 
) const
virtual

Get the full tuple of indices for a single element.

virtual bool GA_AIFSharedStringTuple::getStatistics ( const GA_Attribute attrib,
GA_StringTableStatistics stats 
) const
pure virtual

Query information about the string storage.

const char* GA_AIFSharedStringTuple::getString ( const GA_Attribute attrib,
GA_Offset  ai,
int  tuple_index = 0 
) const
overridevirtual

Get a single string from the array for a single tuple of an element.

Implements GA_AIFStringTuple.

GA_Size GA_AIFSharedStringTuple::getTableEntries ( const GA_Attribute attrib) const
inline

Return the number of entries in the shared string table.

Definition at line 98 of file GA_AIFSharedStringTuple.h.

virtual GA_StringIndexType GA_AIFSharedStringTuple::getTableHandle ( const GA_Attribute attrib,
const char *  string 
) const
pure virtual

Get the handle (index) corresponding to the given string, returning -1 if none.

virtual const char* GA_AIFSharedStringTuple::getTableOrderedString ( const GA_Attribute a,
exint  index 
) const
pure virtual

GA_StringIndexType indices may not be contiguous, this method allows you to get a string given an ordered index. Strings will be defined for all contiguous strings. This may be an expensive operation, it's better to access strings by their index if possible.

This method will return a NULL pointer past the end of the string table

virtual const char* GA_AIFSharedStringTuple::getTableString ( const GA_Attribute attrib,
GA_StringIndexType  handle 
) const
pure virtual

Get a string from the string table (without going through an attribute)

int GA_AIFSharedStringTuple::getTupleSize ( const GA_Attribute attrib) const
overridepure virtual

Query the tuple size.

Implements GA_AIFStringTuple.

virtual bool GA_AIFSharedStringTuple::replaceTableString ( GA_Attribute attrib,
GA_StringIndexType  handle,
const char *  string 
) const
pure virtual

Replace a string in the shared string table with a new value. Warning, it's possible that the table will "collapse" after the replacement. For example:

table := [ "foo", "bar" ]
table.replaceString(1, "foo") # Replace "bar" with "foo"
table := [ "foo" ]

In the above example, all elements which originally referenced "bar" will now reference "foo". This means that trying to swap two values will not work as expected.

virtual bool GA_AIFSharedStringTuple::setHandle ( GA_Attribute attrib,
GA_Offset  ai,
GA_StringIndexType  handle,
int  tuple_index 
) const
pure virtual

Set a single component for a single element.

virtual bool GA_AIFSharedStringTuple::setHandle ( GA_Attribute attrib,
const GA_Range ai,
GA_StringIndexType  handle,
int  tuple_index 
) const
virtual

Set a single component for a range of elements.

virtual bool GA_AIFSharedStringTuple::setHandles ( GA_Attribute attrib,
GA_Offset  ai,
const GA_StringIndexType handles,
int  count,
int  start = 0 
) const
virtual

Set multiple components for a single element.

virtual bool GA_AIFSharedStringTuple::setHandles ( GA_Attribute attrib,
const GA_Range ai,
const GA_StringIndexType handles,
int  count,
int  start = 0 
) const
virtual

Set multiple components for a range of elements.

bool GA_AIFSharedStringTuple::setString ( GA_Attribute attrib,
GA_Offset  ai,
const char *  string,
int  tuple_index 
) const
overridevirtual

Set a single component for a single element.

Implements GA_AIFStringTuple.

bool GA_AIFSharedStringTuple::setString ( GA_Attribute attrib,
const GA_Range ai,
const char *  string,
int  tuple_index 
) const
overridevirtual

Set a single component for a range of elements.

Reimplemented from GA_AIFStringTuple.

bool GA_AIFSharedStringTuple::setTupleSize ( GA_Attribute attrib,
int  size 
) const
overridepure virtual

Set the tuple size.

Implements GA_AIFStringTuple.

virtual GA_StringIndexType GA_AIFSharedStringTuple::validateTableHandle ( const GA_Attribute attrib,
GA_StringIndexType  index 
) const
pure virtual

It's possible that there are invalid handle indexes mixed with the valid handles. When iterating over all the handles, you can call validateTableHandle() which will ensure that there's a string associated with the given handle.

Friends And Related Function Documentation

friend class StringBuffer
friend

Definition at line 386 of file GA_AIFSharedStringTuple.h.


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