ADTF  3.18.2
string_list_base< storageT >

forward declaration More...

Public Types

typedef string_list_base< storageT > _myType
 definition of my type
 
typedef std::vector< storageT > tStringList
 list of containing cStrings
 
typedef tStringList::const_iterator const_iterator
 short typedefinition for cString lists iterators
 
typedef tStringList::const_reverse_iterator const_reverse_iterator
 short typedefinition for cString lists reverse iterators
 
typedef tStringList::iterator iterator
 short typedefinition for cString lists iterators
 
typedef tStringList::reverse_iterator reverse_iterator
 short typedefinition for cString lists reverse iterators
 

Public Member Functions

iterator begin ()
 Return iterator to beginning.
 
iterator end ()
 Return iterator to end.
 
const_iterator begin () const
 Return const_iterator to beginning.
 
const_iterator end () const
 Return const_iterator to end.
 
const_iterator cbegin () const
 Return iterator to beginning.
 
const_iterator cend () const
 Return iterator to end.
 
reverse_iterator rbegin ()
 Return reverse iterator to reverse beginning.
 
reverse_iterator rend ()
 Return reverse iterator to reverse end.
 
const_reverse_iterator crbegin () const
 Return reverse const_iterator to reverse beginning.
 
const_reverse_iterator crend () const
 Return reverse const_iterator to reverse end.
 
 string_list_base ()
 Constructor that initializes an empty cStringList object.
 
 string_list_base (const _myType &lstList)
 Constructor that duplicates an existing string list. More...
 
 string_list_base (_myType &&lstList)
 Constructor that duplicates an existing string list. More...
 
 string_list_base (const storageT &strList)
 Constructor that creates string list from comma or semicolon-delimited string. More...
 
 string_list_base (std::initializer_list< storageT > lstStrings)
 
string_list_baseoperator= (const _myType &lstList)
 The cStringList assignment (=) operator reinitializes existing string lists with an existing object. More...
 
string_list_baseoperator= (_myType &&lstList)
 The cStringList assignment (=) operator reinitializes existing string lists with an existing object. More...
 
virtual ~string_list_base ()
 Destructor.
 
tVoid Copy (const _myType &lstList)
 This function copies the content of an existing string list to this cStringList object. More...
 
tVoid Clear ()
 This function cleans up the list and frees all allocated memory blocks.
 
tResult Append (const storageT &strString)
 This function appends one string to the list. More...
 
tResult Append (const _myType &lstString)
 This function appends the given list of strings to the list. More...
 
tResult Add (const storageT &strString)
 This function appends one string to the list only if the strString is not yet part of the list. More...
 
tResult Add (const _myType &lstString)
 This function appends strings of the given list to the list only if the string is not yet part of the list. More...
 
tResult Insert (tSize nIdx, const storageT &strString)
 This function inserts a string to the list at a specified position. More...
 
tResult Delete (tSize nIdx)
 This function removes one item from the list. More...
 
tVoid Sort (tBool bIgnoreCase=tFalse)
 This function arranges the list elements. More...
 
tSize GetItemCount () const
 This function returns the number of items the list contains. More...
 
const storageT & Get (tSize nIdx, const storageT &strDefault="") const
 This function retrieves a string value from the list. More...
 
tResult Set (tSize nIdx, const storageT &strValue)
 This function stores a string value into the list. More...
 
tSize Find (const storageT &strString) const
 This function returns the position of a string inside the list. More...
 
tSize Match (const storageT &strPattern) const
 Returns the index of the string matching a pattern. More...
 
tSize FindNoCase (const storageT &strString) const
 This function returns the position of a string inside the list. More...
 
storageT Join (const storageT &strSeparator) const
 This function concatenates all list elements to one single cString object. More...
 
tBool IsEmpty () const
 This function checks if the string object is empty. More...
 
storageT & operator[] (tSize nIdx)
 This function retrieves a string value from the list. More...
 
const storageT & operator[] (tSize nIdx) const
 This function retrieves a string value from the list. More...
 
bool operator== (const _myType &oList) const
 

Static Public Member Functions

static tBool fnSortLexically (const storageT &strFirst, const storageT &strSecond)
 Checks if two strings are sorted lexically. More...
 

Static Public Attributes

static const tSize InvalidPos = g_npos
 used to identicate out of range, invalidpos or default length
 

Protected Attributes

tStringList m_lstList
 Internally used string list.
 

Detailed Description

