File indexing completed on 2025-05-23 02:04:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <memory>
0015 #include <cstring>
0016
0017
0018 #include "FWCore/Framework/interface/DataKey.h"
0019
0020
0021
0022
0023
0024 namespace {
0025 constexpr char kBlank[] = {'\0'};
0026 }
0027
0028 namespace edm::eventsetup {
0029
0030 DataKey::DataKey() = default;
0031
0032 DataKey& DataKey::operator=(const DataKey& rhs) {
0033
0034 DataKey temp(rhs);
0035 swap(temp);
0036
0037 return *this;
0038 }
0039
0040 DataKey& DataKey::operator=(DataKey&& rhs) {
0041
0042 DataKey temp(std::move(rhs));
0043 swap(temp);
0044
0045 return *this;
0046 }
0047
0048
0049
0050
0051 void DataKey::swap(DataKey& iOther) {
0052 std::swap(ownMemory_, iOther.ownMemory_);
0053
0054
0055 using std::swap;
0056 swap(type_, iOther.type_);
0057 swap(name_, iOther.name_);
0058 }
0059
0060 void DataKey::makeCopyOfMemory() {
0061
0062
0063 char const* pName = kBlank;
0064 std::unique_ptr<char[]> pNameHolder;
0065 if (kBlank[0] != name().value()[0]) {
0066 size_t const nBytes = std::strlen(name().value()) + 1;
0067 pNameHolder.reset(new char[nBytes]);
0068 pName = pNameHolder.get();
0069 std::strncpy(pNameHolder.get(), name().value(), nBytes);
0070 }
0071 name_ = NameTag(pName);
0072 ownMemory_ = true;
0073 pNameHolder.release();
0074 }
0075
0076 void DataKey::deleteMemory() {
0077 if (kBlank[0] != name().value()[0]) {
0078 delete[] (name().value());
0079 }
0080 }
0081
0082
0083
0084
0085 bool DataKey::operator==(const DataKey& iRHS) const { return ((type_ == iRHS.type_) && (name_ == iRHS.name_)); }
0086
0087 bool DataKey::operator<(const DataKey& iRHS) const {
0088 return (type_ < iRHS.type_) || ((type_ == iRHS.type_) && (name_ < iRHS.name_));
0089 }
0090 }