summaryrefslogtreecommitdiff
path: root/libtnsl/box/string.tnsl
blob: c364e6a58afa3b434ed432c6101e342cc67e0362 (plain)
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
/#
  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
#/

;enum TEXT_ENCODING [uint] {
	UTF_8,
	UN7_1,
	ASCII
}

;struct String extends Vector(uint8) {
	uint encoding
}

/; method String
	# Returns index of first difference, or -1 if there is no difference
	/; diff_index (String str) [int]
		;uint l = math.mint(uint, str.length, self.length)
		/; loop (uint i = 0; i < l) [i++]
			/; if (self{i} != str{i})
				;return i [int]
			;/
		;/

		/; if ()

		;/

		;return -1
	;/

	/; override operator == (String str) [bool]
		/; if (self.encoding != str.encoding || self.length != str.length)
			;return false
		;/
		;return diff_index(str) == -1
	;/
;/