~ubuntu-branches/ubuntu/oneiric/protobuf/oneiric

« back to all changes in this revision

Viewing changes to src/google/protobuf/compiler/cpp/cpp_helpers.h

  • Committer: Bazaar Package Importer
  • Author(s): Iustin Pop
  • Date: 2008-08-03 11:01:44 UTC
  • Revision ID: james.westby@ubuntu.com-20080803110144-uyiw41bf1m2oe17t
Tags: upstream-2.0.0~b
ImportĀ upstreamĀ versionĀ 2.0.0~b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Protocol Buffers - Google's data interchange format
 
2
// Copyright 2008 Google Inc.
 
3
// http://code.google.com/p/protobuf/
 
4
//
 
5
// Licensed under the Apache License, Version 2.0 (the "License");
 
6
// you may not use this file except in compliance with the License.
 
7
// You may obtain a copy of the License at
 
8
//
 
9
//      http://www.apache.org/licenses/LICENSE-2.0
 
10
//
 
11
// Unless required by applicable law or agreed to in writing, software
 
12
// distributed under the License is distributed on an "AS IS" BASIS,
 
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
// See the License for the specific language governing permissions and
 
15
// limitations under the License.
 
16
 
 
17
// Author: kenton@google.com (Kenton Varda)
 
18
//  Based on original Protocol Buffers design by
 
19
//  Sanjay Ghemawat, Jeff Dean, and others.
 
20
 
 
21
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
 
22
#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
 
23
 
 
24
#include <string>
 
25
#include <google/protobuf/descriptor.h>
 
26
 
 
27
namespace google {
 
28
namespace protobuf {
 
29
namespace compiler {
 
30
namespace cpp {
 
31
 
 
32
// Commonly-used separator comments.  Thick is a line of '=', thin is a line
 
33
// of '-'.
 
34
extern const char kThickSeparator[];
 
35
extern const char kThinSeparator[];
 
36
 
 
37
// Returns the non-nested type name for the given type.  If "qualified" is
 
38
// true, prefix the type with the full namespace.  For example, if you had:
 
39
//   package foo.bar;
 
40
//   message Baz { message Qux {} }
 
41
// Then the qualified ClassName for Qux would be:
 
42
//   ::foo::bar::Baz_Qux
 
43
// While the non-qualified version would be:
 
44
//   Baz_Qux
 
45
string ClassName(const Descriptor* descriptor, bool qualified);
 
46
string ClassName(const EnumDescriptor* enum_descriptor, bool qualified);
 
47
 
 
48
// Get the (unqualified) name that should be used for this field in C++ code.
 
49
// The name is coerced to lower-case to emulate proto1 behavior.  People
 
50
// should be using lowercase-with-underscores style for proto field names
 
51
// anyway, so normally this just returns field->name().
 
52
string FieldName(const FieldDescriptor* field);
 
53
 
 
54
// Returns the scope where the field was defined (for extensions, this is
 
55
// different from the message type to which the field applies).
 
56
inline const Descriptor* FieldScope(const FieldDescriptor* field) {
 
57
  return field->is_extension() ?
 
58
    field->extension_scope() : field->containing_type();
 
59
}
 
60
 
 
61
// Strips ".proto" or ".protodevel" from the end of a filename.
 
62
string StripProto(const string& filename);
 
63
 
 
64
// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
 
65
// Note:  non-built-in type names will be qualified, meaning they will start
 
66
// with a ::.  If you are using the type as a template parameter, you will
 
67
// need to insure there is a space between the < and the ::, because the
 
68
// ridiculous C++ standard defines "<:" to be a synonym for "[".
 
69
const char* PrimitiveTypeName(FieldDescriptor::CppType type);
 
70
 
 
71
// Get the declared type name in CamelCase format, as is used e.g. for the
 
72
// methods of WireFormat.  For example, TYPE_INT32 becomes "Int32".
 
73
const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
 
74
 
 
75
// Convert a file name into a valid identifier.
 
76
string FilenameIdentifier(const string& filename);
 
77
 
 
78
// Return the name of the BuildDescriptors() function for a given file.
 
79
string GlobalBuildDescriptorsName(const string& filename);
 
80
 
 
81
}  // namespace cpp
 
82
}  // namespace compiler
 
83
}  // namespace protobuf
 
84
 
 
85
}  // namespace google
 
86
#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__