Qpid Proton C++  0.17.0
annotation_key.hpp
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 
30 namespace proton {
31 
35 class annotation_key : public scalar_base {
36  public:
39 
41  template <class T> annotation_key(const T& x) { *this = x; }
42 
45  annotation_key& operator=(uint64_t x) { put_(x); return *this; }
46  annotation_key& operator=(const symbol& x) { put_(x); return *this; }
48 
51  annotation_key& operator=(const std::string& x) { put_(symbol(x)); return *this; }
52  annotation_key& operator=(const char *x) { put_(symbol(x)); return *this; }
54 
56  friend class message;
57  friend class codec::decoder;
59 };
60 
63 template <class T> T get(const annotation_key& x);
65 
69 template<> inline uint64_t get<uint64_t>(const annotation_key& x) { return internal::get<uint64_t>(x); }
70 
74 template<> inline symbol get<symbol>(const annotation_key& x) { return internal::get<symbol>(x); }
75 
80 template<class T> T coerce(const annotation_key& x) { return internal::coerce<T>(x); }
81 
82 } // proton
83 
84 #endif // PROTON_ANNOTATION_KEY_HPP
An AMQP message.
Definition: message.hpp:47
A key for use with AMQP annotation maps.
Definition: annotation_key.hpp:35
annotation_key(const T &x)
Construct from any type that can be assigned.
Definition: annotation_key.hpp:41
Base class for scalar types.
Definition: scalar_base.hpp:57
A std::string that represents the AMQP symbol type.
Definition: symbol.hpp:32
T coerce(const annotation_key &x)
Get the binary value or throw conversion_error.
Definition: annotation_key.hpp:80
annotation_key()
An empty annotation key.
Definition: annotation_key.hpp:38
The main Proton namespace.
Definition: annotation_key.hpp:30
Experimental - Stream-like decoder from AMQP bytes to C++ values.
Definition: decoder.hpp:53