ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Static Fields | Public Static Methods | List of all members
CString Class Reference

Class Description


Provides static methods working with character arrays.

Public Static Fields

static readonly char[] DefaultWhitespaces = {' ','\r','\n','\t' }
 
static readonly String NewLineChars =Environment.NewLine
 
static readonly char[] NullBuffer = new char[0]
 

Public Static Methods

static bool AdjustRegion (int referenceLength, ref int regionStart, ref int regionLength)
 
static int CompareTo (char[] needle, int needleStart, int needleLength, char[] haystack, int haystackStart, int haystackLength, Case sensitivity)
 
static int CompareTo (String needle, int needleStart, int needleLength, char[] haystack, int haystackStart, int haystackLength, Case sensitivity)
 
static bool ContainsAt (char[] needle, int needleStart, int needleLength, char[] haystack, int haystackPos, int haystackLimit, Case sensitivity=Case.Sensitive)
 
static bool ContainsAt (String needle, char[] haystack, int haystackPos, int haystackLimit, Case sensitivity=Case.Sensitive)
 
static int IndexOf (char[] haystack, char needle, int regionStart=0, int regionLength=int.MaxValue)
 
static int IndexOfAnyInRegion (char[] haystack, int regionStart, int regionLength, char[] needles, Inclusion inclusion)
 
static int IndexOfFirstDifference (char[] haystack, int haystackStart, int haystackLength, String needle, Case sensitivity)
 
static int IndexOfString (char[] needle, int needleStart, int needleLength, char[] haystack, int haystackStart, int haystackLength, Case sensitivity)
 
static int IndexOfString (String needle, char[] haystack, int haystackStart, int haystackLength, Case sensitivity)
 
static int LastIndexOfAny (char[] haystack, int regionStart, int regionLength, char[] needles, Inclusion inclusion)
 

Member Function Documentation

◆ AdjustRegion()

static bool AdjustRegion ( int  referenceLength,
ref int  regionStart,
ref int  regionLength 
)
inlinestatic

Static method that adjusts a given region to fit into the range [0 .. referenceLength].

Parameters
referenceLengthLength of the string that the given region will be adjusted to.
[in,out]regionStartThe start of the region to be adjusted.
[in,out]regionLengthThe length of the region to be adjusted.
Returns
True if adjusted range is empty.

◆ CompareTo() [1/2]

static int CompareTo ( char[]  needle,
int  needleStart,
int  needleLength,
char[]  haystack,
int  haystackStart,
int  haystackLength,
Case  sensitivity 
)
inlinestatic

Compares two regions of two char[].
No parameter checks are performed. Null and empty checks and proper region bounds have to be provided (this is a helper method for other compareTo methods).

Parameters
needleA char[] that is compared to this.
needleStartThe start of the substring within needle.
needleLengthThe length of the substring within needle.
haystackThe char[] that is to compared.
haystackStartThe start of the substring within haystack.
haystackLengthThe length of the substring within haystack.
sensitivityCase sensitivity of the operation.
Returns
  • 0 if haystack and needle are null or if both have a length of 0 or if both share the same content.
  • <0 if haystack is nulled and needle is not or if haystack is smaller than needle.
  • >0 if haystack is not nulled but needle is or if haystack is greater than needle.

◆ CompareTo() [2/2]

static int CompareTo ( String  needle,
int  needleStart,
int  needleLength,
char[]  haystack,
int  haystackStart,
int  haystackLength,
Case  sensitivity 
)
inlinestatic

Compares a region of a String with another region in a char[].
No parameter checks are performed. Null and empty checks and proper region bounds have to be provided (this is a helper method for other compareTo methods).

Parameters
needleA String that is compared to this.
needleStartThe start of the substring within needle.
needleLengthThe length of the substring within needle.
haystackThe character buffer that is to compared.
haystackStartThe start of the substring within haystack.
haystackLengthThe length of the substring within haystack.
sensitivityCase sensitivity of the operation.
Returns
  • 0 if haystack and needle are null or if both have a length of 0 or if both share the same content.
  • <0 if haystack is nulled and needle is not or if haystack is smaller than needle.
  • >0 if haystack is not nulled but needle is or if haystack is greater than needle.

◆ ContainsAt() [1/2]

static bool ContainsAt ( char[]  needle,
int  needleStart,
int  needleLength,
char[]  haystack,
int  haystackPos,
int  haystackLimit,
Case  sensitivity = Case.Sensitive 
)
inlinestatic

Checks if a region of a char[] is located at the given position of another char[].

Parameters
needleThe character array containing the needle.
needleStartThe index of the start of the needle within the character array.
needleLengthThe length of the needle within the character array.
haystackThe character array to look in for the needle.
haystackPosThe position to look at in haystack.
haystackLimitThe length of the haystack (may be equal or less than haystack.Length).
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true if the needle is found at the given position. false otherwise.

