File: Char.sc

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (113 lines) | stat: -rw-r--r-- 2,156 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Char : Magnitude {

	const <nl = $\n ;
	const <ret = $\r ;
	const <vtab = $\v ;
	const <ff = $\f ;
	const <tab = $\t ;
	const <space = $  ;
	const <comma = $, ;
	const <bullet = $* ;
	const <binaryOpCharacters = "!@%&*-+=|<>?/";

	*new { ^this.shouldNotImplement(thisMethod) }
	// to create a Char use the Integer methods asAscii or asDigit

	hash { _ObjectHash; ^this.primitiveFailed }

	ascii {
		// returns the ascii value of a character as an Integer
		_AsciiValue
		^this.primitiveFailed
	}
	digit {
		// returns the digit value of a character as an Integer
		_DigitValue
		^this.primitiveFailed
	}
	asAscii { ^this }
	// this returns the single unicode value.
	// ascii is a subset of unicode
	asUnicode { ^this.ascii }
	// case conversion
	toUpper {
		_ToUpper
		^this.primitiveFailed
	}
	toLower {
		_ToLower
		^this.primitiveFailed
	}

	// tests return Boolean:
	isAlpha {
		// is an alphabetic character
		_IsAlpha
		^this.primitiveFailed
	}
	isAlphaNum {
		// is an alphabetic character or decimal digit
		_IsAlphaNum
		^this.primitiveFailed
	}
	isPrint {
		// is printable
		_IsPrint
		^this.primitiveFailed
	}
	isPunct {
		// is punctuation
		_IsPunct
		^this.primitiveFailed
	}
	isControl {
		// is a control character
		_IsControl
		^this.primitiveFailed
	}
	isSpace {
		// is white space
		_IsSpace
		^this.primitiveFailed
	}
	isVowel {
		^"AEIOU".includes(this.toUpper);
	}
	isDecDigit {
		// is a decimal digit 0-9
		_IsDecDigit
		^this.primitiveFailed
	}
	isUpper {
		// is upper case alphabetic character
		_IsUpper
		^this.primitiveFailed
	}
	isLower {
		// is lower case alphabetic character
		_IsLower
		^this.primitiveFailed
	}
	isFileSafe {
		if(this.isPrint.not,{ ^false });
		^this.ascii != 47 and: {this.ascii != 58} and: {this.ascii != 34}
	}
	isPathSeparator {
		^thisProcess.platform.isPathSeparator(this)
	}
	< { arg aChar;
		^this.ascii < aChar.ascii
	}
	== { arg aChar;  ^aChar respondsTo: \ascii and: { this.ascii == aChar.ascii } }

	++ { |that| ^this.asString ++ that }

	printOn { arg stream;
		stream.put(this);
	}
	storeOn { arg stream;
		stream.putAll(this.asCompileString);
	}

	archiveAsCompileString { ^true }
}