summaryrefslogtreecommitdiff
path: root/upb/msgfactory.h
blob: 9b3b59993891bb555528fb7a80656dbdf3d9ecd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#include "upb/def.h"
#include "upb/msg.h"

#ifndef UPB_MSGFACTORY_H_
#define UPB_MSGFACTORY_H_

/** upb_msgfactory ************************************************************/

struct upb_msgfactory;
typedef struct upb_msgfactory upb_msgfactory;

#ifdef __cplusplus
extern "C" {
#endif

/* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
 * upb_visitorplan objects.  These are the objects necessary to represent,
 * populate, and and visit upb_msg objects.
 *
 * These caches are all populated by upb_msgdef, and lazily created on demand.
 */

/* Creates and destroys a msgfactory, respectively.  The messages for this
 * msgfactory must come from |symtab| (which should outlive the msgfactory). */
upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
void upb_msgfactory_free(upb_msgfactory *f);

const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);

/* The functions to get cached objects, lazily creating them on demand.  These
 * all require:
 *
 * - m is in upb_msgfactory_symtab(f)
 * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
 *
 * The returned objects will live for as long as the msgfactory does.
 *
 * TODO(haberman): consider making this thread-safe and take a const
 * upb_msgfactory. */
const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
                                              const upb_msgdef *m);

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif /* UPB_MSGFACTORY_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback