STD
Class emos_std_string_lib


public class emos_std_string_lib

# This library contains some useful string manipulation routines.


Method Summary
 intalltrim(in str1)
           
 intarr2str(inout[] arr, in sep, in count, in start)
          This functions concatenates all elements of the array into a string.
 intindex1(in s1, in s2)
           
 intindex2(in s1, in s2, in n1)
           
 intjoin_path(in part1, in part2, in sep)
          Diese Funktion fügt zwei Pfadteile zusammen.
 intltrim(in str1)
           
 intrandom_arr(inout[] arr1, in nnn)
           
 intreplace(in str, in delchr, in insstr)
          Replaces all delchr characters with insstr string.
 intreplace1(in s1, in s2, in s3)
           
 intsplit_path(in path, out dir, out file, in sep)
          Splits a path string into a directory and file parts.
 intsplit1(in s1, inout[] arr1, in s2)
           
 intstrip_both(in str, in zap)
          Removes all occuences of zap from both sides of str (trim).
 intstrip_front(in str, in zap)
          Removes all occuences of zap from the front of str (left trim).
 intstrip_trail(in str, in zap)
          Removes all occuences of zap from the end of str (right trim).
 intsubstr1(in str1, in s1, in s2)
           
 inttrim(in str1)
           

Method Detail

alltrim

public int alltrim(in str1)

arr2str

public int arr2str(inout[] arr, in sep, in count, in start)
This functions concatenates all elements of the array into a string. Elements are separated by sep.

NOTE! Iy the arr is not sequentially inexed (starting from 0), then either the count should NOT be defined (in operator will be used) or start must be defined (sequential from then on).

Parameters:
arr[] - (inout) array to be "streamed"
sep - (in) (optional) separator, [default: comma]
count - (in) (optional) number of elements in the array [default: 0]
start - (in) (optional) starting index [default: 0]
Returns: streamed array

index1

public int index1(in s1, in s2)

index2

public int index2(in s1, in s2, in n1)

join_path

public int join_path(in part1, in part2, in sep)
Diese Funktion fügt zwei Pfadteile zusammen. Dabei werden sep konvertiert "/-->\ bzw. \-->/). Standardmeßig werden \ durch / ersetzt. Eventuell nicht oder merfach vorhandene Separatoren in der Join-Stelle werden auf ein gesetzt.

EXAMPLE:

join_path( "C:\aaa", "bbb.xxx" )   ==>  "C:/aaa/bbb.xxx"
join_path( "C:\aaa\", "\bbb.xxx" ) ==>  "C:/aaa/bbb.xxx"
join_path( "", "bbb.xxx" )         ==>  "/bbb.xxx"
join_path( "C:/aaa" )              ==>  "C:/aaa/"
Parameters:
part1 - (in) erster Teil der Pfadangabe
part2 - (in) zweiter Teil der Pfadangabe
sep - (in) (optional) Pathseparator to use [default: /]
Returns: concatenated path

ltrim

public int ltrim(in str1)

random_arr

public int random_arr(inout[] arr1, in nnn)

replace

public int replace(in str, in delchr, in insstr)
Replaces all delchr characters with insstr string.

NOTE1! This function internally uses split() to process the string. Unfortunatelly, split() has an undocumented "feature" that it trims blanks from the given string before splitting. This has the effect that replace() does the same. If you don't want the string to be trimmed, use replace1().

NOTE2! The replace() replaces each occurence of individual characters within delchr with the complete string insstr. It does NOT replace string delchr with the string insstr.

Parameters:
str - (in) string to be processed
delchr - (in) character(s) to be replaced
insstr - (in) string to be used as replacement
Returns: converted string

replace1

public int replace1(in s1, in s2, in s3)

split_path

public int split_path(in path, out dir, out file, in sep)
Splits a path string into a directory and file parts. The path separator can be defined with sep (default: backslash)

NOTE! The function does not analyse whether the file part is indeed a file name. Anything following the last is treated as file. Anything before is treated as dir. NOTE2! dir does not end with sep.

Parameters:
path - (in) string to be processed
dir - (out) directory-part (up until the last sep)
file - (out) name-part (anything after the last sep)
sep - (in) (optional) separator (default: backslash)
Returns: E_OK: success !E_OK: error (do not ust the out variables!)

split1

public int split1(in s1, inout[] arr1, in s2)

strip_both

public int strip_both(in str, in zap)
Removes all occuences of zap from both sides of str (trim).
Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
retrun converted string

strip_front

public int strip_front(in str, in zap)
Removes all occuences of zap from the front of str (left trim).
Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
retrun converted string

strip_trail

public int strip_trail(in str, in zap)
Removes all occuences of zap from the end of str (right trim).
Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
Returns: converted string

substr1

public int substr1(in str1, in s1, in s2)

trim

public int trim(in str1)