template<class storageT>
class A_UTILS_NS::string_list_base< storageT >

forward declaration

String list class.

Definition at line 20 of file stringlist.h.

Constructor & Destructor Documentation

◆ string_list_base() [1/3]

string_list_base ( const _myType lstList)
inline

Constructor that duplicates an existing string list.

Parameters
lstList[in] List object to be copied.

Definition at line 109 of file stringlist.h.

◆ string_list_base() [2/3]

string_list_base ( _myType &&  lstList)
inline

Constructor that duplicates an existing string list.

Parameters
lstList[in] List object to be copied.

Definition at line 120 of file stringlist.h.

◆ string_list_base() [3/3]

string_list_base ( const storageT &  strList)
inline

Constructor that creates string list from comma or semicolon-delimited string.

Both delimiters can be used at the same time.

Parameters
strList[in] Comma or semicolon-delimited string.

Definition at line 133 of file stringlist.h.

References string_base< cStackString >::InvalidPos, and string_list_base< storageT >::m_lstList.

Member Function Documentation

◆ Add() [1/2]

tResult Add ( const _myType lstString)
inline

This function appends strings of the given list to the list only if the string is not yet part of the list.

Parameters
lstString[in] String to be added if strString is not already Part of the List
Return values
ERR_NOERRORat least one string was added.
ERR_FAILEDno string of the list was added, every string is already part of the list

Definition at line 339 of file stringlist.h.

References string_list_base< storageT >::begin(), string_list_base< storageT >::end(), IS_OK, RETURN_ERROR, and RETURN_NOERROR.

◆ Add() [2/2]

tResult Add ( const storageT &  strString)
inline

This function appends one string to the list only if the strString is not yet part of the list.

Parameters
strString[in] String to be added if strString is not already Part of the List
Return values
ERR_NOERRORthe string was added.
ERR_FAILEDthe string is not added, already part of the list

Definition at line 317 of file stringlist.h.

References RETURN_ERROR, and RETURN_NOERROR.

◆ Append() [1/2]

tResult Append ( const _myType lstString)
inline

This function appends the given list of strings to the list.

  • Parameters
    lstString[in] Stringlist to append
    Returns
    ERR_NOERROR if everything was ok.

Definition at line 293 of file stringlist.h.

References string_list_base< storageT >::cbegin(), string_list_base< storageT >::cend(), and RETURN_NOERROR.

◆ Append() [2/2]

tResult Append ( const storageT &  strString)
inline

This function appends one string to the list.

  • Parameters
    strString[in] String to be appended
    Returns
    ERR_NOERROR if everything was ok.

Definition at line 277 of file stringlist.h.

References RETURN_NOERROR.

Referenced by string_base< storageT >::Split(), and string_base< storageT >::SplitToken().

◆ Copy()

tVoid Copy ( const _myType lstList)
inline

This function copies the content of an existing string list to this cStringList object.

Parameters
lstList[in] List object to be copied.
Returns
True, if everything was ok, otherwise false.

Definition at line 248 of file stringlist.h.

References string_list_base< storageT >::m_lstList.

◆ Delete()

tResult Delete ( tSize  nIdx)
inline

This function removes one item from the list.

Parameters
nIdx[in] Position where the string should be removed. The element currently at this position as well as all following elements are moved one position further back ( Position n -> Position n-1 )
Returns
Returns ERR_NOERROR, if the item specified by nIdx was found and removed, otherwise ERR_INVALID_INDEX.

Definition at line 397 of file stringlist.h.

References RETURN_ERROR.

◆ Find()

tSize Find ( const storageT &  strString) const
inline

This function returns the position of a string inside the list.

Parameters
strString[in] String to find inside the list.
Returns
Returns the zero-based position index of a string inside the list. If the string doesn't exist in the list, InvalidPos is returned.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 522 of file stringlist.h.

◆ FindNoCase()

tSize FindNoCase ( const storageT &  strString) const
inline

This function returns the position of a string inside the list.

Parameters
strString[in] String to find inside the list.
Returns
Returns the zero-based position index of a string inside the list. If the string doesn't exist in the list, InvalidPos is returned.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 620 of file stringlist.h.

◆ fnSortLexically()

static tBool fnSortLexically ( const storageT &  strFirst,
const storageT &  strSecond 
)
inlinestatic

Checks if two strings are sorted lexically.

Note
Function name is misleading. This function only compares two strings. It does not sort them!
Parameters
[in]strFirst
[in]strSecond
Returns
True if strFirst is less than strSecond.

