/MEng/StringList

ClassPath:MEng.
Parent ClassPath:MEng.Object
Copyable:Yes
Final:Yes

MEng.StringList represents a collection of strings. Note that this is not the same as a collection of string objects. For most purposes, a collection of strings would be more appropriate. The string list class' primary purpose is as a list of keys, where the primary operation, after adding the keys to the list, is to check whether a given key is present or not, i.e. as a sort of 'enumerated string' type. It is not nearly as efficient as a standard collection if you are moving values into and out of it, since you cannot directly access the string objects as you can with a collection.

The main use of this class is in the CQC system, where it is the representation of a StringList type field.

The list is ordered, meaning that the iteration order is the order that they are added to the list, and indexed access is supported. By default, duplicate strings are not allowed, but this attribute can be controlled in the constructor. Because of the way it's normally used, you wouldn't want to allow duplicates.

 

Nested Classes:

Enum=StrListErrors
    BadIndex    : "Index %(1) is invalid for this string list. Count=%(2)";
    AlreadyUsed : "A duplicate string was added to the list";
EndEnum;

This enumerated type defines the string list specific exceptions that this class might throw. Note though that other exceptions might be thrown from other classes used by this class

 

Constructors:

Constructor();
Constructor([In] MEng.Boolean UniqueOnly);

There is one default constructor, which creates an empty string list. And there is a second constructor which allows you to set the uniqueness constraint. By default the uniqueness constraint is set, so duplicates are not allowed.

 

Final, Const Methods:

FindString([In] MEng.String ToFind, [Out] MEng.Card4 Index) Returns MEng.Boolean;

Looks for the passed string in this list, and returns True if it is found. If the return is True, then the Index parameter is updated with it's index. If not found, then the return is False and the Index parameter is not updated.

GetAt([In] MEng.Card4 GetAt) Returns MEng.String;

Returns the string object at the indicated index. Keep in mind that, unlike a collection, this returns a copy of the string, so you cannot modify it directly. If the index is not valid for this list, a BadIndex exception is thrown.

GetElemCount() Returns MEng.Card4;

Returns the count of strings currently in this string list.

 

Final, Non-Const Methods:

Append([In] MEng.String ToAppend);

Appends a new string to this string list. The new string is added to the end any existing strings currently in the list. If this string is already in the list, and the uniqueness constraint is set on this list, an AlreadyUsed exception is thrown.

InsertAt([In] MEng.Card4 InsertAt, [In] MEng.String ToInsert);

Inserts a new string to this string list, at the indicated index. If this string is already in the list, and the uniqueness constraint is set on this list, an AlreadyUsed exception is thrown. If the insert index is invalid, a BadIndex exception is thrown.

RemoveAll();

Removes all strings from this list, leaving it empty.

RemoveAt([In] MEng.Card4 RemoveAt);

Removes the string at the indicated index. If the passed index is invalid, a BadIndex exception is thrown.

SetAt([In] MEng.Card4 SetAt, [In] MEng.String NewValue);

Updates the value of the string at the SetAt index. If the index is not not valid, a BadIndex exception is thrown. If the new value is a duplicate, and the uniqueness constraint is set on this list, the AlreadyUsed exception will be thrown.