2016-06-07 09:39:46 -05:00
|
|
|
/********************************************************************
|
|
|
|
* guid.hpp - GncGUID struct definition. *
|
|
|
|
* Copyright 2016 Aaron Laws *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
* *
|
|
|
|
*******************************************************************/
|
|
|
|
#ifndef GUID_HPP_HEADER
|
|
|
|
#define GUID_HPP_HEADER
|
|
|
|
|
|
|
|
#include <boost/uuid/uuid.hpp>
|
|
|
|
#include <stdexcept>
|
2023-01-23 07:57:38 -06:00
|
|
|
|
2016-10-20 15:47:32 -05:00
|
|
|
#include "guid.h"
|
2016-06-07 09:39:46 -05:00
|
|
|
|
2016-10-20 15:47:32 -05:00
|
|
|
namespace gnc {
|
2016-06-07 09:39:46 -05:00
|
|
|
struct guid_syntax_exception : public std::invalid_argument
|
|
|
|
{
|
|
|
|
guid_syntax_exception () noexcept;
|
|
|
|
};
|
|
|
|
|
2016-10-24 13:20:55 -05:00
|
|
|
struct GUID
|
2016-06-07 09:39:46 -05:00
|
|
|
{
|
2016-10-24 13:20:55 -05:00
|
|
|
private:
|
|
|
|
boost::uuids::uuid implementation;
|
|
|
|
|
|
|
|
public:
|
2016-10-20 15:47:32 -05:00
|
|
|
GUID (boost::uuids::uuid const &) noexcept;
|
|
|
|
GUID (GncGUID const &) noexcept;
|
2016-10-24 13:20:55 -05:00
|
|
|
GUID (GUID const &) noexcept = default;
|
2016-10-20 15:47:32 -05:00
|
|
|
GUID () noexcept = default;
|
2016-10-24 13:20:55 -05:00
|
|
|
GUID & operator = (GUID &&) noexcept;
|
|
|
|
|
|
|
|
operator GncGUID () const noexcept;
|
2016-10-20 15:47:32 -05:00
|
|
|
static GUID create_random () noexcept;
|
|
|
|
static GUID const & null_guid () noexcept;
|
2017-07-20 17:36:43 -05:00
|
|
|
static GUID from_string (std::string const &);
|
2017-10-19 14:42:32 -05:00
|
|
|
static bool is_valid_guid (std::string const &);
|
2016-06-07 09:39:46 -05:00
|
|
|
std::string to_string () const noexcept;
|
2016-10-24 13:20:55 -05:00
|
|
|
auto begin () const noexcept -> decltype (implementation.begin ());
|
|
|
|
auto end () const noexcept -> decltype (implementation.end ());
|
|
|
|
bool operator < (GUID const &) noexcept;
|
2018-03-06 11:48:22 -06:00
|
|
|
friend bool operator == (GUID const &, GncGUID const &) noexcept;
|
2016-10-24 13:20:55 -05:00
|
|
|
friend bool operator != (GUID const &, GUID const &) noexcept;
|
2016-06-07 09:39:46 -05:00
|
|
|
};
|
|
|
|
|
2016-10-24 13:20:55 -05:00
|
|
|
bool operator != (GUID const &, GUID const &) noexcept;
|
|
|
|
bool operator == (GUID const &, GncGUID const &) noexcept;
|
2016-10-20 15:47:32 -05:00
|
|
|
|
|
|
|
|
2023-03-18 15:53:49 -05:00
|
|
|
} // namespace gnc
|
|
|
|
|
|
|
|
bool operator== (const GncGUID&, const GncGUID&);
|
2016-06-07 09:39:46 -05:00
|
|
|
#endif
|