CharClass (class)
public CharClass {inherits CharClassInterface, {CharMap bool}}
Package: CURL.LANGUAGE.STRINGS

An immutable set of characters. Its main purpose is to respond efficiently to queries about membership in the set; see CharClass.member?.

Programming Notes

CharClass is initialized with a series of CharClassInterface and String arguments. It records the union of these in an efficient internal representation, ready to be queried by CharClass.member?.

Constructors
default:Initializes a new CharClass.
constructor public {CharClass.default ...:any}
from-any:Construct a new CharClass from a char, String, CharClass or WCharClass.
factory public implicit {CharClass.from-any arg:any}:CharClass
Properties
Properties inherited from CharMapInterface: mutable?
Class Variables and Constants
digit-chars:Provides the CharClass containing the ASCII digit characters, which are the values '0' through '9'.
public constant CharClass.digit-chars:CharClass ={make-digit-chars}
letter-chars:Provides the CharClass containing the Unicode letter characters.
public constant CharClass.letter-chars:CharClass ={make-letter-chars}
whitespace-chars:Provides the CharClass containing the Unicode whitespace characters, which are the values '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u0020' plus several non-ASCII whitespace values.
public constant CharClass.whitespace-chars:CharClass ={make-whitespace-chars}
Methods
clone-writable:Converts this class to a mutable version of itself. Changes made to the returned object will not affect the original.
public {CharClass.clone-writable}:WritableCharClass
complement-clone:Returns a clone containing the complement of self.
public {CharClass.complement-clone}:CharClass
difference-clone:Returns a clone containing the difference between self and zero or more CharClassInterfaces.
public {CharClass.difference-clone ...:CharClassInterface}:CharClass
fold:Creates a new CharClassInterface with member characters mapped according to a supplied procedure.
public {CharClass.fold
    folder:{proc-type {char}:char}
}:CharClassInterface
intersect-clone:Returns a clone containing the intersection of self and zero or more CharClassInterfaces.
public {CharClass.intersect-clone ...:CharClassInterface}:CharClass
member?:Determines whether a character is a member of the class. Returns true if and only if the character is a member.
public final inline {CharClass.member? ch:char}:bool
union-clone:Returns a clone containing the union of self and zero or more CharClassInterfaces.
public {CharClass.union-clone ...:CharClassInterface}:CharClass
Methods inherited from CharClassInterface: to-Iterator
Methods inherited from _WCharMap: get
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Constructor Details
default (constructor)
public {CharClass.default ...:any}

Initializes a new CharClass.



from-any (factory)
public implicit {CharClass.from-any arg:any}:CharClass

Construct a new CharClass from a char, String, CharClass or WCharClass.



Property DetailsClass Variable and Constant Details
digit-chars (class constant)
public constant CharClass.digit-chars:CharClass ={make-digit-chars}

Provides the CharClass containing the ASCII digit characters, which are the values '0' through '9'.



letter-chars (class constant)
public constant CharClass.letter-chars:CharClass ={make-letter-chars}

Provides the CharClass containing the Unicode letter characters.



whitespace-chars (class constant)
public constant CharClass.whitespace-chars:CharClass ={make-whitespace-chars}

Provides the CharClass containing the Unicode whitespace characters, which are the values '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u0020' plus several non-ASCII whitespace values.



Method Details
clone-writable (method)
public {CharClass.clone-writable}:WritableCharClass

Converts this class to a mutable version of itself. Changes made to the returned object will not affect the original.

Returns

The WritableCharClass with members identical to those of self.


complement-clone (method)
public {CharClass.complement-clone}:CharClass

Returns a clone containing the complement of self.

Returns

An instance of CharClassInterface.

Description

Returns a clone which will be true for each character that self is false and false for any character that self is true.

Notes

The type returned may not be the same type as self.


difference-clone (method)
public {CharClass.difference-clone ...:CharClassInterface}:CharClass

Returns a clone containing the difference between self and zero or more CharClassInterfaces.

...: the rest arguments specify the CharClassInterfaces from which you want to form the difference.

Returns

An instance of CharClassInterface.

Description

Returns a clone which will be true for each character that self is true and all of arguments are false for.

Notes

The type returned may not be the same type as self.


fold (method)
public {CharClass.fold
    folder:{proc-type {char}:char}
}:CharClassInterface

Creates a new CharClassInterface with member characters mapped according to a supplied procedure.

folder: The procedure that maps member characters. The folder is called once for every character that is a member of the class.

Returns

The returned CharClassInterface contains only those characters that folder returned at least once.

Description

It is not possible for the returned CharClassInterface to have more member characters than the original object.

Notes

This can iterate over many values for CharClassInterfaces with many characters that map to true, including CharClassInterfaces created by CharClassInterface.complement-clone.


intersect-clone (method)
public {CharClass.intersect-clone ...:CharClassInterface}:CharClass

Returns a clone containing the intersection of self and zero or more CharClassInterfaces.

...: the rest arguments specify the CharClassInterfaces from which you want to form the intersection.

Returns

An instance of CharClassInterface.

Description

Returns a clone which will be true for each character that self and all of arguments are true for.

Notes

The type returned may not be the same type as self.


member? (method)
public final inline {CharClass.member? ch:char}:bool

Determines whether a character is a member of the class. Returns true if and only if the character is a member.

ch: The character whose membership is to be tested.


union-clone (method)
public {CharClass.union-clone ...:CharClassInterface}:CharClass

Returns a clone containing the union of self and zero or more CharClassInterfaces.

...: the rest arguments specify the CharClassInterfaces from which you want to form the union.

Returns

An instance of CharClassInterface.

Description

Returns a clone which will be true for each character that self or any of the arguments is true for.

Notes

The type returned may not be the same type as self.