14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSScanner;
|
|
8
|
|
9 import dstep.foundation.NSCharacterSet;
|
|
10 import dstep.foundation.NSDictionary;
|
|
11 import dstep.foundation.NSObject;
|
|
12 import dstep.foundation.NSString;
|
|
13 import dstep.objc.bridge.Bridge;
|
|
14 import dstep.objc.objc : id;
|
|
15
|
|
16 class NSScanner : NSObject, INSCopying
|
|
17 {
|
|
18 mixin ObjcWrap;
|
|
19 mixin TNSDecimalNumberScanning;
|
|
20 mixin TNSExtendedScanner;
|
|
21
|
|
22 NSString string ()
|
|
23 {
|
|
24 return invokeObjcSelf!(NSString, "string");
|
|
25 }
|
|
26
|
|
27 NSUInteger scanLocation ()
|
|
28 {
|
|
29 return invokeObjcSelf!(NSUInteger, "scanLocation");
|
|
30 }
|
|
31
|
|
32 void setScanLocation (NSUInteger pos)
|
|
33 {
|
|
34 return invokeObjcSelf!(void, "setScanLocation:", NSUInteger)(pos);
|
|
35 }
|
|
36
|
|
37 void setCharactersToBeSkipped (NSCharacterSet set)
|
|
38 {
|
|
39 return invokeObjcSelf!(void, "setCharactersToBeSkipped:", NSCharacterSet)(set);
|
|
40 }
|
|
41
|
|
42 void setCaseSensitive (bool flag)
|
|
43 {
|
|
44 return invokeObjcSelf!(void, "setCaseSensitive:", bool)(flag);
|
|
45 }
|
|
46
|
|
47 void setLocale (Object locale)
|
|
48 {
|
|
49 return invokeObjcSelf!(void, "setLocale:", Object)(locale);
|
|
50 }
|
|
51
|
|
52 Object copyWithZone (NSZone* zone)
|
|
53 {
|
|
54 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
55 }
|
|
56 }
|
|
57
|
|
58 template TNSExtendedScanner ()
|
|
59 {
|
|
60 NSCharacterSet charactersToBeSkipped ()
|
|
61 {
|
|
62 return invokeObjcSelf!(NSCharacterSet, "charactersToBeSkipped");
|
|
63 }
|
|
64
|
|
65 bool caseSensitive ()
|
|
66 {
|
|
67 return invokeObjcSelf!(bool, "caseSensitive");
|
|
68 }
|
|
69
|
|
70 Object locale ()
|
|
71 {
|
|
72 return invokeObjcSelf!(Object, "locale");
|
|
73 }
|
|
74
|
|
75 bool scanInt (int* value)
|
|
76 {
|
|
77 return invokeObjcSelf!(bool, "scanInt:", int*)(value);
|
|
78 }
|
|
79
|
|
80 bool scanInteger (NSInteger* value)
|
|
81 {
|
|
82 return invokeObjcSelf!(bool, "scanInteger:", NSInteger*)(value);
|
|
83 }
|
|
84
|
|
85 bool scanHexLongLong (unsigned long long* result)
|
|
86 {
|
|
87 return invokeObjcSelf!(bool, "scanHexLongLong:", unsigned long long*)(result);
|
|
88 }
|
|
89
|
|
90 bool scanHexFloat (float* result)
|
|
91 {
|
|
92 return invokeObjcSelf!(bool, "scanHexFloat:", float*)(result);
|
|
93 }
|
|
94
|
|
95 bool scanHexDouble (double* result)
|
|
96 {
|
|
97 return invokeObjcSelf!(bool, "scanHexDouble:", double*)(result);
|
|
98 }
|
|
99
|
|
100 bool scanHexInt (unsigned* value)
|
|
101 {
|
|
102 return invokeObjcSelf!(bool, "scanHexInt:", unsigned*)(value);
|
|
103 }
|
|
104
|
|
105 bool scanLongLong (long long* value)
|
|
106 {
|
|
107 return invokeObjcSelf!(bool, "scanLongLong:", long long*)(value);
|
|
108 }
|
|
109
|
|
110 bool scanFloat (float* value)
|
|
111 {
|
|
112 return invokeObjcSelf!(bool, "scanFloat:", float*)(value);
|
|
113 }
|
|
114
|
|
115 bool scanDouble (double* value)
|
|
116 {
|
|
117 return invokeObjcSelf!(bool, "scanDouble:", double*)(value);
|
|
118 }
|
|
119
|
|
120 bool scanString (NSString string, NSString** value)
|
|
121 {
|
|
122 return invokeObjcSelf!(bool, "scanString:intoString:", NSString, NSString**)(string, value);
|
|
123 }
|
|
124
|
|
125 bool scanCharactersFromSet (NSCharacterSet set, NSString** value)
|
|
126 {
|
|
127 return invokeObjcSelf!(bool, "scanCharactersFromSet:intoString:", NSCharacterSet, NSString**)(set, value);
|
|
128 }
|
|
129
|
|
130 bool scanUpToString (NSString string, NSString** value)
|
|
131 {
|
|
132 return invokeObjcSelf!(bool, "scanUpToString:intoString:", NSString, NSString**)(string, value);
|
|
133 }
|
|
134
|
|
135 bool scanUpToCharactersFromSet (NSCharacterSet set, NSString** value)
|
|
136 {
|
|
137 return invokeObjcSelf!(bool, "scanUpToCharactersFromSet:intoString:", NSCharacterSet, NSString**)(set, value);
|
|
138 }
|
|
139
|
|
140 bool isAtEnd ()
|
|
141 {
|
|
142 return invokeObjcSelf!(bool, "isAtEnd");
|
|
143 }
|
|
144
|
|
145 Object initWithString (NSString string)
|
|
146 {
|
|
147 return invokeObjcSelf!(Object, "initWithString:", NSString)(string);
|
|
148 }
|
|
149
|
|
150 this (NSString string)
|
|
151 {
|
|
152 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
153 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, string);
|
|
154
|
|
155 if (result)
|
|
156 objcObject = ret;
|
|
157
|
|
158 dObject = this;
|
|
159 }
|
|
160
|
|
161 static Object scannerWithString (NSString string)
|
|
162 {
|
|
163 return invokeObjcSelfClass!(Object, "scannerWithString:", NSString)(string);
|
|
164 }
|
|
165
|
|
166 static Object localizedScannerWithString (NSString string)
|
|
167 {
|
|
168 return invokeObjcSelfClass!(Object, "localizedScannerWithString:", NSString)(string);
|
|
169 }
|
|
170 }
|
|
171
|