int main()

in tools/ODataEntityGenerator/ODataEntityGenerator/main.m [32:82]


int main(int argc, const char * argv[]) {

    @autoreleasepool {

        NSUserDefaults *appParams = [NSUserDefaults standardUserDefaults];
        
        NSString *inputURLString = [appParams stringForKey:paramURL];
        NSURL *inputURL = (inputURLString != nil ? [NSURL URLWithString:inputURLString] : nil);
        if (inputURL == nil)
        {
            inputURLString = [appParams stringForKey:paramFile];
            inputURL = (inputURLString != nil ? [[NSURL alloc] initFileURLWithPath:inputURLString] : nil);
        }

        if (inputURL == nil)
            inputURL = [NSURL URLWithString:@"http://services.odata.org/OData/OData.svc/$metadata"];
        
        NSString *outputPath = [appParams stringForKey:paramOutput];
        
        if (inputURL!=nil && outputPath!=nil)
        {
            // validate the output directory
            BOOL isDir;
            if ([[NSFileManager defaultManager] fileExistsAtPath:outputPath isDirectory:&isDir] && (!isDir)) {
                printf("Problems with the output dir");
                return 1;
            }
            
            // validate the input xml
            NSError *error = nil;
            NSXMLDocument *xmlDom = [[NSXMLDocument alloc] initWithContentsOfURL:inputURL options:NSXMLDocumentValidate error:&error];
            if (xmlDom == nil) {
                printf("Problems with the input: %s", [[error description] cStringUsingEncoding:NSUTF8StringEncoding]);
                return 1;
            }
            
            NSDictionary *entityDescriptors = [SMDParser entityDescriptorsFromSMD:xmlDom];
            
            [EntityGenerator writeEntities:entityDescriptors toFolder:outputPath];
            
            [ServiceGenerator writeEntities:entityDescriptors toFolder:outputPath];
            
            printf("\ndone");
        }
        else {
            PresentUsageInformation();
        }
    }
    
    return 0;
}