LLDB mainline
Checksum.cpp
Go to the documentation of this file.
1//===-- Checksum.cpp ------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/STLExtras.h"
11#include "llvm/ADT/SmallString.h"
12
13using namespace lldb_private;
14
15Checksum::Checksum(llvm::MD5::MD5Result md5) { SetMD5(md5); }
16
17Checksum::Checksum(const Checksum &checksum) { SetMD5(checksum.m_checksum); }
18
20 SetMD5(checksum.m_checksum);
21 return *this;
22}
23
24void Checksum::SetMD5(llvm::MD5::MD5Result md5) {
25 const constexpr size_t md5_length = 16;
26 std::uninitialized_copy_n(md5.begin(), md5_length, m_checksum.begin());
27}
28
29Checksum::operator bool() const { return !llvm::equal(m_checksum, g_sentinel); }
30
31bool Checksum::operator==(const Checksum &checksum) const {
32 return llvm::equal(m_checksum, checksum.m_checksum);
33}
34
35bool Checksum::operator!=(const Checksum &checksum) const {
36 return !(*this == checksum);
37}
38
39std::string Checksum::digest() const {
40 return std::string(m_checksum.digest());
41}
42
43llvm::MD5::MD5Result Checksum::g_sentinel = {
44 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
Checksum & operator=(const Checksum &checksum)
Definition: Checksum.cpp:19
llvm::MD5::MD5Result m_checksum
Definition: Checksum.h:32
Checksum(llvm::MD5::MD5Result md5=g_sentinel)
Definition: Checksum.cpp:15
static llvm::MD5::MD5Result g_sentinel
Definition: Checksum.h:17
std::string digest() const
Definition: Checksum.cpp:39
bool operator==(const Checksum &checksum) const
Definition: Checksum.cpp:31
void SetMD5(llvm::MD5::MD5Result)
Definition: Checksum.cpp:24
bool operator!=(const Checksum &checksum) const
Definition: Checksum.cpp:35
A class that represents a running process on the host machine.