◆ ContainsAt() [2/2]

static bool ContainsAt ( String  needle,
char[]  haystack,
int  haystackPos,
int  haystackLimit,
Case  sensitivity = Case.Sensitive 
)
inlinestatic

Checks if the given String is located at the given position in a char[].

Parameters
needleThe character array containing the needle.
haystackThe character array to look in for the needle.
haystackPosThe position to look at in haystack.
haystackLimitThe length of the haystack (may be equal or less than haystack.Length.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true if the needle is found at the given position. false otherwise.

◆ IndexOf()

static int IndexOf ( char[]  haystack,
char  needle,
int  regionStart = 0,
int  regionLength = int.MaxValue 
)
inlinestatic

Static method that searches a character in a region of a character array.

Parameters
haystackCharacter array that is searched in.
needleThe character to be searched for.
regionStartThe start of the region within haystack. Defaults to 0.
regionLengthThe length of the region within haystack. Defaults to int.MaxValue.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ IndexOfAnyInRegion()

static int IndexOfAnyInRegion ( char[]  haystack,
int  regionStart,
int  regionLength,
char[]  needles,
Inclusion  inclusion 
)
inlinestatic

Static method that returns the index of the first character which is included (alternatively not included) in a given set of characters.

This method searches from left to right. For backward search, see LastIndexOfAny

Parameters
haystackCharacter array that is searched in.
regionStartThe start of the region within haystack.
regionLengthThe length of the region within haystack.
needlesCharacter array that holds the characters to be searched for.
inclusionDenotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters.
Returns
The index (relative to the start of the region) of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ IndexOfFirstDifference()

static int IndexOfFirstDifference ( char[]  haystack,
int  haystackStart,
int  haystackLength,
String  needle,
Case  sensitivity 
)
inlinestatic

Static method that returns the index of the first character which not equal within two strings. If haystack starts with needle, then the length of needle is returned.

Parameters
haystackCharacter array that is searched in.
haystackStartThe start of the region within haystack.
haystackLengthThe length of the region within haystack.
needleThe string to be searched for.
sensitivityThe sensitivity to the case of characters of the operation.
Returns
The index within needle with the first difference.

◆ IndexOfString() [1/2]

static int IndexOfString ( char[]  needle,
int  needleStart,
int  needleLength,
char[]  haystack,
int  haystackStart,
int  haystackLength,
Case  sensitivity 
)
inlinestatic

Search the given AString in a region of a character array.

Parameters
needleThe string to be searched for.
needleStartThe start of the region within haystack.
needleLengthThe length of the region within haystack.
haystackCharacter array that is searched in.
haystackStartThe start of the region within haystack.
haystackLengthThe length of the region within haystack.
sensitivityThe sensitivity to the case of characters of the operation.
Returns
-1 if the String is not found. Otherwise the index of first occurrence relative to haystackStart.

◆ IndexOfString() [2/2]

static int IndexOfString ( String  needle,
char[]  haystack,
int  haystackStart,
int  haystackLength,
Case  sensitivity 
)
inlinestatic

Search the given String in a region of a character array.

Parameters
needleThe string to be searched for.
haystackCharacter array that is searched in.
haystackStartThe start of the region within haystack.
haystackLengthThe length of the region within haystack.
sensitivityThe sensitivity to the case of characters of the operation.
Returns
-1 if the String is not found. Otherwise the index of first occurrence relative to haystackStart.

◆ LastIndexOfAny()

static int LastIndexOfAny ( char[]  haystack,
int  regionStart,
int  regionLength,
char[]  needles,
Inclusion  inclusion 
)
inlinestatic

Static method that returns the index of the first character which is included (alternatively not included) in a given set of characters. The search starts at the end of the region and continues towards its start.

Parameters
haystackCharacer array to search in.
regionStartThe start of the region within haystack.
regionLengthThe length of the region within haystack.
needlesCharacer array that holds the characters to be searched for.
inclusionDenotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters.
Returns
The index relative to the start of the region. If the search was not successful, then regionStart -1 is returned;

Member Data Documentation

◆ DefaultWhitespaces

readonly char [] DefaultWhitespaces = {' ','\r','\n','\t' }
static

Contains all characters that by default get trimmed by trim methods defined in this class.

◆ NewLineChars

readonly String NewLineChars =Environment.NewLine
static

The system depended new line character codes retrieved statically (once) using "Environment.NewLine;"

◆ NullBuffer

readonly char [] NullBuffer = new char[0]
static

A singleton that references a zero-length character array. May be used to avoid object allocation.


The documentation for this class was generated from the following file: