#ifndef QPID_MESSAGING_UUID_H #define QPID_MESSAGING_UUID_H /* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ #include "qpid/messaging/ImportExport.h" #include #include namespace qpid { namespace messaging { class Uuid { public: static const size_t SIZE; /** * If unique is true, this will generate a new unique uuid, if not * it will construct a null uuid. */ QPID_CLIENT_EXTERN Uuid(bool unique=false); QPID_CLIENT_EXTERN Uuid(const Uuid&); QPID_CLIENT_EXTERN Uuid& operator=(const Uuid&); /** Copy the UUID from data16, which must point to a 16-byte UUID */ QPID_CLIENT_EXTERN Uuid(const unsigned char* data16); /** Set to a new unique identifier. */ QPID_CLIENT_EXTERN void generate(); /** Set to all zeros. */ QPID_CLIENT_EXTERN void clear(); /** Test for null (all zeros). */ QPID_CLIENT_EXTERN bool isNull() const; QPID_CLIENT_EXTERN operator bool() const; QPID_CLIENT_EXTERN bool operator!() const; /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ QPID_CLIENT_EXTERN std::string str() const; QPID_CLIENT_EXTERN size_t size() const; QPID_CLIENT_EXTERN const unsigned char* data() const; friend QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); friend QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); friend QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); private: unsigned char bytes[16]; }; /** Returns true if the uuids are equal, false otherwise. **/ QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); /** Returns true if the uuids are NOT equal, false if they are. **/ QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); /** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); /** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); }} // namespace qpid::messaging #endif /*!QPID_MESSAGING_UUID_H*/