• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MESSAGE_COPY_H_
9 #define UPB_MESSAGE_COPY_H_
10 
11 #include "upb/mem/arena.h"
12 #include "upb/message/array.h"
13 #include "upb/message/map.h"
14 #include "upb/message/message.h"
15 #include "upb/mini_table/message.h"
16 
17 // Must be last.
18 #include "upb/port/def.inc"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 // Deep clones a message using the provided target arena.
25 upb_Message* upb_Message_DeepClone(const upb_Message* msg,
26                                    const upb_MiniTable* m, upb_Arena* arena);
27 
28 // Shallow clones a message using the provided target arena.
29 upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
30                                       const upb_MiniTable* m, upb_Arena* arena);
31 
32 // Deep clones array contents.
33 upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type,
34                                const upb_MiniTable* sub, upb_Arena* arena);
35 
36 // Deep clones map contents.
37 upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
38                            upb_CType value_type,
39                            const upb_MiniTable* map_entry_table,
40                            upb_Arena* arena);
41 
42 // Deep copies the message from src to dst.
43 bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
44                           const upb_MiniTable* m, upb_Arena* arena);
45 
46 // Shallow copies the message from src to dst.
47 void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
48                              const upb_MiniTable* m);
49 
50 #ifdef __cplusplus
51 } /* extern "C" */
52 #endif
53 
54 #include "upb/port/undef.inc"
55 
56 #endif  // UPB_MESSAGE_COPY_H_
57