Class StringList

Index Home MAE > MAE Architecture > MAE Data Types > Class Index > Class StringList

Summary
Public Methods
StringList()
int find(element) const
bool remove(element)
bool remove(other_list)
bool replace(oldtext, newtext, all)
StringList& sort()
inline const StringList operator+(a) const
inline StringList& operator+=(a)
inline const StringList operator-(a) const
inline StringList& operator-=(a)
const bool operator==(b)
Private Methods
static bool gt(a, b)

#include <StringList.h >

Super class: string

Summary

A class to manage an ordered list of strings. This is not a set; a string may appear on the list multiple times.

Note: by default, a string must not contain a comma to leverage this class's full functionality. A different separator character can be used if commas are needed in the strings.

Public Methods

StringList()

Constructor. Create an empty list of strings.

int find(element) const

const string& element

a string to check


Locate the position of a string in the string list.

Return value: the position, 0+ or -1 on error

bool remove(element)

const string& element

the string to locate and remove


Remove a string from the list.

Return value: true if string found and removed

bool remove(other_list)

const StringList& other_list

the list of string to remove


Remove a list of strings from the list.

Return value: true if string at least one string was found and removed

bool replace(oldtext, newtext, all)

const string& oldtext

the string to locate

const string& newtext

the replacement string

bool all

if true, check whole list (don't stop at first match)

Default value: false


Replace a string in the list with a new string.

Return value: true if at least one string was found and replaced

StringList& sort()

Alphabetically sort the list of strings.

Return value: the instance back

inline const StringList operator+(a) const

const StringList& a

other string list to add


Add a string list to this string list.

Return value: combined string list

inline StringList& operator+=(a)

const StringList& a

other string list to add


Add/Append another string list to this string list.

Return value: combined string list

inline const StringList operator-(a) const

const StringList& a

other string list to remove


Remove a string list from this string list. All strings found in a will be removed from this StringList, if present.

Return value: combined string list

inline StringList& operator-=(a)

const StringList& a

other string list to remove


Remove a string list from this string list. All strings found in a will be removed from this StringList, if present.

Return value: combined string list

const bool operator==(b)

const StringList& b

other string list


Compare two string lists to determine if they are the same.

The order of the strings in the list does not matter.

Return value: true if the lists are the same; false if they are not

Private Methods

static bool gt(a, b)

const string& a

left string to compare

const string& b

right string to compare


Compare two strings to determine if a > b.

Return value: true if a is lexicographically later/bigger than b