.
1 /*
2 Copyright (C) 2012, 2014 Johan Mattsson
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the
7 License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 */
14
15 namespace BirdFont {
16
17 public class UniRange : GLib.Object {
18
19 public unichar start;
20 public unichar stop;
21
22 public UniRange (unichar start, unichar stop) {
23 this.start = start;
24 this.stop = stop;
25 }
26
27 public unichar length () {
28 return stop - start + 1;
29 }
30
31 public bool has_character (unichar c) {
32 return (start <= c <= stop);
33 }
34
35 public unichar get_char (unichar index) {
36 unichar result = start + index;
37
38 if (unlikely (!(start <= result <= stop))) {
39 warning ("Index out of range in UniRange (%u <= %u <= %u) (index: %u)\n", start, result, stop, index);
40 }
41
42 return result;
43 }
44 }
45
46 }
47