CICEAttributeDataArrayString Class Reference
 
 
 
CICEAttributeDataArrayString Class Reference

This reference page is linked to from the following overview topics: Softimage 2014.


#include <xsi_iceattributedataarray.h>


Class Description

This class is a specialization of CICEAttributeDataArray which allows access to the ICEAttribute data as a 1D array of type siICENodeDataString. CICEAttributeDataArrayString objects are read-only and can be filled with the methods supplied with the ICEAttribute class.

See also:
ICEAttribute::GetDataArray, ICEAttribute::GetDataArrayChunk, CICEAttributeDataArray2DString, Type Definitions for CICEAttributeDataArray
Since:
9.0 (2011)
Example:
This example demonstrates how to iterate over the siICENodeDataString attributes on a geometry. For a more detailed example, check out the Inspect ICE Attributes example.
                using namespace XSI;

                Application app;
                X3DObject x3dObj = app.GetSelection().GetItem(0);
                ICEAttribute attr = x3dObj.GetActivePrimitive().GetGeometry().GetICEAttributeFromName( L"MyStringAttribute" );

                // Log the data pointer address and size of data.
                CICEAttributeDataArrayString strData;
                attr.GetDataArray( strData );

                for( ULONG i=0; i<strData.GetCount( ); i++ )
                {
                        ULONG nCount;
                        const CICEAttributeDataArrayString::TData* pStr;
                        strData.GetData( i, &pStr, nCount );

                        app.LogMessage( CString( pStr, nCount ) + L":" + CString( nCount ) );
                }
Inheritance diagram for CICEAttributeDataArrayString:
CBaseICEAttributeDataArray

List of all members.

Public Member Functions

SICPPSDK_INLINE  CICEAttributeDataArrayString ()
SICPPSDK_INLINE  ~CICEAttributeDataArrayString ()
SICPPSDK_INLINE CStatus  GetData (ULONG in_index, const TData **out_ppStr, ULONG &out_nCount) const
SICPPSDK_INLINE CStatus  GetData (ULONG in_index, CString &out_str) const
SICPPSDK_INLINE CStatus  SetData (ULONG in_index, const CString &in_str)
SICPPSDK_INLINE CString  operator[] (ULONG in_index) const
CStatus  SetArray (const TData **in_ppData, ULONG in_count)

Constructor & Destructor Documentation

SICPPSDK_INLINE CICEAttributeDataArrayString ( ) [inline]

Default Constructor.

SICPPSDK_INLINE ~CICEAttributeDataArrayString ( ) [inline]

Destructor.


Member Function Documentation

CStatus GetData ( ULONG  in_index,
const TData **  out_ppStr,
ULONG &  out_nCount 
) const

Returns a pointer to the string stored at a specific index. The data is read-only and cannot be modified.

Note:
The memory allocated for the data returned by CICEAttributeDataArrayString::GetData is only available within the scope of this CICEAttributeDataArrayString instance. Make sure to make a copy of the data if you need to access it outside the scope of CICEAttributeDataArrayString.
Note:
The string returned in out_ppStr is not null-terminated, the caller must make sure to take the number of characters in account when manipulating the string.
Parameters:
in_index Array index of the user data to retrieve. The size is 0 if no data is stored at this index.
Return values:
out_ppStr Read-only pointer to the data.
out_nCount Number of characters in the string.
Returns:
Success/failure
SICPPSDK_INLINE CStatus GetData ( ULONG  in_index,
CString out_str 
) const

Returns a CString object set with a copy of the string stored at a specific index.

Parameters:
in_index Array index of the string to retrieve. The object is empty if no string is stored at this index.
Return values:
out_str Copy of the string.
Returns:
Success/failure
SICPPSDK_INLINE CStatus SetData ( ULONG  in_index,
const CString in_str 
)

Accessor to string array for writing to the data array.

Parameters:
in_index Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable.
Returns:
CStatus::OK Success.
CStatus::InvalidArgument Index out of range.
CStatus::AccessDenied Array is read-only.
Since:
11.0 (2013)
SICPPSDK_INLINE CString operator[] ( ULONG  in_index ) const

Returns a CString stored at in_index. The CString object will contain a copy of the string.

Parameters:
in_index Index in the array. The index must be smaller than the number of elements in the array, otherwise the object returned is empty.
Returns:
Copy of the CString.
CStatus SetArray ( const TData **  in_ppData,
ULONG  in_count 
)

Set all the values in the string ICE attribute

Parameters:
in_ppData Input string array. The strings must be null-terminated.
in_count Number of strings in the input array
Returns:
CStatus::OK Success.
CStatus::Fail Operation failed.
Since:
12.0 (2014)
Example:
This example demonstrates how to set the whole array
                Application xsi;
                Model root = xsi.GetActiveSceneRoot();
                X3DObject cone( CreatePrim( L"cone", L"MeshSurface", L"", L"") );
                {
                        ICEAttribute attr = cone.GetActivePrimitive().GetGeometry().AddICEAttribute( "DataArrayString", XSI::siICENodeDataString, XSI::siICENodeStructureSingle, XSI::siICENodeContextComponent0D );

                        CString l_connSet(L"cone");
                        ApplyOp( L"ICETree", l_connSet, siConstructionModeModeling );

                        AddICECompoundNode("Set Data", "cone.polymsh.ICETree");
                        AddICENode("$XSI_DSPRESETS\\ICENodes\\GetDataNode.Preset", "cone.polymsh.ICETree");
                        SetValue("cone.polymsh.ICETree.SceneReferenceNode.reference", "self.DataArrayString");
                        SetValue("cone.polymsh.ICETree.Set_Data.Reference", "self.foo");
                        ConnectICENodes("cone.polymsh.ICETree.Set_Data.Value", "cone.polymsh.ICETree.SceneReferenceNode.value");
                        ConnectICENodes("cone.polymsh.ICETree.port1", "cone.polymsh.ICETree.Set_Data.Execute");

                        DisplayPortValues("cone.polymsh.ICETree.Set_Data.Value", true, 0, true, "", 0, 0, 0, 1, false, true, 0.62, 1, 0.62, 1, false, 0, 10000, 1, false, false, 0, 10, false, true, false, 100);

                        CICEAttributeDataArrayString data;
                        attr.GetDataArray( data );


                        CICEAttributeDataLogger<CString>::Log( attr );  
                        ULONG l_nbElem = attr.GetElementCount();

                        {
                                typedef const wchar_t* RawWStringType;
                                RawWStringType* l_Values = new RawWStringType[l_nbElem];

                                for (ULONG i=0; i<l_nbElem; i++)
                                        l_Values[i] = (i%2==0) ? L"odd" : L"even";

                                data.SetArray(l_Values, l_nbElem);

                                CICEAttributeDataLogger<CString>::Log( attr );
                                delete[] l_Values;
                        }

                        // These have no effect since the reference returned by operator[] are only temporary
                        data[0] = L"str 0";

                        // These work
                        data.SetData(0, L"First string");
                        data.SetData(4, L"String value at index 4");
                }

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