Browse code

Convenience methods to create template from char[];

Nat! authored on 16-04-2016 15:48:01
Showing 5 changed files
... ...
@@ -1362,7 +1362,6 @@
1362 1362
 				415DA5A5182BC9E300F654F7 /* All */,
1363 1363
 				41770103190175F6002D0221 /* Show Documentation in Browser */,
1364 1364
 				415DA5B4182BCAAF00F654F7 /* OSX */,
1365
-				415DA5B9182BCAB500F654F7 /* iOS */,
1366 1365
 				41764B8B16DA511200560FCF /* mulle-scion */,
1367 1366
 				41D6DF5B16DE53AE004833D6 /* MulleScion (OSX Framework) */,
1368 1367
 				41D6DF2316DE523D004833D6 /* MulleScion (OSX Library) */,
... ...
@@ -1370,6 +1369,7 @@
1370 1369
 				41AEA1F6182D097300840887 /* MulleScionGraphviz (OSX Library) */,
1371 1370
 				41D6DF0316DE51C9004833D6 /* MulleScionParser (OSX Library) */,
1372 1371
 				41D6DED816DE509E004833D6 /* MulleScionPrinter (OSX Library) */,
1372
+				415DA5B9182BCAB500F654F7 /* iOS */,
1373 1373
 				410300711701DBE200197713 /* MulleScion (iOS Library) */,
1374 1374
 				411EEAA6182D311F00361ADF /* MulleScionFoundation (iOS Library) */,
1375 1375
 				412E7FD0182D2F80008A7FCC /* MulleScionGraphviz (iOS Library) */,
... ...
@@ -65,6 +65,8 @@
65 65
  */
66 66
 @interface MulleScionTemplate ( Convenience)
67 67
 
68
+- (id) initWithUTF8String:(unsigned char *) s;
69
+
68 70
 - (id) initWithFile:(NSString *) fileName;            // template or archive
69 71
 
70 72
 - (id) initWithContentsOfFile:(NSObject <MulleScionStringOrURL> *) fileName;
... ...
@@ -86,6 +88,14 @@
86 88
 + (NSString *) descriptionWithTemplateFile:(NSObject <MulleScionStringOrURL> *) fileName
87 89
                           propertyListFile:(NSObject <MulleScionStringOrURL> *) plistFileName;
88 90
 
91
++ (NSString *) descriptionWithUTF8Template:(unsigned char *) s
92
+                                dataSource:(id <MulleScionDataSource>) dataSource
93
+                            localVariables:(NSDictionary *) locals;
94
+
95
+
96
++ (NSString *) descriptionWithUTF8Template:(unsigned char *) s
97
+                                dataSource:(id <MulleScionDataSource>) dataSource;
98
+
89 99
 
90 100
 + (BOOL) writeToOutput:(id <MulleScionOutput>) output
91 101
           templateFile:(NSObject <MulleScionStringOrURL> *) fileName
... ...
@@ -93,6 +93,29 @@ char  MulleScionFrameworkVersion[] = STRINGIFY( PROJECT_VERSION);
93 93
 }
94 94
 
95 95
 
96
++ (NSString *) descriptionWithUTF8Template:(unsigned char *) s
97
+                                dataSource:(id <MulleScionDataSource>) dataSource
98
+                            localVariables:(NSDictionary *) locals
99
+{
100
+   MulleScionTemplate   *template;
101
+   
102
+   template = [[[MulleScionTemplate alloc] initWithUTF8String:s] autorelease];
103
+   if( ! template)
104
+      return( nil);
105
+   return( [template descriptionWithDataSource:dataSource
106
+                                localVariables:locals]);
107
+}
108
+
109
+
110
++ (NSString *) descriptionWithUTF8Template:(unsigned char *) s
111
+                                dataSource:(id <MulleScionDataSource>) dataSource
112
+{
113
+   return( [self descriptionWithUTF8Template:s
114
+                                  dataSource:dataSource
115
+                              localVariables:nil]);
116
+}
117
+
118
+
96 119
 static id   acquirePropertyList( NSObject <MulleScionStringOrURL> *s)
97 120
 {
98 121
    NSData    *data;
... ...
@@ -150,6 +173,18 @@ static id   acquirePropertyList( NSObject <MulleScionStringOrURL> *s)
150 173
 }
151 174
 
152 175
 
176
+- (id) initWithUTF8String:(unsigned char *) s
177
+{
178
+   MulleScionParser   *parser;
179
+
180
+   parser = [MulleScionParser parserWithUTF8String:s];
181
+   [self autorelease];
182
+   
183
+   self = [[parser template] retain];
184
+   return( self);
185
+}
186
+
187
+
153 188
 - (id) _initWithContentsOfFile:(NSString *) fileName
154 189
 {
155 190
    MulleScionParser   *parser;
... ...
@@ -47,6 +47,8 @@
47 47
    NSString   *fileName_;
48 48
 }
49 49
 
50
++ (MulleScionParser *) parserWithUTF8String:(unsigned char *) s;
51
+
50 52
 + (MulleScionParser *) parserWithContentsOfFile:(NSString *) fileName;
51 53
 + (MulleScionParser *) parserWithContentsOfURL:(NSURL *) url;
52 54
 
... ...
@@ -94,6 +94,21 @@
94 94
 }
95 95
 
96 96
 
97
++ (MulleScionParser *) parserWithUTF8String:(unsigned char *) s
98
+{
99
+   NSData            *data;
100
+   MulleScionParser  *parser;
101
+   
102
+   data = [[[NSData alloc] initWithBytesNoCopy:s
103
+                                       length:strlen( s)
104
+                                 freeWhenDone:NO] autorelease];
105
+   parser = [[[self alloc] initWithData:data
106
+                               fileName:@"unknown.scion"] autorelease];
107
+   return( parser);
108
+}
109
+
110
+
111
+
97 112
 + (MulleScionParser *) parserWithContentsOfFile:(NSString *) path
98 113
 {
99 114
    NSData            *data;