FBX C++ API Reference
FbxStringListT< Type > Class Template Reference

#include <fbxstringlist.h>

Class Description

template<class Type>
class FbxStringListT< Type >

Base class of FbxStringList.

Definition at line 50 of file fbxstringlist.h.

Public Member Functions

Operation With The Array
int AddItem (Type *pItem)
 Append a item at the end of the array. More...
 
int InsertItemAt (int pIndex, Type *pItem)
 Insert a item in the array. More...
 
Type * GetItemAt (int pIndex) const
 Access item at given index. More...
 
int FindItem (Type *pItem) const
 Find first matching item. More...
 
Constructor and Destructor
 FbxStringListT ()
 Default constructor. More...
 
virtual ~FbxStringListT ()
 Destructor. More...
 
void RemoveLast ()
 Remove the item at the end of the array and delete the associated object. More...
 
int GetCount () const
 Get number of items in the array. More...
 
FbxStringoperator[] (int pIndex)
 Access the string in the item at given index. More...
 
FbxHandle GetReferenceAt (int pIndex) const
 Access the value of reference in the item at given index. More...
 
void SetReferenceAt (int pIndex, FbxHandle pRef)
 Set the value of reference at given index. More...
 
char * GetStringAt (int pIndex) const
 Access the pointer of string at given index. More...
 
virtual bool SetStringAt (int pIndex, const char *pString)
 Set string at given index. More...
 
int Find (Type &pItem) const
 Find first matching item. More...
 
int FindIndex (FbxHandle pReference) const
 Find first matching item which has the same reference as given parameter. More...
 
int FindIndex (const char *pString) const
 Find first matching item in array whose string address is the same as given pointer. More...
 
FbxHandle FindReference (const char *pString) const
 Access the value of reference of the first matching item in array whose string address is the same as given pointer. More...
 
bool Remove (Type &pItem)
 Remove first matching item. More...
 
bool Remove (const char *pString)
 Remove first matching item in array whose string address is the same as given pointer. More...
 
bool RemoveIt (Type &pItem)
 Remove first matching item. More...
 
void Sort ()
 Sort the array by the string of every item,not case sensitive. More...
 
void * FindEqual (const char *pString) const
 Find first matching item which has the same string as given parameter,not case sensitive. More...
 
void * FindCaseSensitive (const char *pString) const
 Find first matching item which has the same string as given parameter, case sensitive. More...
 
int Add (const char *pString, FbxHandle pItem=0)
 Add a new item at the end of array. More...
 
virtual int InsertAt (int pIndex, const char *pString, FbxHandle pItem=0)
 
virtual void RemoveAt (int pIndex)
 Remove the item at the given position in the array and delete the associated object. More...
 
virtual void Clear ()
 Delete the array. More...
 
virtual void GetText (FbxString &pText) const
 Get the string of all the item. More...
 
virtual int SetText (const char *pList)
 Clear the array and set the array's new items with the substring separated by '~' from the given string. More...
 

Protected Attributes

FbxArray< Type * > mList
 

Constructor & Destructor Documentation

◆ FbxStringListT()

FbxStringListT ( )
inline

Default constructor.

Definition at line 90 of file fbxstringlist.h.

91  {
92  }

◆ ~FbxStringListT()

virtual ~FbxStringListT ( )
inlinevirtual

Destructor.

Definition at line 95 of file fbxstringlist.h.

95 { Clear(); }
virtual void Clear()
Delete the array.

Member Function Documentation

◆ AddItem()

int AddItem ( Type *  pItem)
inline

Append a item at the end of the array.

Returns
Index of appended pointer.

Definition at line 64 of file fbxstringlist.h.

64 { return mList.Add( pItem ); }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int Add(const T &pElement)
Append an element at the end of the array, doubling the array if capacity is not sufficient.
Definition: fbxarray.h:83

◆ InsertItemAt()

int InsertItemAt ( int  pIndex,
Type *  pItem 
)
inline

Insert a item in the array.

Parameters
pIndexPosition where to insert the item.
pItemItem to insert.
Returns
Position of the inserted item in the array.
Remarks
If the given index is out of range, the pointer is appended at the end of the array.

Definition at line 72 of file fbxstringlist.h.

