pulsar-client-cpp
Schema.h
1 
19 #pragma once
20 
21 #include <pulsar/defines.h>
22 
23 #include <iosfwd>
24 #include <map>
25 #include <memory>
26 #include <string>
27 
28 namespace pulsar {
29 
34 {
38  SEPARATED,
39 
43  INLINE
44 };
45 
46 // Return string representation of result code
47 PULSAR_PUBLIC const char *strEncodingType(pulsar::KeyValueEncodingType encodingType);
48 
49 PULSAR_PUBLIC KeyValueEncodingType enumEncodingType(std::string encodingTypeStr);
50 
52 {
56  NONE = 0,
57 
61  STRING = 1,
62 
66  JSON = 2,
67 
71  PROTOBUF = 3,
72 
76  AVRO = 4,
77 
81  INT8 = 6,
82 
86  INT16 = 7,
87 
91  INT32 = 8,
92 
96  INT64 = 9,
97 
101  FLOAT = 10,
102 
106  DOUBLE = 11,
107 
111  KEY_VALUE = 15,
112 
117 
121  BYTES = -1,
122 
127 
132 };
133 
134 // Return string representation of result code
135 PULSAR_PUBLIC const char *strSchemaType(SchemaType schemaType);
136 
137 PULSAR_PUBLIC SchemaType enumSchemaType(std::string schemaTypeStr);
138 
139 class SchemaInfoImpl;
140 
141 typedef std::map<std::string, std::string> StringMap;
142 
146 class PULSAR_PUBLIC SchemaInfo {
147  public:
158  SchemaInfo();
159 
166  SchemaInfo(SchemaType schemaType, const std::string &name, const std::string &schema,
167  const StringMap &properties = StringMap());
168 
174  SchemaInfo(const SchemaInfo &keySchema, const SchemaInfo &valueSchema,
175  const KeyValueEncodingType &keyValueEncodingType = KeyValueEncodingType::INLINE);
176 
180  SchemaType getSchemaType() const;
181 
185  const std::string &getName() const;
186 
190  const std::string &getSchema() const;
191 
195  const StringMap &getProperties() const;
196 
197  private:
198  typedef std::shared_ptr<SchemaInfoImpl> SchemaInfoImplPtr;
199  SchemaInfoImplPtr impl_;
200 };
201 
202 } // namespace pulsar
203 
204 PULSAR_PUBLIC std::ostream &operator<<(std::ostream &s, pulsar::SchemaType schemaType);
205 
206 PULSAR_PUBLIC std::ostream &operator<<(std::ostream &s, pulsar::KeyValueEncodingType encodingType);
pulsar::KEY_VALUE
@ KEY_VALUE
Definition: Schema.h:111
pulsar::DOUBLE
@ DOUBLE
Definition: Schema.h:106
pulsar::INT32
@ INT32
Definition: Schema.h:91
pulsar::KeyValueEncodingType::INLINE
@ INLINE
pulsar::AVRO
@ AVRO
Definition: Schema.h:76
pulsar::INT64
@ INT64
Definition: Schema.h:96
pulsar::FLOAT
@ FLOAT
Definition: Schema.h:101
pulsar::SchemaType
SchemaType
Definition: Schema.h:51
pulsar::INT8
@ INT8
Definition: Schema.h:81
pulsar::INT16
@ INT16
Definition: Schema.h:86
pulsar::AUTO_PUBLISH
@ AUTO_PUBLISH
Definition: Schema.h:131
pulsar::KeyValueEncodingType
KeyValueEncodingType
Definition: Schema.h:33
pulsar::JSON
@ JSON
Definition: Schema.h:66
pulsar::STRING
@ STRING
Definition: Schema.h:61
pulsar::SchemaInfo
Definition: Schema.h:146
pulsar::BYTES
@ BYTES
Definition: Schema.h:121
pulsar::NONE
@ NONE
Definition: Schema.h:56
pulsar
Definition: Authentication.h:31
pulsar::PROTOBUF
@ PROTOBUF
Definition: Schema.h:71
pulsar::KeyValueEncodingType::SEPARATED
@ SEPARATED
pulsar::AUTO_CONSUME
@ AUTO_CONSUME
Definition: Schema.h:126
pulsar::PROTOBUF_NATIVE
@ PROTOBUF_NATIVE
Definition: Schema.h:116