File indexing completed on 2024-04-06 12:13:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <iostream>
0015 #include <vector>
0016
0017
0018 #include "FWCore/Utilities/interface/ESInputTag.h"
0019 #include "FWCore/Utilities/interface/Parse.h"
0020 #include "FWCore/Utilities/interface/EDMException.h"
0021
0022 using namespace edm;
0023
0024 ESInputTag::ESInputTag() = default;
0025
0026 ESInputTag::ESInputTag(std::string moduleLabel, std::string dataLabel)
0027 : module_(std::move(moduleLabel)), data_(std::move(dataLabel)) {}
0028
0029 ESInputTag::ESInputTag(const std::string& iEncodedValue) {
0030
0031 std::vector<std::string> tokens = tokenize(iEncodedValue, ":");
0032 int nwords = tokens.size();
0033 if (nwords > 2) {
0034 throw edm::Exception(errors::Configuration, "ESInputTag")
0035 << "ESInputTag " << iEncodedValue << " has " << nwords << " tokens but only up two 2 are allowed.";
0036 }
0037 if (nwords > 0) {
0038 if (nwords != 2) {
0039 throw edm::Exception(errors::Configuration, "ESInputTag")
0040 << "ESInputTag " << iEncodedValue << " must contain a ':' to separate the module and data labels.";
0041 }
0042 module_ = tokens[0];
0043 data_ = tokens[1];
0044 }
0045 }
0046
0047
0048
0049
0050 bool ESInputTag::operator==(const edm::ESInputTag& iRHS) const {
0051 return module_ == iRHS.module_ && data_ == iRHS.data_;
0052 }
0053
0054 std::string ESInputTag::encode() const {
0055 std::string result = module_;
0056 result += ":";
0057 if (!data_.empty()) {
0058 result += data_;
0059 }
0060 return result;
0061 }
0062
0063 namespace edm {
0064 std::ostream& operator<<(std::ostream& os, ESInputTag const& tag) {
0065 os << "Module label: " << tag.module() << " Data label: " << tag.data();
0066 return os;
0067 }
0068 }