Qpid Proton C++ API  0.18.1
annotation_key.hpp
Go to the documentation of this file.
1 #ifndef PROTON_ANNOTATION_KEY_HPP
2 #define PROTON_ANNOTATION_KEY_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./scalar_base.hpp"
26 #include "./symbol.hpp"
27 
28 #include <proton/type_compat.h>
29 
32 
33 namespace proton {
34 
38 class annotation_key : public scalar_base {
39  public:
42 
44  template <class T> annotation_key(const T& x) { *this = x; }
45 
48  annotation_key& operator=(uint64_t x) { put_(x); return *this; }
49  annotation_key& operator=(const symbol& x) { put_(x); return *this; }
51 
54  annotation_key& operator=(const std::string& x) { put_(symbol(x)); return *this; }
55  annotation_key& operator=(const char *x) { put_(symbol(x)); return *this; }
57 
59  friend class message;
60  friend class codec::decoder;
62 };
63 
66 template <class T> T get(const annotation_key& x);
68 
72 template<> inline uint64_t get<uint64_t>(const annotation_key& x) { return internal::get<uint64_t>(x); }
73 
77 template<> inline symbol get<symbol>(const annotation_key& x) { return internal::get<symbol>(x); }
78 
83 template<class T> T coerce(const annotation_key& x) { return internal::coerce<T>(x); }
84 
85 } // proton
86 
87 #endif // PROTON_ANNOTATION_KEY_HPP
An AMQP message.
Definition: message.hpp:50
A key for use with AMQP annotation maps.
Definition: annotation_key.hpp:38
annotation_key(const T &x)
Construct from any type that can be assigned.
Definition: annotation_key.hpp:44
The base class for scalar types.
Definition: scalar_base.hpp:60
symbol get< symbol >(const annotation_key &x)
Get the symbol value or throw conversion_error.
Definition: annotation_key.hpp:77
A string that represents the AMQP symbol type.
Definition: symbol.hpp:35
The base class for scalar types.
A string that represents the AMQP symbol type.
T coerce(const annotation_key &x)
Get the binary value or throw conversion_error.
Definition: annotation_key.hpp:83
annotation_key()
An empty annotation key.
Definition: annotation_key.hpp:41
The main Proton namespace.
Definition: annotation_key.hpp:33
Unsettled API - A stream-like decoder from AMQP bytes to C++ values.
Definition: decoder.hpp:56
uint64_t get< uint64_t >(const annotation_key &x)
Get the uint64_t value or throw conversion_error.
Definition: annotation_key.hpp:72