25#ifndef __PROTOBUF_HELPER_H__
26#define __PROTOBUF_HELPER_H__
35#define protobuf_field_type_VALUE_STRING_LIST(XXX) \
36 XXX(PROTOBUF_TYPE_NONE, 0, "") \
37 XXX(PROTOBUF_TYPE_DOUBLE, 1, "double") \
38 XXX(PROTOBUF_TYPE_FLOAT, 2, "float") \
39 XXX(PROTOBUF_TYPE_INT64, 3, "int64") \
40 XXX(PROTOBUF_TYPE_UINT64, 4, "uint64") \
41 XXX(PROTOBUF_TYPE_INT32, 5, "int32") \
42 XXX(PROTOBUF_TYPE_FIXED64, 6, "fixed64") \
43 XXX(PROTOBUF_TYPE_FIXED32, 7, "fixed32") \
44 XXX(PROTOBUF_TYPE_BOOL, 8, "bool") \
45 XXX(PROTOBUF_TYPE_STRING, 9, "string") \
46 XXX(PROTOBUF_TYPE_GROUP, 10, "group") \
47 XXX(PROTOBUF_TYPE_MESSAGE, 11, "message") \
48 XXX(PROTOBUF_TYPE_BYTES, 12, "bytes") \
49 XXX(PROTOBUF_TYPE_UINT32, 13, "uint32") \
50 XXX(PROTOBUF_TYPE_ENUM, 14, "enum") \
51 XXX(PROTOBUF_TYPE_SFIXED32, 15, "sfixed32") \
52 XXX(PROTOBUF_TYPE_SFIXED64, 16, "sfixed64") \
53 XXX(PROTOBUF_TYPE_SINT32, 17, "sint32") \
54 XXX(PROTOBUF_TYPE_SINT64, 18, "sint64")
56#define PROTOBUF_MAX_FIELD_TYPE 18
58VALUE_STRING_ENUM(protobuf_field_type);
59VALUE_STRING_ARRAY_GLOBAL_DCL(protobuf_field_type);
62typedef struct PbwDescriptorPool PbwDescriptorPool;
64typedef struct PbwMethodDescriptor PbwMethodDescriptor;
66typedef struct PbwDescriptor PbwDescriptor;
68typedef struct PbwFieldDescriptor PbwFieldDescriptor;
70typedef struct PbwEnumDescriptor PbwEnumDescriptor;
72typedef struct PbwEnumValueDescriptor PbwEnumValueDescriptor;
74typedef void(*pbw_report_error_cb_t)(
const char *msg_format, ...);
86pbw_load_proto_file(PbwDescriptorPool* pool,
const char* filename);
89const PbwMethodDescriptor*
90pbw_DescriptorPool_FindMethodByName(
const PbwDescriptorPool* pool,
const char* name);
94pbw_MethodDescriptor_name(
const PbwMethodDescriptor* method);
98pbw_MethodDescriptor_full_name(
const PbwMethodDescriptor* method);
102pbw_MethodDescriptor_input_type(
const PbwMethodDescriptor* method);
106pbw_MethodDescriptor_output_type(
const PbwMethodDescriptor* method);
110pbw_DescriptorPool_FindMessageTypeByName(
const PbwDescriptorPool* pool,
const char* name);
114pbw_Descriptor_name(
const PbwDescriptor* message);
118pbw_Descriptor_full_name(
const PbwDescriptor* message);
122pbw_Descriptor_field_count(
const PbwDescriptor* message);
125const PbwFieldDescriptor*
126pbw_Descriptor_field(
const PbwDescriptor* message,
int field_index);
129const PbwFieldDescriptor*
130pbw_Descriptor_FindFieldByNumber(
const PbwDescriptor* message,
int number);
133const PbwFieldDescriptor*
134pbw_Descriptor_FindFieldByName(
const PbwDescriptor* message,
const char* name);
138pbw_FieldDescriptor_full_name(
const PbwFieldDescriptor* field);
142pbw_FieldDescriptor_name(
const PbwFieldDescriptor* field);
146pbw_FieldDescriptor_number(
const PbwFieldDescriptor* field);
150pbw_FieldDescriptor_type(
const PbwFieldDescriptor* field);
154pbw_FieldDescriptor_is_repeated(
const PbwFieldDescriptor* field);
158pbw_FieldDescriptor_is_packed(
const PbwFieldDescriptor* field);
162pbw_FieldDescriptor_typeName(
int field_type);
166pbw_FieldDescriptor_message_type(
const PbwFieldDescriptor* field);
169const PbwEnumDescriptor*
170pbw_FieldDescriptor_enum_type(
const PbwFieldDescriptor* field);
174pbw_FieldDescriptor_is_required(
const PbwFieldDescriptor* field);
179pbw_FieldDescriptor_has_default_value(
const PbwFieldDescriptor* field);
183pbw_FieldDescriptor_default_value_int32(
const PbwFieldDescriptor* field);
187pbw_FieldDescriptor_default_value_int64(
const PbwFieldDescriptor* field);
191pbw_FieldDescriptor_default_value_uint32(
const PbwFieldDescriptor* field);
195pbw_FieldDescriptor_default_value_uint64(
const PbwFieldDescriptor* field);
199pbw_FieldDescriptor_default_value_float(
const PbwFieldDescriptor* field);
203pbw_FieldDescriptor_default_value_double(
const PbwFieldDescriptor* field);
207pbw_FieldDescriptor_default_value_bool(
const PbwFieldDescriptor* field);
211pbw_FieldDescriptor_default_value_string(
const PbwFieldDescriptor* field,
int* size);
214const PbwEnumValueDescriptor*
215pbw_FieldDescriptor_default_value_enum(
const PbwFieldDescriptor* field);
219pbw_EnumDescriptor_name(
const PbwEnumDescriptor* anEnum);
223pbw_EnumDescriptor_full_name(
const PbwEnumDescriptor* anEnum);
227pbw_EnumDescriptor_value_count(
const PbwEnumDescriptor* anEnum);
230const PbwEnumValueDescriptor*
231pbw_EnumDescriptor_value(
const PbwEnumDescriptor* anEnum,
int value_index);
234const PbwEnumValueDescriptor*
235pbw_EnumDescriptor_FindValueByNumber(
const PbwEnumDescriptor* anEnum,
int number);
238const PbwEnumValueDescriptor*
239pbw_EnumDescriptor_FindValueByName(
const PbwEnumDescriptor* anEnum,
const char* name);
243pbw_EnumValueDescriptor_name(
const PbwEnumValueDescriptor* enumValue);
247pbw_EnumValueDescriptor_full_name(
const PbwEnumValueDescriptor* enumValue);
251pbw_EnumValueDescriptor_number(
const PbwEnumValueDescriptor* enumValue);
255pbw_foreach_message(
const PbwDescriptorPool* pool,
void (*cb)(
const PbwDescriptor* message,
void* userdata),
void* userdata);
void pbw_reinit_DescriptorPool(PbwDescriptorPool **pool, const char **directories, pbw_report_error_cb_t error_cb)
Definition protobuf-helper.c:33