Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.4/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/0.9.1/ProtobufCS/src/ProtoGen/Program.cs @ 6120

Last change on this file since 6120 was 3857, checked in by abeham, 14 years ago

#866

  • Added protobuf-csharp-port project source to ExtLibs
File size: 3.4 KB
Line 
1#region Copyright notice and license
2// Protocol Buffers - Google's data interchange format
3// Copyright 2008 Google Inc.  All rights reserved.
4// http://github.com/jskeet/dotnet-protobufs/
5// Original C++/Java/Python code:
6// http://code.google.com/p/protobuf/
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12//     * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14//     * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18//     * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33#endregion
34
35using System;
36using System.Collections.Generic;
37using Google.ProtocolBuffers.DescriptorProtos;
38
39namespace Google.ProtocolBuffers.ProtoGen {
40  /// <summary>
41  /// Entry point for the Protocol Buffers generator.
42  /// </summary>
43  class Program {
44    static int Main(string[] args) {
45      try {
46        // Hack to make sure everything's initialized
47        DescriptorProtoFile.Descriptor.ToString();
48        GeneratorOptions options = ParseCommandLineArguments(args);
49
50        IList<string> validationFailures;
51        if (!options.TryValidate(out validationFailures)) {
52          // We've already got the message-building logic in the exception...
53          InvalidOptionsException exception = new InvalidOptionsException(validationFailures);
54          Console.WriteLine(exception.Message);
55          return 1;
56        }
57
58        Generator generator = Generator.CreateGenerator(options);
59        generator.Generate();
60        return 0;
61      } catch (Exception e) {
62        Console.Error.WriteLine("Error: {0}", e.Message);
63        Console.Error.WriteLine();
64        Console.Error.WriteLine("Detailed exception information: {0}", e);
65        return 1;
66      }
67    }
68
69    private static GeneratorOptions ParseCommandLineArguments(string[] args) {
70      GeneratorOptions options = new GeneratorOptions();
71      //string baseDir = "c:\\Users\\Jon\\Documents\\Visual Studio 2008\\Projects\\ProtocolBuffers";
72      //options.OutputDirectory = baseDir + "\\tmp";
73      //options.InputFiles = new[] { baseDir + "\\protos\\nwind-solo.protobin" };
74      options.OutputDirectory = ".";
75      options.InputFiles = args;
76      return options;
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.