The Vish Visualization Shell 0.3
Vish
Public Member Functions | List of all members
Wizt::StringSelection Class Reference

A list of strings with one of them selected. More...

#include <ocean/shrimp/VStringList.hpp>

Inheritance diagram for Wizt::StringSelection:
MemCore::StringList MemCore::ReferenceBase< StringList >

Public Member Functions

bool operator! () const
 Check whether this string list has nothing selected.
 
const string & operator() () const
 Return the selected string.
 
bool operator== (const Wizt::StringSelection &B) const
 Compare two string selections.
 
bool select (const string &what)
 Select a specific entry of the string list.
 
bool selectFirst ()
 Select the first entry from the list, if possible.
 
 StringSelection ()
 Constructor, makes an empty list.
 
 StringSelection (char delim, const string &what, const string &encoding)
 Construct from encoded string.
 
 StringSelection (const string &what)
 Construct and make one entry.
 
 StringSelection (const string &what, const RefPtr< MemCore::StringList > &list)
 Construct from string an a stringlist.
 
bool tryselect (const string &what)
 A variation of the select() function, which selects the first entry of the string list if the specified string is not part of the list.
 
 ~StringSelection ()
 Destructor, cleans up the list.
 
- Public Member Functions inherited from MemCore::StringList
template<typename... Arguments>
void addString (const string &Value, Arguments... parameters)
 Recursive handling of parameter pack.
 
string collapse (const string &delimiter) const
 Collapse a list of strings to a single string.
 
bool contains (const string &s) const
 Check if a certain string is contained here.
 
 StringList ()
 Construct empty string list.
 
 StringList (const string &path, char delimiter)
 Construct from some string by splitting up using the giving delimiter.
 
 StringList (const string &s)
 Construct string list with one entry.
 
 StringList (const string &s0, const string &s1)
 Construct string list with two entries.
 
 StringList (const string &s0, const string &s1, const string &s2)
 Construct string list with three entries.
 
 StringList (const StringList &SL)
 Construct empty string list.
 
- Public Member Functions inherited from MemCore::ReferenceBase< StringList >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< StringList, StringList > &PossibleSelf) const noexcept
 Check if this object is identical to the one used by the given pointer.
 
void mkAutoDestructive ()
 Marks this object as being automatically destructed, e.g.
 
refcount_t refcount () const noexcept
 The strong reference count.
 
 ReferenceBase (StringList *that) noexcept
 Constructor, initializes reference counter to zero.
 
const auto & self () const
 Return weak pointer to the object self.
 
refcount_t wrefcount () const noexcept
 The weak reference count.
 

Additional Inherited Members

- Public Types inherited from MemCore::ReferenceBase< StringList >
using reference_domain_t = StringList
 The type of the base class.
 
using SelfPtr_t = WeakPtr< StringList, StringList >
 Type for a pointer to this object itself.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< StringList >
virtual void extremeUnction ()
 A virtual function that will be called just before the object is destroyed.
 
ReferenceBaseoperator= (const ReferenceBase &R)
 Protected assignment operator (should not be called).
 
void suicide ()
 Delete this.
 
virtual ~ReferenceBase ()
 Virtual destructor.
 

Detailed Description

A list of strings with one of them selected.

Note that the selected string persists even when the respective entry in the list has been removed. This behavior might be changed in the future.

Constructor & Destructor Documentation

◆ StringSelection()

Wizt::StringSelection::StringSelection ( char  delim,
const string &  what,
const string &  encoding 
)

Construct from encoded string.

Parameters
encodingThe string to be split with the delimiter
whatThe iniitially selected string
delimDelimited in the string encoding

Member Function Documentation

◆ operator==()

bool Wizt::StringSelection::operator== ( const Wizt::StringSelection B) const

Compare two string selections.

Note that they ought to be sorted first (call the sort() member function).

◆ select()

bool Wizt::StringSelection::select ( const string &  what)

Select a specific entry of the string list.

The selection is only accepted if found in the string list, otherwise false is returned.

References MemCore::StringList::contains().

Referenced by selectFirst(), and tryselect().

◆ tryselect()

bool Wizt::StringSelection::tryselect ( const string &  what)

A variation of the select() function, which selects the first entry of the string list if the specified string is not part of the list.

Todo:
A future version might actually select the string which is most similar to those existing in the list, or accept a regular expression here for maximum match.
Returns
false if no selection could be made at all, which means the stringlist is just empty.

References select().