File indexing completed on 2024-04-06 12:13:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "FWCore/Utilities/interface/Guid.h"
0013 #include <cstring>
0014 #include <cassert>
0015
0016 namespace edm {
0017
0018 void Guid::init(bool usetime) {
0019 if (usetime) {
0020 ::uuid_generate_time(data_);
0021 } else {
0022
0023
0024
0025
0026 ::uuid_generate(data_);
0027 }
0028 }
0029
0030 std::string const Guid::toBinary() const { return std::string(reinterpret_cast<const char*>(data_), sizeof(data_)); }
0031
0032 Guid const& Guid::fromBinary(std::string const& source) {
0033 assert(source.size() == sizeof(data_));
0034 std::memcpy(data_, source.data(), sizeof(data_));
0035 return *this;
0036 }
0037
0038 std::string const Guid::toString() const {
0039 char out[UUID_STR_LEN];
0040 ::uuid_unparse(data_, out);
0041 return std::string(out);
0042 }
0043
0044
0045 Guid const& Guid::fromString(std::string const& source) {
0046 auto err = ::uuid_parse(source.c_str(), data_);
0047 assert(err == 0);
0048 return *this;
0049 }
0050
0051 bool Guid::isValidString(std::string const& source) {
0052 uuid_t tmp;
0053 auto err = ::uuid_parse(source.c_str(), tmp);
0054 return err == 0;
0055 }
0056
0057 bool Guid::operator<(Guid const& g) const { return ::uuid_compare(data_, g.data_) < 0; }
0058 }