objectivec_helpers.h

This section contains reference documentation for working with protocol buffer classes in C++.

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace google::protobuf::compiler::objectivec

Helper functions for generating ObjectiveC code.

Classes in this file

Generator options (see objectivec_generator.cc for a description of each):
Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.
Helper for parsing simple files.
Helper class for parsing framework import mappings and generating import statements.

File Members

These definitions are not part of any class.
enum
ObjectiveCType
enum
FlagType
const char *const
ProtobufLibraryFrameworkName
The name the commonly used by the library when built as a framework. more...
std::string
EscapeTrigraphs(const std::string & to_escape)
Escape C++ trigraphs by escaping question marks to "\?".
void
TrimWhitespace(StringPiece * input)
Remove white space from either end of a StringPiece.
bool
IsRetainedName(const std::string & name)
Returns true if the name requires a ns_returns_not_retained attribute applied to it.
bool
IsInitName(const std::string & name)
Returns true if the name starts with "init" and will need to have special handling under ARC.
std::string
FileClassPrefix(const FileDescriptor * file)
Gets the objc_class_prefix.
std::string
FilePath(const FileDescriptor * file)
Gets the path of the file we're going to generate (sans the .pb.h extension). more...
std::string
FilePathBasename(const FileDescriptor * file)
Just like FilePath(), but without the directory part.
std::string
FileClassName(const FileDescriptor * file)
Gets the name of the root class we'll generate in the file. more...
std::string
ClassName(const Descriptor * descriptor)
These return the fully-qualified class name corresponding to the given descriptor.
std::string
ClassName(const Descriptor * descriptor, std::string * out_suffix_added)
std::string
EnumName(const EnumDescriptor * descriptor)
std::string
EnumValueName(const EnumValueDescriptor * descriptor)
Returns the fully-qualified name of the enum value corresponding to the the descriptor.
std::string
EnumValueShortName(const EnumValueDescriptor * descriptor)
Returns the name of the enum value corresponding to the descriptor.
std::string
UnCamelCaseEnumShortName(const std::string & name)
Reverse what an enum does.
std::string
ExtensionMethodName(const FieldDescriptor * descriptor)
Returns the name to use for the extension (used as the method off the file's Root class).
std::string
FieldName(const FieldDescriptor * field)
Returns the transformed field name.
std::string
FieldNameCapitalized(const FieldDescriptor * field)
std::string
OneofEnumName(const OneofDescriptor * descriptor)
Returns the transformed oneof name.
std::string
OneofName(const OneofDescriptor * descriptor)
std::string
OneofNameCapitalized(const OneofDescriptor * descriptor)
std::string
ObjCClass(const std::string & class_name)
Returns a symbol that can be used in C code to refer to an Objective C class without initializing the class.
std::string
ObjCClassDeclaration(const std::string & class_name)
Declares an Objective C class without initializing the class so that it can be refrerred to by ObjCClass.
bool
HasPreservingUnknownEnumSemantics(const FileDescriptor * file)
bool
IsMapEntryMessage(const Descriptor * descriptor)
std::string
UnCamelCaseFieldName(const std::string & name, const FieldDescriptor * field)
Reverse of the above.
template std::string
GetOptionalDeprecatedAttribute(const TDescriptor * descriptor, const FileDescriptor * file = NULL, bool preSpace = true, bool postNewline = false)
std::string
GetCapitalizedType(const FieldDescriptor * field)
ObjectiveCType
GetObjectiveCType(FieldDescriptor::Type field_type)
ObjectiveCType
GetObjectiveCType(const FieldDescriptor * field)
bool
IsPrimitiveType(const FieldDescriptor * field)
bool
IsReferenceType(const FieldDescriptor * field)
std::string
GPBGenericValueFieldName(const FieldDescriptor * field)
std::string
DefaultValue(const FieldDescriptor * field)
bool
HasNonZeroDefaultValue(const FieldDescriptor * field)
std::string
BuildFlagsString(const FlagType type, const std::vector< std::string > & strings)
std::string
BuildCommentsString(const SourceLocation & location, bool prefer_single_line)
Builds HeaderDoc/appledoc style comments out of the comments in the .proto file.
std::string
ProtobufFrameworkImportSymbol(const std::string & framework_name)
Returns the CPP symbol name to use as the gate for framework style imports for the given framework name to use.
bool
IsProtobufLibraryBundledProtoFile(const FileDescriptor * file)
Checks if the file is one of the proto's bundled with the library.
bool
ValidateObjCClassPrefixes(const std::vector< const FileDescriptor * > & files, const Options & generation_options, std::string * out_error)
Checks the prefix for the given files and outputs any warnings as needed. more...
bool
ParseSimpleFile(const std::string & path, LineConsumer * line_consumer, std::string * out_error)

enum objectivec::ObjectiveCType {
  OBJECTIVECTYPE_INT32,
  OBJECTIVECTYPE_UINT32,
  OBJECTIVECTYPE_INT64,
  OBJECTIVECTYPE_UINT64,
  OBJECTIVECTYPE_FLOAT,
  OBJECTIVECTYPE_DOUBLE,
  OBJECTIVECTYPE_BOOLEAN,
  OBJECTIVECTYPE_STRING,
  OBJECTIVECTYPE_DATA,
  OBJECTIVECTYPE_ENUM,
  OBJECTIVECTYPE_MESSAGE
}

OBJECTIVECTYPE_INT32
OBJECTIVECTYPE_UINT32
OBJECTIVECTYPE_INT64
OBJECTIVECTYPE_UINT64
OBJECTIVECTYPE_FLOAT
OBJECTIVECTYPE_DOUBLE
OBJECTIVECTYPE_BOOLEAN
OBJECTIVECTYPE_STRING
OBJECTIVECTYPE_DATA
OBJECTIVECTYPE_ENUM
OBJECTIVECTYPE_MESSAGE

enum objectivec::FlagType {
  FLAGTYPE_DESCRIPTOR_INITIALIZATION,
  FLAGTYPE_EXTENSION,
  FLAGTYPE_FIELD
}

FLAGTYPE_DESCRIPTOR_INITIALIZATION
FLAGTYPE_EXTENSION
FLAGTYPE_FIELD

const char *const objectivec::ProtobufLibraryFrameworkName

The name the commonly used by the library when built as a framework.

This lines up to the name used in the CocoaPod.


std::string objectivec::FilePath(
        const FileDescriptor * file)

Gets the path of the file we're going to generate (sans the .pb.h extension).

The path will be dependent on the objectivec package declared in the proto package.


std::string objectivec::FileClassName(
        const FileDescriptor * file)

Gets the name of the root class we'll generate in the file.

This class is not meant for external consumption, but instead contains helpers that the rest of the classes need


bool objectivec::ValidateObjCClassPrefixes(
        const std::vector< const FileDescriptor * > & files,
        const Options & generation_options,
        std::string * out_error)

Checks the prefix for the given files and outputs any warnings as needed.

If there are flat out errors, then out_error is filled in with the first error and the result is false.

struct Options

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace google::protobuf::compiler::objectivec

Generator options (see objectivec_generator.cc for a description of each):

Members

std::string
expected_prefixes_path
std::vector< std::string >
expected_prefixes_suppressions
std::string
generate_for_named_framework
std::string
named_framework_to_proto_path_mappings_path
std::string
runtime_import_prefix
Options()

class TextFormatDecodeData

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace google::protobuf::compiler::objectivec

Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.

Members

TextFormatDecodeData()
~TextFormatDecodeData()
TextFormatDecodeData(const TextFormatDecodeData & )
TextFormatDecodeData &
operator=(const TextFormatDecodeData & )
void
AddString(int32 key, const std::string & input_for_decode, const std::string & desired_output)
size_t
num_entries() const
std::string
Data() const
static std::string
DecodeDataForString(const std::string & input_for_decode, const std::string & desired_output)

class LineConsumer

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace google::protobuf::compiler::objectivec

Helper for parsing simple files.

Members

LineConsumer()
virtual
~LineConsumer()
virtual bool
ConsumeLine(const StringPiece & line, std::string * out_error) = 0

class ImportWriter

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace google::protobuf::compiler::objectivec

Helper class for parsing framework import mappings and generating import statements.

Members

ImportWriter(const std::string & generate_for_named_framework, const std::string & named_framework_to_proto_path_mappings_path, const std::string & runtime_import_prefix, bool include_wkt_imports)
~ImportWriter()
void
AddFile(const FileDescriptor * file, const std::string & header_extension)
void
Print(io::Printer * printer) const
static void
PrintRuntimeImports(io::Printer * printer, const std::vector< std::string > & header_to_import, const std::string & runtime_import_prefix, bool default_cpp_symbol = false)