Class Reference stringList

The stringList class provides a list of strings. More...

Member

stringList()
stringList(stringList list)
void append(string item)
string at(int pos)
void clear()
bool contains(string item)
string findMostSimilar(string target)
int indexOf(string search, int start=0)
void insert(int pos, string value)
string join(string separator)
void prepend(string value)
int removeAll(string item)
void removeAt(int pos)
int size()
void set(int pos, string item)
void sortList(int style=0)
void swap(int pos1, int pos2)

Detailed Description

graph LR s(string)--split-->sl(stringList) pr(process)--getCommandlineParameter-->sl dr(drawingField)--findCellRegExp-->sl click s "/layoutscript/api/string" click pr "/layoutscript/api/process" click dr "/layoutscript/api/drawingfield" click sl "/layoutscript/api/stringlist" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class sl thisClas class s,pr,dr clas

A stringList is a dynamic list of string values. string split builds one from a separator; process getCommandlineParameter returns the arguments the LayoutEditor was started with; drawingField findCellRegExp returns matching cell names. append, prepend, insert, and set edit entries; join concatenates them with a separator (which may be empty). Index 0 is the first item; size is the count; set has no effect if pos is past the end. contains, indexOf, and findMostSimilar search; sortList orders the list. In Python this class maps to a native list of strings.

Example:

stringList sl;
sl.append("metal1");
sl.append("via");
sl.append("metal2");
string joined = sl.join(",");
int i = sl.indexOf("via");
if (i >= 0)
 sl.set(i, "via1");

Member Function Documentation


stringList::stringList()

Creates a new empty list of strings.


stringList::stringList(stringList list)

Creates a new list of strings with a copy of list.


void stringList::append(string item)

Inserts item at the end of the list.


string stringList::at(int pos)

Returns: the string at index pos. The first entry is 0.


void stringList::clear()

Removes all items from the list.


bool stringList::contains(string item)

Returns: true if the list contains item, otherwise false.


string stringList::findMostSimilar(string target)

Returns: the string in the list that is most similar to target. (introduced with release 20260423)


int stringList::indexOf(string search, int start=0)

Returns: the index of the first occurrence of search, searching forward from start. Returns -1 if search is not found.

Parameter:
search search
start start

void stringList::insert(int pos, string value)

Inserts value at pos. Later items move one position.

Parameter:
pos pos
value value

string stringList::join(string separator)

Joins every string in the list into one string, with separator between items. separator may be empty.

Returns: the concatenated string.


void stringList::prepend(string value)

Inserts value at the beginning of the list.


int stringList::removeAll(string item)

Removes every occurrence of item.

Returns: the number of entries removed.


void stringList::removeAt(int pos)

Removes the entry at pos. The list shrinks by one.


int stringList::size()

Returns: the number of strings in the list.


void stringList::set(int pos, string item)

Sets entry pos to item. The first entry is 0. Has no effect if the list is shorter than pos.

Parameter:
pos pos
item item

void stringList::sortList(int style=0)

Sorts the list. style chooses the order:

Values: Alignment:
0 case insensitive
1 case sensitive
10 by integer value (e.g. 1, 4, 8, 12, 34, 765 )

(introduced with release 20201224)


void stringList::swap(int pos1, int pos2)

Swaps the values at pos1 and pos2.