WPILibC++ 2027.0.0-alpha-3
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8#ifndef UPB_REFLECTION_MESSAGE_H_
9#define UPB_REFLECTION_MESSAGE_H_
10
11#include <stddef.h>
12
13#include "upb/mem/arena.h"
14#include "upb/message/map.h"
15#include "upb/message/message.h"
17
18// Must be last.
19#include "upb/port/def.inc"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25// Returns a mutable pointer to a map, array, or submessage value. If the given
26// arena is non-NULL this will construct a new object if it was not previously
27// present. May not be called for primitive fields.
29 const upb_FieldDef* f,
30 upb_Arena* a);
31
32// Returns the field that is set in the oneof, or NULL if none are set.
34 const upb_OneofDef* o);
35
36// Clear all data and unknown fields.
38
39// Clears any field presence and sets the value back to its default.
41 const upb_FieldDef* f);
42
43// May only be called for fields where upb_FieldDef_HasPresence(f) == true.
45 const upb_FieldDef* f);
46
47// Returns the value in the message associated with this field def.
49 const upb_FieldDef* f);
50
51// Sets the given field to the given value. For a msg/array/map/string, the
52// caller must ensure that the target data outlives |msg| (by living either in
53// the same arena or a different arena that outlives it).
54//
55// Returns false if allocation fails.
58
59// Iterate over present fields.
60//
61// size_t iter = kUpb_Message_Begin;
62// const upb_FieldDef *f;
63// upb_MessageValue val;
64// while (upb_Message_Next(msg, m, ext_pool, &f, &val, &iter)) {
65// process_field(f, val);
66// }
67//
68// If ext_pool is NULL, no extensions will be returned. If the given symtab
69// returns extensions that don't match what is in this message, those extensions
70// will be skipped.
71
72#define kUpb_Message_Begin -1
73
75 const upb_DefPool* ext_pool,
76 const upb_FieldDef** f, upb_MessageValue* val,
77 size_t* iter);
78
79// Clears all unknown field data from this message and all submessages.
81 const upb_MessageDef* m,
82 const upb_DefPool* ext_pool,
83 int maxdepth);
84
85#ifdef __cplusplus
86} /* extern "C" */
87#endif
88
89#include "upb/port/undef.inc"
90
91#endif /* UPB_REFLECTION_MESSAGE_H_ */
#define UPB_API
Definition def.inc:162
struct upb_FieldDef upb_FieldDef
Definition common.h:29
struct upb_OneofDef upb_OneofDef
Definition common.h:34
struct upb_DefPool upb_DefPool
Definition common.h:24
struct upb_MessageDef upb_MessageDef
Definition common.h:31
UPB_API const upb_FieldDef * upb_Message_WhichOneofByDef(const upb_Message *msg, const upb_OneofDef *o)
UPB_API void upb_Message_ClearFieldByDef(upb_Message *msg, const upb_FieldDef *f)
UPB_API bool upb_Message_Next(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, const upb_FieldDef **f, upb_MessageValue *val, size_t *iter)
UPB_API upb_MutableMessageValue upb_Message_Mutable(upb_Message *msg, const upb_FieldDef *f, upb_Arena *a)
UPB_API bool upb_Message_HasFieldByDef(const upb_Message *msg, const upb_FieldDef *f)
void upb_Message_ClearByDef(upb_Message *msg, const upb_MessageDef *m)
UPB_API bool upb_Message_SetFieldByDef(upb_Message *msg, const upb_FieldDef *f, upb_MessageValue val, upb_Arena *a)
UPB_API upb_MessageValue upb_Message_GetFieldByDef(const upb_Message *msg, const upb_FieldDef *f)
UPB_API bool upb_Message_DiscardUnknown(upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, int maxdepth)
Definition arena.h:29
Definition types.h:18
Definition value.h:27
Definition value.h:61