72 { return mList.InsertAt( pIndex, pItem ); }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int InsertAt(const int pIndex, const T &pElement, bool pCompact=false)
Insert an element at the given position, growing the array if capacity is not sufficient.
Definition: fbxarray.h:48

◆ GetItemAt()

Type* GetItemAt ( int  pIndex) const
inline

Access item at given index.

Definition at line 75 of file fbxstringlist.h.

75 { return mList[pIndex]; }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ FindItem()

int FindItem ( Type *  pItem) const
inline

Find first matching item.

Returns
Index of first matching item found or -1 if there is no matching element.

Definition at line 80 of file fbxstringlist.h.

80 { return mList.Find( pItem ); }
int Find(const T &pElement, const int pStartIndex=0) const
Find first matching element, from first to last.
Definition: fbxarray.h:164
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ RemoveLast()

void RemoveLast ( )
inline

Remove the item at the end of the array and delete the associated object.

Definition at line 99 of file fbxstringlist.h.

99 { RemoveAt( mList.GetCount()-1 ); }
virtual void RemoveAt(int pIndex)
Remove the item at the given position in the array and delete the associated object.
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ GetCount()

int GetCount ( ) const
inline

Get number of items in the array.

Returns
The number of items in the array.

Definition at line 104 of file fbxstringlist.h.

104 { return mList.GetCount(); }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ operator[]()

FbxString& operator[] ( int  pIndex)
inline

Access the string in the item at given index.

Definition at line 107 of file fbxstringlist.h.

107 { return mList[pIndex]->mString; }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ GetReferenceAt()

FbxHandle GetReferenceAt ( int  pIndex) const
inline

Access the value of reference in the item at given index.

Definition at line 110 of file fbxstringlist.h.

110 { return mList[pIndex]->mReference; }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ SetReferenceAt()

void SetReferenceAt ( int  pIndex,
FbxHandle  pRef 
)
inline

Set the value of reference at given index.

Definition at line 113 of file fbxstringlist.h.

113 { mList[pIndex]->mReference = pRef; }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ GetStringAt()

char* GetStringAt ( int  pIndex) const
inline

Access the pointer of string at given index.

Definition at line 116 of file fbxstringlist.h.

116 { if (pIndex<mList.GetCount()) return mList[pIndex]->mString.Buffer(); else return NULL; }
#define NULL
Definition: fbxarch.h:210
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ SetStringAt()

virtual bool SetStringAt ( int  pIndex,
const char *  pString 
)
inlinevirtual

Set string at given index.

Definition at line 119 of file fbxstringlist.h.

