Qpid Proton C++  0.12.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
annotation_key.hpp
1 #ifndef ANNOTATION_KEY_HPP
2 #define ANNOTATION_KEY_HPP
3 
4 /*
5  * Licensed to the Apache Software Foundation (ASF) under one
6  * or more contributor license agreements. See the NOTICE file
7  * distributed with this work for additional information
8  * regarding copyright ownership. The ASF licenses this file
9  * to you under the Apache License, Version 2.0 (the
10  * "License"); you may not use this file except in compliance
11  * with the License. You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing,
16  * software distributed under the License is distributed on an
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  * KIND, either express or implied. See the License for the
19  * specific language governing permissions and limitations
20  * under the License.
21  */
22 
23 #include "proton/types.hpp"
24 #include "proton/scalar.hpp"
25 
26 namespace proton {
27 
28 class encoder;
29 class decoder;
30 
35 class annotation_key : public restricted_scalar {
36  public:
38  annotation_key() { scalar_ = uint64_t(0); }
39 
45  annotation_key& operator=(uint64_t x) { scalar_ = x; return *this; }
46  annotation_key& operator=(const amqp_symbol& x) { scalar_ = x; return *this; }
48  annotation_key& operator=(const std::string& x) { scalar_ = amqp_symbol(x); return *this; }
50  annotation_key& operator=(const char *x) { scalar_ = amqp_symbol(x); return *this; }
52 
55  template <class T> annotation_key(T x) { *this = x; }
56 
60  void get(uint64_t& x) const { scalar_.get(x); }
61  void get(amqp_symbol& x) const { scalar_.get(x); }
63 
65  template<class T> T get() const { T x; get(x); return x; }
66 
68  friend PN_CPP_EXTERN encoder operator<<(encoder, const annotation_key&);
69  friend PN_CPP_EXTERN decoder operator>>(decoder, annotation_key&);
70  friend class message;
72 };
73 
74 }
75 
76 #endif // ANNOTATION_KEY_HPP
An AMQP message.
Definition: message.hpp:48
A key for use with AMQP annotation maps.
Definition: annotation_key.hpp:35
annotation_key(T x)
A constructor that converts from any type that we can assign from.
Definition: annotation_key.hpp:55
annotation_key & operator=(const char *x)
char* is encoded as proton::amqp::amqp_symbol.
Definition: annotation_key.hpp:50
annotation_key & operator=(const std::string &x)
std::string is encoded as proton::amqp::amqp_symbol.
Definition: annotation_key.hpp:48
Defines C++ types representing AMQP types.
annotation_key()
Create an empty key.
Definition: annotation_key.hpp:38