Ariles
protobuf3.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2020 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 /**
12 @defgroup protobuf3 Protocol Buffers [incomplete]
13 
14 @brief Exchange data with protobuf classes.
15 
16 Only trivial protobuf messages are supported: no repeated fields, no nested
17 messages, etc. The main limitation is that protobuf C++ API depends on both the
18 name and the type of message fields, which makes it impossible to handle either
19 via templates or preprocessor macro.
20 */
21 
22 
23 #pragma once
24 
25 #define ARILES2_VISITOR_INCLUDED_protobuf3
26 
29 #include <ariles2/adapters/basic.h>
30 
31 
32 namespace ariles2
33 {
34  namespace ns_protobuf3
35  {
37  {
38  };
39 
40 
41 #define ARILES2_NAMED_ENTRY_protobuf3_write(v, entry, name) other.set_##name(entry);
42 #define ARILES2_NAMED_ENTRY_protobuf3_read(v, entry, name) \
43  visitor.visitMapEntry(entry, other.name(), #name, parameters);
44 #define ARILES2_PARENT_protobuf3_write(v, entry) entry::arilesVisit(visitor, other, parameters);
45 #define ARILES2_PARENT_protobuf3_read(v, entry) entry::arilesVisit(visitor, other, parameters);
46 
47 
48 #define ARILES2_VISIT_protobuf3 \
49  template <class t_Other> \
50  void arilesVisit( \
51  ariles2::protobuf3::Writer &visitor, \
52  t_Other &other, \
53  const typename ariles2::protobuf3::Writer::Parameters &parameters) const \
54  { \
55  ARILES2_UNUSED_ARG(visitor); \
56  ARILES2_UNUSED_ARG(other); \
57  ARILES2_UNUSED_ARG(parameters); \
58  ARILES2_TRACE_FUNCTION; \
59  ARILES2_ENTRIES(protobuf3_write) \
60  } \
61  template <class t_Other> \
62  void arilesVisit( \
63  ariles2::protobuf3::Reader &visitor, \
64  const t_Other &other, \
65  const typename ariles2::protobuf3::Reader::Parameters &parameters) \
66  { \
67  ARILES2_UNUSED_ARG(visitor); \
68  ARILES2_UNUSED_ARG(other); \
69  ARILES2_UNUSED_ARG(parameters); \
70  ARILES2_TRACE_FUNCTION; \
71  ARILES2_ENTRIES(protobuf3_read) \
72  }
73 
74 
75 #define ARILES2_METHODS_protobuf3 \
76  const ariles2::protobuf3::Writer::Parameters &arilesGetParameters(const ariles2::protobuf3::Writer &visitor) const \
77  { \
78  ARILES2_TRACE_FUNCTION; \
79  return (visitor.getDefaultParameters()); \
80  } \
81  const ariles2::protobuf3::Reader::Parameters &arilesGetParameters(const ariles2::protobuf3::Reader &visitor) const \
82  { \
83  ARILES2_TRACE_FUNCTION; \
84  return (visitor.getDefaultParameters()); \
85  }
86 
87 #define ARILES2_BASE_METHODS_protobuf3
88  } // namespace ns_protobuf3
89 } // namespace ariles2
90 
91 
92 #include "./protobuf3/reader.h"
93 #include "./protobuf3/writer.h"
94 
95 
96 namespace ariles2
97 {
98  /**
99  * @brief protobuf3 visitor.
100  * @ingroup protobuf3
101  */
103  {
107  };
108 } // namespace ariles2
ariles2
Definition: basic.h:16
reader.h
ariles2::protobuf3
protobuf3 visitor.
Definition: protobuf3.h:102
ariles2::protobuf3::Writer
ns_protobuf3::Writer Writer
Definition: protobuf3.h:106
ariles2::ns_protobuf3::Writer
Definition: writer.h:17
ariles2::ns_protobuf3::Reader
Definition: reader.h:17
ariles2::ns_protobuf3::Base
Definition: protobuf3.h:36
helpers.h
ARILES2_VISIBILITY_ATTRIBUTE
#define ARILES2_VISIBILITY_ATTRIBUTE
Definition: helpers.h:138
ariles2::protobuf3::Base
ns_protobuf3::Base Base
Definition: protobuf3.h:104
writer.h
basic.h
ariles2::protobuf3::Reader
ns_protobuf3::Reader Reader
Definition: protobuf3.h:105
config.h