120  {
121  if (pIndex<mList.GetCount())
122  {
123  mList[pIndex]->mString = pString;
124  return true;
125  } else return false;
126  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ Find()

int Find ( Type &  pItem) const
inline

Find first matching item.

Returns
Index of first matching item found or -1 if there is no matching element.

Definition at line 132 of file fbxstringlist.h.

133  {
134  for (int Count=0; Count<mList.GetCount(); Count++) {
135  if (mList[Count]==&pItem) {
136  return Count;
137  }
138  }
139  return -1;
140  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ FindIndex() [1/2]

int FindIndex ( FbxHandle  pReference) const
inline

Find first matching item which has the same reference as given parameter.

Returns
Index of first matching item found or -1 if there is no matching element.

Definition at line 146 of file fbxstringlist.h.

147  {
148  for (int Count=0; Count<mList.GetCount(); Count++) {
149  if (mList[Count]->mReference==pReference) {
150  return Count;
151  }
152  }
153  return -1;
154  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ FindIndex() [2/2]

int FindIndex ( const char *  pString) const
inline

Find first matching item in array whose string address is the same as given pointer.

Returns
Index of first matching item found or -1 if there is no matching element.

Definition at line 160 of file fbxstringlist.h.

161  {
162  for (int lCount=0; lCount<mList.GetCount(); lCount++) {
163  if (mList[lCount]->mString==pString) {
164  return lCount;
165  }
166  }
167  return -1;
168  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ FindReference()

FbxHandle FindReference ( const char *  pString) const
inline

Access the value of reference of the first matching item in array whose string address is the same as given pointer.

Returns
The value of reference of the first matching item found or NULL if there is no matching element.

Definition at line 175 of file fbxstringlist.h.

176  {
177  int lIndex = FindIndex( pString );
178  if (lIndex!=-1) {
179  return mList[lIndex]->mReference;
180  }
181  return 0; // NULL
182  }
int FindIndex(FbxHandle pReference) const
Find first matching item which has the same reference as given parameter.
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ Remove() [1/2]

bool Remove ( Type &  pItem)
inline

Remove first matching item.

Definition at line 185 of file fbxstringlist.h.

186  {
187  int lIndex = Find( pItem );
188  if (lIndex>=0) {
189  RemoveAt( lIndex );
190  return true;
191  }
192  return false;
193  }
virtual void RemoveAt(int pIndex)
Remove the item at the given position in the array and delete the associated object.
int Find(Type &pItem) const
Find first matching item.

◆ Remove() [2/2]

bool Remove ( const char *  pString)
inline

Remove first matching item in array whose string address is the same as given pointer.

Definition at line 196 of file fbxstringlist.h.

197  {
198  int lIndex = FindIndex( pString );
199  if (lIndex>=0) {
200  RemoveAt( lIndex );
201  return true;
202  }
203  return false;
204  }
virtual void RemoveAt(int pIndex)
Remove the item at the given position in the array and delete the associated object.
int FindIndex(FbxHandle pReference) const
Find first matching item which has the same reference as given parameter.

◆ RemoveIt()

bool RemoveIt ( Type &  pItem)
inline

Remove first matching item.

Definition at line 207 of file fbxstringlist.h.

208  {
209  int lIndex = Find( pItem );
210  if (lIndex>=0) {
211  RemoveAt( lIndex );
212  return true;
213  }
214  return false;
215  }
virtual void RemoveAt(int pIndex)
Remove the item at the given position in the array and delete the associated object.
int Find(Type &pItem) const
Find first matching item.

◆ Sort()

void Sort ( )
inline

Sort the array by the string of every item,not case sensitive.

Definition at line 218 of file fbxstringlist.h.

219  {
220  qsort( &(mList.GetArray()[0]),mList.GetCount(),sizeof(FbxStringListItem*),FbxCompareStringListSort );
221  }
T * GetArray() const
Get pointer to internal array of elements.
Definition: fbxarray.h:371
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int FbxCompareStringListSort(const void *E1, const void *E2)
Definition: fbxstringlist.h:34
Wraps a string (FbxString) and a pointer (FbxHandle).
Definition: fbxstringlist.h:24

◆ FindEqual()

void* FindEqual ( const char *  pString) const
inline

Find first matching item which has the same string as given parameter,not case sensitive.

Returns
the pointer of matching item found or NULL if there is no matching element.
Remarks
To cast the returned pointer to the FbxStringListItem you need a double indirection: (FbxStringListItem**)

Definition at line 228 of file fbxstringlist.h.

229  {
230  FbxStringListItem Key(pString);
231 
232  if (mList.GetCount() != 0)
233  {
234  return bsearch ( &Key, &(mList.GetArray()[0]),mList.GetCount(),sizeof(FbxStringListItem*),FbxCompareStringListFindEqual );
235  }
236  else
237  {
238  return NULL ;
239  }
240  }
T * GetArray() const
Get pointer to internal array of elements.
Definition: fbxarray.h:371
#define NULL
Definition: fbxarch.h:210
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int FbxCompareStringListFindEqual(const void *E1, const void *E2)
Definition: fbxstringlist.h:39
Wraps a string (FbxString) and a pointer (FbxHandle).
Definition: fbxstringlist.h:24

◆ FindCaseSensitive()

void* FindCaseSensitive ( const char *  pString) const
inline

Find first matching item which has the same string as given parameter, case sensitive.

Returns
the pointer of matching item found or NULL if there is no matching element.
Remarks
To cast the returned pointer to the FbxStringListItem you need a double indirection: (FbxStringListItem**)

Definition at line 247 of file fbxstringlist.h.

248  {
249  FbxStringListItem Key(pString);
250 
251  if (mList.GetCount() != 0)
252  {
253  return bsearch ( &Key, &(mList.GetArray()[0]),mList.GetCount(),sizeof(FbxStringListItem*), FbxCompareCaseSensitiveStringList);
254  }
255  else
256  {
257  return NULL ;
258  }
259 
260  }
T * GetArray() const
Get pointer to internal array of elements.
Definition: fbxarray.h:371
#define NULL
Definition: fbxarch.h:210
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int FbxCompareCaseSensitiveStringList(const void *E1, const void *E2)
Definition: fbxstringlist.h:44
Wraps a string (FbxString) and a pointer (FbxHandle).
Definition: fbxstringlist.h:24

◆ Add()

int Add ( const char *  pString,
FbxHandle  pItem = 0 
)
inline

Add a new item at the end of array.

Definition at line 264 of file fbxstringlist.h.

265  {
266  return InsertAt( mList.GetCount(),pString,pItem );
267  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
virtual int InsertAt(int pIndex, const char *pString, FbxHandle pItem=0)

◆ InsertAt()

virtual int InsertAt ( int  pIndex,
const char *  pString,
FbxHandle  pItem = 0 
)
inlinevirtual

Definition at line 269 of file fbxstringlist.h.

270  {
271  return mList.InsertAt( pIndex,FbxNew< Type >( pString,(FbxHandle)pItem ));
272  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53
int InsertAt(const int pIndex, const T &pElement, bool pCompact=false)
Insert an element at the given position, growing the array if capacity is not sufficient.
Definition: fbxarray.h:48

◆ RemoveAt()

virtual void RemoveAt ( int  pIndex)
inlinevirtual

Remove the item at the given position in the array and delete the associated object.

Parameters
pIndexPosition of the item to remove.
Remarks
If the index is not valid, nothing is performed. Otherwise, the item is removed from the array and the items are shifted to fill the empty slot.

Definition at line 280 of file fbxstringlist.h.

281  {
282  FbxDelete(mList.RemoveAt(pIndex));
283  }
T RemoveAt(const int pIndex)
Remove an element at the given position in the array.
Definition: fbxarray.h:239
void FbxDelete(T *p)
Deletion policy for pointer template classes that uses the FbxDelete() function.
Definition: fbxnew.h:341
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ Clear()

virtual void Clear ( )
inlinevirtual

Delete the array.

Definition at line 286 of file fbxstringlist.h.

287  {
289  }
void FbxArrayDelete(FbxArray< T > &pArray)
Call FbxDelete on each element of the array, and then clear it.
Definition: fbxarray.h:465
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ GetText()

virtual void GetText ( FbxString pText) const
inlinevirtual

Get the string of all the item.

Returns
The text of string, each item's string separated by '~'.

Definition at line 294 of file fbxstringlist.h.

295  {
296  int lCount;
297  for (lCount=0; lCount<mList.GetCount(); lCount++)
298  {
299  pText += mList[lCount]->mString;
300  if (lCount<mList.GetCount()-1)
301  {
302  pText += "~";
303  }
304  }
305  }
FbxArray< Type * > mList
Definition: fbxstringlist.h:53

◆ SetText()

virtual int SetText ( const char *  pList)
inlinevirtual

Clear the array and set the array's new items with the substring separated by '~' from the given string.

Parameters
pListThe string which used to generate the new items.
Returns
The last index of the item in the new array.
Remarks
The number of items in the new array is the same as the number of substrings, and the string of each item is decided by the content of each substring.

Definition at line 313 of file fbxstringlist.h.

314  {
315  int lPos=0, lOldPos = 0;
316  int lLastIndex=0;
317  FbxString lName=pList;
318 
319  Clear();
320  for (lPos=0; lName.Buffer()[lPos]!=0; lPos++) {
321  if (lName.Buffer()[lPos]=='~') {
322  lName.Buffer()[lPos]=0;
323  lLastIndex = Add(lName.Buffer()+lOldPos);
324  lOldPos=lPos+1;
325  }
326  }
327 
328  if(lOldPos != lPos)
329  {
330  lLastIndex = Add(lName.Buffer()+lOldPos);
331  }
332  return lLastIndex;
333  }
virtual void Clear()
Delete the array.
Utility class to manipulate strings.
Definition: fbxstring.h:66
char * Buffer()
Non-const buffer access.
int Add(const char *pString, FbxHandle pItem=0)
Add a new item at the end of array.

Member Data Documentation

◆ mList

FbxArray<Type*> mList
protected

Definition at line 53 of file fbxstringlist.h.


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