Qpid Proton C++  0.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
message_id.hpp
1 #ifndef PROTON_MESSAGE_ID_HPP
2 #define PROTON_MESSAGE_ID_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 "./binary.hpp"
26 #include "./internal/scalar_base.hpp"
27 #include "./uuid.hpp"
28 
29 #include <string>
30 
31 namespace proton {
32 
42 class message_id : public internal::scalar_base {
43  public:
45  message_id() { put_(uint64_t(0)); }
46 
48  template <class T> message_id(const T& x) { *this = x; }
49 
54  message_id& operator=(uint64_t x) { put_(x); return *this; }
55  message_id& operator=(const uuid& x) { put_(x); return *this; }
56  message_id& operator=(const binary& x) { put_(x); return *this; }
57  message_id& operator=(const std::string& x) { put_(x); return *this; }
58  message_id& operator=(const char* x) { put_(x); return *this; }
59 
61  private:
62  message_id(const pn_atom_t& a): internal::scalar_base(a) {}
63 
65  friend class message;
66  friend class codec::decoder;
68 };
69 
72 template <class T> T get(const message_id& x);
74 
76 template<> inline uint64_t get<uint64_t>(const message_id& x) { return internal::get<uint64_t>(x); }
78 template<> inline uuid get<uuid>(const message_id& x) { return internal::get<uuid>(x); }
80 template<> inline binary get<binary>(const message_id& x) { return internal::get<binary>(x); }
82 template<> inline std::string get<std::string>(const message_id& x) { return internal::get<std::string>(x); }
83 
86 template<class T> T coerce(const message_id& x) { return internal::coerce<T>(x); }
87 
88 } // proton
89 
90 #endif // PROTON_MESSAGE_ID_HPP
T coerce(const message_id &x)
Coerce the contained value to type T.
Definition: message_id.hpp:86
A 16-byte universally unique identifier.
Definition: uuid.hpp:34
message_id(const T &x)
Construct from any type that can be assigned.
Definition: message_id.hpp:48
Arbitrary binary data.
Definition: binary.hpp:34
message_id & operator=(const char *x)
Treated as amqp::STRING.
Definition: message_id.hpp:58
An AMQP message ID.
Definition: message_id.hpp:42
message_id()
An empty message_id has a uint64_t value set to 0.
Definition: message_id.hpp:45