2 * @brief Class for handling UUIDs
4 /* Copyright 2008 Lemur Consulting Ltd
5 * Copyright 2009,2010,2013,2016,2018 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef XAPIAN_INCLUDED_UUIDS_H
23 #define XAPIAN_INCLUDED_UUIDS_H
30 /// The size of a UUID in bytes.
31 static constexpr unsigned BINARY_SIZE
= 16;
33 /// The size of a UUID string in bytes (not including trailing '\0').
34 static constexpr unsigned STRING_SIZE
= 36;
40 void parse(const char* in
);
42 void parse(const std::string
& in
) { return parse(in
.data()); }
44 // Not currently used.
46 std::memset(uuid_data
, 0, BINARY_SIZE
);
49 // Not currently used.
50 bool is_null() const {
51 for (char ch
: uuid_data
) {
58 std::string
to_string() const;
60 const char* data() const {
61 return reinterpret_cast<const char*>(uuid_data
);
64 void assign(const char* p
) { std::memcpy(uuid_data
, p
, BINARY_SIZE
); }
68 unsigned char uuid_data
[BINARY_SIZE
];
71 #endif /* XAPIAN_INCLUDED_UUIDS_H */