Definition at line 420 of file stringlist.h.

References tFalse, and tTrue.

◆ Get()

const storageT& Get ( tSize  nIdx,
const storageT &  strDefault = "" 
) const
inline

This function retrieves a string value from the list.

Parameters
nIdx[in] Zero-based list index of the element to be fetched.
strDefault[in] Default value that is returned if the element was not found (default is an empty string) or nIdx was negative.
Returns
The function creates a cString object that is initialized with the contents of the referenced list item.

Definition at line 475 of file stringlist.h.

◆ GetItemCount()

tSize GetItemCount ( ) const
inline

This function returns the number of items the list contains.

Returns
Returns the number of list items.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 460 of file stringlist.h.

◆ Insert()

tResult Insert ( tSize  nIdx,
const storageT &  strString 
)
inline

This function inserts a string to the list at a specified position.

  • Parameters
    nIdx[in] Position where the string should be inserted to. If this is zero or below zero, the element is appended at the front of the list. If the value is greater than the number of elements in the list, the element is appended at the end.
    strString[in] String to be inserted
    Returns
    ERR_NOERROR if everything was ok.
    ERR_INVALID_INDEX if insertion index is out of range.

Definition at line 374 of file stringlist.h.

References RETURN_ERROR, and RETURN_NOERROR.

◆ IsEmpty()

tBool IsEmpty ( ) const
inline

This function checks if the string object is empty.

Returns
tBool value that is true, if the string list object has no elements.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 678 of file stringlist.h.

◆ Join()

storageT Join ( const storageT &  strSeparator) const
inline

This function concatenates all list elements to one single cString object.

The strings are separated by a separator string.

Parameters
strSeparator[in] Separator string.
Returns
The function creates a cString object that is initialized with the concatenated list content.

Definition at line 647 of file stringlist.h.

References tTrue.

◆ Match()

tSize Match ( const storageT &  strPattern) const
inline

Returns the index of the string matching a pattern.

Parameters
strPattern[in] The pattern to match (can contain the '*' wildcard at the beginning and at the end).
Returns
The index of the string matching the pattern. If no matching string exists in the list, InvalidPos is returned.

Definition at line 541 of file stringlist.h.

References string_base< cStackString >::InvalidPos.

◆ operator=() [1/2]

string_list_base& operator= ( _myType &&  lstList)
inline

The cStringList assignment (=) operator reinitializes existing string lists with an existing object.

Parameters
lstList[in] List object to be copied.
Returns
Reference to cStringList object.

Definition at line 221 of file stringlist.h.

◆ operator=() [2/2]

string_list_base& operator= ( const _myType lstList)
inline

The cStringList assignment (=) operator reinitializes existing string lists with an existing object.

Parameters
lstList[in] List object to be copied.
Returns
Reference to cStringList object.

Definition at line 207 of file stringlist.h.

◆ operator[]() [1/2]

storageT& operator[] ( tSize  nIdx)
inline

This function retrieves a string value from the list.

Parameters
nIdx[in] Zero-based list index of the element to be fetched.
Returns
The function creates a cString object that is initialized with the contents of the referenced list item.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 694 of file stringlist.h.

◆ operator[]() [2/2]

const storageT& operator[] ( tSize  nIdx) const
inline

This function retrieves a string value from the list.

Parameters
nIdx[in] Zero-based list index of the element to be fetched.
Returns
The function creates a cString object that is initialized with the contents of the referenced list item.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 700 of file stringlist.h.

◆ Set()

tResult Set ( tSize  nIdx,
const storageT &  strValue 
)
inline

This function stores a string value into the list.

Parameters
nIdx[in] Zero-based list index of the element to be written to. If the provided index is bigger than the last existing index n, the element is appended at position n+1. If the value is negative, the operation fails.
strValue[in] Value that is written to the list.
Returns
Standard error code.
Return values
ERR_NOERRORif everything was ok
ERR_INVALID_ARGif InvalidPos == nIdx

Definition at line 496 of file stringlist.h.

References RETURN_NOERROR.

◆ Sort()

tVoid Sort ( tBool  bIgnoreCase = tFalse)
inline

This function arranges the list elements.

Parameters
bIgnoreCase[in] If false, a strict character code comparison is performed. Otherwise the comparison is made case insensitive. The character code comparison is the default behavior.
Returns
tVoid
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Definition at line 442 of file stringlist.h.