Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.3 KiB
63 lines
2.3 KiB
14 years ago
|
/*
|
||
|
* upb - a minimalist implementation of protocol buffers.
|
||
|
*
|
||
14 years ago
|
* Copyright (c) 2011 Google Inc. See LICENSE for details.
|
||
|
* Author: Josh Haberman <jhaberman@gmail.com>
|
||
|
*
|
||
14 years ago
|
* upb's core components like upb_decoder and upb_msg are carefully designed to
|
||
|
* avoid depending on each other for maximum orthogonality. In other words,
|
||
|
* you can use a upb_decoder to decode into *any* kind of structure; upb_msg is
|
||
14 years ago
|
* just one such structure. A upb_msg can be serialized/deserialized into any
|
||
|
* format, protobuf binary format is just one such format.
|
||
14 years ago
|
*
|
||
|
* However, for convenience we provide functions here for doing common
|
||
|
* operations like deserializing protobuf binary format into a upb_msg. The
|
||
|
* compromise is that this file drags in almost all of upb as a dependency,
|
||
|
* which could be undesirable if you're trying to use a trimmed-down build of
|
||
|
* upb.
|
||
|
*
|
||
14 years ago
|
* While these routines are convenient, they do not reuse any encoding/decoding
|
||
|
* state. For example, if a decoder is JIT-based, it will be re-JITted every
|
||
|
* time these functions are called. For this reason, if you are parsing lots
|
||
|
* of data and efficiency is an issue, these may not be the best functions to
|
||
|
* use (though they are useful for prototyping, before optimizing).
|
||
14 years ago
|
*/
|
||
|
|
||
|
#ifndef UPB_GLUE_H
|
||
|
#define UPB_GLUE_H
|
||
|
|
||
14 years ago
|
#include <stdbool.h>
|
||
14 years ago
|
#include "upb/upb.h"
|
||
14 years ago
|
|
||
14 years ago
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
// Forward-declares so we don't have to include everything in this .h file.
|
||
|
// Clients should use the regular, typedef'd names (eg. upb_string).
|
||
|
struct _upb_msg;
|
||
|
struct _upb_msgdef;
|
||
14 years ago
|
struct _upb_symtab;
|
||
14 years ago
|
|
||
|
// Decodes the given string, which must be in protobuf binary format, to the
|
||
|
// given upb_msg with msgdef "md", storing the status of the operation in "s".
|
||
14 years ago
|
void upb_strtomsg(const char *str, size_t len, void *msg,
|
||
|
struct _upb_msgdef *md, upb_status *s);
|
||
14 years ago
|
|
||
14 years ago
|
//void upb_msgtotext(struct _upb_string *str, void *msg,
|
||
|
// struct _upb_msgdef *md, bool single_line);
|
||
14 years ago
|
|
||
14 years ago
|
void upb_read_descriptor(struct _upb_symtab *symtab, const char *str, size_t len,
|
||
|
upb_status *status);
|
||
|
|
||
|
void upb_read_descriptorfile(struct _upb_symtab *symtab, const char *fname,
|
||
|
upb_status *status);
|
||
|
|
||
|
char *upb_readfile(const char *filename, size_t *len);
|
||
14 years ago
|
|
||
14 years ago
|
#ifdef __cplusplus
|
||
|
} /* extern "C" */
|
||
|
#endif
|
||
|
|
||
|
#endif
|