Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TStringList< S, O > Class Template Reference

String list with optional object association and sorting. More...

#include <TStringList.h>

Public Member Functions

 TStringList ()
 Constructs a list not allowing duplicates by default.
 
 TStringList (bool duplicates, bool sorted)
 Constructs a list configuring duplicate behavior and sorting.
 
 ~TStringList ()
 Destroys the string list and releases resources.
 
ssize_t add (const S &text, O *object=nullptr)
 Adds a string to the list.
 
ssize_t addAt (ssize_t index, const S &text, O *object=nullptr)
 Inserts a string at the given index but when sorting it is calling add() instead.
 
void clear ()
 Clears all items from the list.
 
void removeAt (ssize_t index)
 Deletes the item at the given index.
 
void exchange (ssize_t i, ssize_t j)
 Exchanges two items.
 
ssize_t indexOf (const S &text) const
 Returns the index of the string.
 
void setSorted (bool flag=true)
 Sorts the list and sets a flag so the new entries are sorted as well.
 
bool isSorted () const
 Whether the list is sorted.
 
ssize_t count () const
 Returns the number of items.
 
const S & at (ssize_t index) const
 Returns the string at index.
 
void setObject (ssize_t index, O *obj)
 Sets the object at index.
 
O * objectAt (ssize_t index) const
 Gets the associated object at index.
 
void beginChange ()
 Prevents calling onChanging and onChanged when modifying. Call this before updating or adding multiple items.
 
void endChange ()
 Prevents calling onChanging and onChanged when modifying. Call this after updating or adding multiple items.
 

Public Attributes

std::function< void(void *)> onChanged
 Event handler when the list has changed.
 
std::function< void(void *)> onChanging
 Event handler before the list changes.
 

Detailed Description

template<typename S, typename O = void>
class sf::TStringList< S, O >

String list with optional object association and sorting.

Constructor & Destructor Documentation

◆ TStringList() [1/2]

template<typename S , typename O = void>
sf::TStringList< S, O >::TStringList ( )

Constructs a list not allowing duplicates by default.

◆ TStringList() [2/2]

template<typename S , typename O = void>
sf::TStringList< S, O >::TStringList ( bool  duplicates,
bool  sorted 
)

Constructs a list configuring duplicate behavior and sorting.

◆ ~TStringList()

template<typename S , typename O = void>
sf::TStringList< S, O >::~TStringList ( )

Destroys the string list and releases resources.

Member Function Documentation

◆ add()

template<typename S , typename O = void>
ssize_t sf::TStringList< S, O >::add ( const S &  text,
O *  object = nullptr 
)

Adds a string to the list.

Parameters
textThe string to add.
objectOptional pointer to the object.
Returns
Index at which the string was inserted which depends on sorting or not and -1 when failing on duplicate.

◆ addAt()

template<typename S , typename O = void>
ssize_t sf::TStringList< S, O >::addAt ( ssize_t  index,
const S &  text,
O *  object = nullptr 
)

Inserts a string at the given index but when sorting it is calling add() instead.

Parameters
indexPosition to insert into the list.
textThe string to insert.
objectOptional pointer to the object.
Returns
Index at which the string was inserted which depends on sorting or not and -1 when failing on duplicate.

◆ at()

template<typename S , typename O = void>
const S & sf::TStringList< S, O >::at ( ssize_t  index) const

Returns the string at index.

Parameters
indexIndex of the item.
Returns
Stored string.

◆ beginChange()

template<typename S , typename O = void>
void sf::TStringList< S, O >::beginChange ( )

Prevents calling onChanging and onChanged when modifying. Call this before updating or adding multiple items.

◆ clear()

template<typename S , typename O = void>
void sf::TStringList< S, O >::clear ( )

Clears all items from the list.

◆ count()

template<typename S , typename O = void>
ssize_t sf::TStringList< S, O >::count ( ) const

Returns the number of items.

◆ endChange()

template<typename S , typename O = void>
void sf::TStringList< S, O >::endChange ( )

Prevents calling onChanging and onChanged when modifying. Call this after updating or adding multiple items.

◆ exchange()

template<typename S , typename O = void>
void sf::TStringList< S, O >::exchange ( ssize_t  i,
ssize_t  j 
)

Exchanges two items.

Parameters
iFirst index.
jSecond index.

◆ indexOf()

template<typename S , typename O = void>
ssize_t sf::TStringList< S, O >::indexOf ( const S &  text) const

Returns the index of the string.

Parameters
textThe string to locate.
Returns
Index of the string, or -1 if not found.

◆ isSorted()

template<typename S , typename O = void>
bool sf::TStringList< S, O >::isSorted ( ) const

Whether the list is sorted.

◆ objectAt()

template<typename S , typename O = void>
O * sf::TStringList< S, O >::objectAt ( ssize_t  index) const

Gets the associated object at index.

Parameters
indexIndex of the item.
Returns
Associated object pointer.

◆ removeAt()

template<typename S , typename O = void>
void sf::TStringList< S, O >::removeAt ( ssize_t  index)

Deletes the item at the given index.

Parameters
indexIndex of the item to delete.

◆ setObject()

template<typename S , typename O = void>
void sf::TStringList< S, O >::setObject ( ssize_t  index,
O *  obj 
)

Sets the object at index.

Parameters
indexIndex of the item.
objPointer to associated object.

◆ setSorted()

template<typename S , typename O = void>
void sf::TStringList< S, O >::setSorted ( bool  flag = true)

Sorts the list and sets a flag so the new entries are sorted as well.

Parameters
flagtrue when sorting is required.

Member Data Documentation

◆ onChanged

template<typename S , typename O = void>
std::function<void(void*)> sf::TStringList< S, O >::onChanged

Event handler when the list has changed.

◆ onChanging

template<typename S , typename O = void>
std::function<void(void*)> sf::TStringList< S, O >::onChanging

Event handler before the list changes.


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