CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Hash.cc
Go to the documentation of this file.
5 
6 namespace edm {
7  namespace detail {
8  // This string is the 16-byte, non-printable version.
9  std::string const& InvalidHash() {
10  static std::string const invalid = cms::MD5Result().compactForm();
11  return invalid;
12  }
13  }
14 
15  namespace hash_detail {
18  if (isCompactForm_(hash)) {
19  return hash;
20  }
21  value_type temp(hash);
22  fixup_(temp);
23  return temp;
24  }
25 
26  // 'Fix' the string data member of this Hash, i.e., if it is in
27  // the hexified (32 byte) representation, make it be in the
28  // 16-byte (unhexified) representation.
29  void
31  switch (hash.size()) {
32  case 16: {
33  break;
34  }
35  case 32: {
37  temp.fromHexifiedString(hash);
38  hash = temp.compactForm();
39  break;
40  }
41  case 0: {
43  << "Empty edm::Hash<> instance:\n" << "\nPlease report this to the core framework developers";
44  }
45  default: {
47  << "edm::Hash<> instance with data in illegal state:\n"
48  << hash
49  << "\nPlease report this to the core framework developers";
50  }
51  }
52  }
53 
54  bool
56  return 16 == hash.size();
57  }
58 
59  bool
61  return isCompactForm_(hash) ? (hash != detail::InvalidHash()) : (!hash.empty());
62  }
63 
64  void
66  // Fixup not needed here.
67  if (hash.size() % 2 == 1) {
69  << "Ill-formed Hash instance. "
70  << "Please report this to the core framework developers";
71  }
72  }
73 
74  void
75  toString_(std::string& result, value_type const& hash) {
76  value_type temp1(hash);
77  fixup_(temp1);
79  copy_all(temp1, temp.bytes);
80  result += temp.toString();
81  }
82 
83  void
84  toDigest_(cms::Digest& digest, value_type const& hash) {
85  // FIXME: do we really need to go through a temporary value_type???
86  value_type temp1(hash);
87  fixup_(temp1);
89  copy_all(temp1, temp.bytes);
90  digest.append(temp.toString());
91  }
92 
93  std::ostream&
94  print_(std::ostream& os, value_type const& hash) {
95  value_type temp1(hash);
96  fixup_(temp1);
98  copy_all(temp1, temp.bytes);
99  os << temp.toString();
100  return os;
101  }
102  }
103 }
void toDigest_(cms::Digest &digest, value_type const &hash)
Definition: Hash.cc:84
bool isCompactForm_(value_type const &hash)
Definition: Hash.cc:55
bool isValid_(value_type const &hash)
Definition: Hash.cc:60
void fixup_(value_type &hash)
Definition: Hash.cc:30
std::ostream & print_(std::ostream &os, value_type const &hash)
Definition: Hash.cc:94
void toString_(std::string &result, value_type const &hash)
Definition: Hash.cc:75
unsigned char bytes[16]
Definition: Digest.h:21
void fromHexifiedString(std::string const &s)
Definition: Digest.cc:111
std::string const & InvalidHash()
Definition: Hash.cc:9
std::string value_type
Definition: Hash.h:29
value_type compactForm_(value_type const &hash)
Definition: Hash.cc:17
std::string compactForm() const
Definition: Digest.cc:102
tuple result
Definition: query.py:137
std::string toString() const
Definition: Digest.cc:87
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:24
void throwIfIllFormed(value_type const &hash)
Definition: Hash.cc:65
void append(std::string const &s)
Definition: Digest.cc:182