Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeneratorHelpers.h
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // http://code.google.com/p/protobuf/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: [email protected] (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 //
35 // Edited by Simon Newton for OLA
36 
37 #ifndef PROTOC_GENERATORHELPERS_H_
38 #define PROTOC_GENERATORHELPERS_H_
39 
40 #include <google/protobuf/descriptor.h>
41 #include <google/protobuf/descriptor.pb.h>
42 #include <string>
43 
44 namespace ola {
45 
46 using std::string;
47 
48 // Commonly-used separator comments. Thick is a line of '=', thin is a line
49 // of '-'.
50 extern const char kThickSeparator[];
51 extern const char kThinSeparator[];
52 
53 // Returns the non-nested type name for the given type. If "qualified" is
54 // true, prefix the type with the full namespace. For example, if you had:
55 // package foo.bar;
56 // message Baz { message Qux {} }
57 // Then the qualified ClassName for Qux would be:
58 // ::foo::bar::Baz_Qux
59 // While the non-qualified version would be:
60 // Baz_Qux
61 string ClassName(const google::protobuf::Descriptor* descriptor,
62  bool qualified);
63 
64 // Strips ".proto" or ".protodevel" from the end of a filename.
65 string StripProto(const string& filename);
66 
67 // Convert a file name into a valid identifier.
68 string FilenameIdentifier(const string& filename);
69 
70 // Return the name of the AddDescriptors() function for a given file.
71 string GlobalAddDescriptorsName(const string& filename);
72 
73 // Return the name of the AssignDescriptors() function for a given file.
74 string GlobalAssignDescriptorsName(const string& filename);
75 
76 // Do message classes in this file have descriptor and reflection methods?
77 inline bool HasDescriptorMethods(const google::protobuf::FileDescriptor* file) {
78  return file->options().optimize_for() !=
79  google::protobuf::FileOptions::LITE_RUNTIME;
80 }
81 } // namespace ola
82 #endif // PROTOC_GENERATORHELPERS_H_