Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
message_id.hpp
1 #ifndef MESSAGE_ID_HPP
2 #define MESSAGE_ID_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 
39 class message_id : public restricted_scalar {
40  public:
42  message_id() { scalar_ = uint64_t(0); }
43 
49  message_id& operator=(uint64_t x) { scalar_ = x; return *this; }
50  message_id& operator=(const amqp_uuid& x) { scalar_ = x; return *this; }
51  message_id& operator=(const amqp_binary& x) { scalar_ = x; return *this; }
52  message_id& operator=(const amqp_string& x) { scalar_ = x; return *this; }
54  message_id& operator=(const std::string& x) { scalar_ = amqp_string(x); return *this; }
56  message_id& operator=(const char *x) { scalar_ = amqp_string(x); return *this; }
58 
60  template <class T> message_id(T x) { *this = x; }
61 
68  void get(uint64_t& x) const { scalar_.get(x); }
69  void get(amqp_uuid& x) const { scalar_.get(x); }
70  void get(amqp_binary& x) const { scalar_.get(x); }
71  void get(amqp_string& x) const { scalar_.get(x); }
73 
75  template<class T> T get() const { T x; get(x); return x; }
76 
78  friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&);
79  friend PN_CPP_EXTERN decoder operator>>(decoder, message_id&);
80  friend class message;
82 };
83 
84 }
85 #endif // MESSAGE_ID_HPP
An AMQP message.
Definition: message.hpp:48
Defines C++ types representing AMQP types.
message_id & operator=(const char *x)
char* is encoded as amqp_string
Definition: message_id.hpp:56
message_id(T x)
Create a message ID from any type that we can assign from.
Definition: message_id.hpp:60
message_id & operator=(const std::string &x)
std::string is encoded as amqp_string
Definition: message_id.hpp:54
An AMQP message ID.
Definition: message_id.hpp:39
message_id()
Create an empty (0) message ID.
Definition: message_id.hpp:42