LLVM  8.0.1
raw_sha1_ostream.h
Go to the documentation of this file.
1 //==- raw_sha1_ostream.h - raw_ostream that compute SHA1 --*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the raw_sha1_ostream class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
15 #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/Support/SHA1.h"
20 
21 namespace llvm {
22 
23 /// A raw_ostream that hash the content using the sha1 algorithm.
24 class raw_sha1_ostream : public raw_ostream {
25  SHA1 State;
26 
27  /// See raw_ostream::write_impl.
28  void write_impl(const char *Ptr, size_t Size) override {
29  State.update(ArrayRef<uint8_t>((const uint8_t *)Ptr, Size));
30  }
31 
32 public:
33  /// Return the current SHA1 hash for the content of the stream
35  flush();
36  return State.result();
37  }
38 
39  /// Reset the internal state to start over from scratch.
40  void resetHash() { State.init(); }
41 
42  uint64_t current_pos() const override { return 0; }
43 };
44 
45 } // end llvm namespace
46 
47 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:29
void init()
Reinitialize the internal state.
Definition: SHA1.cpp:85
StringRef result()
Return a reference to the current raw 160-bits SHA1 for the digested data since the last call to init...
Definition: SHA1.cpp:261
void update(ArrayRef< uint8_t > Data)
Digest more data.
Definition: SHA1.cpp:213
void resetHash()
Reset the internal state to start over from scratch.
uint64_t current_pos() const override
Return the current position within the stream, not counting the bytes currently in the buffer...
A raw_ostream that hash the content using the sha1 algorithm.
StringRef sha1()
Return the current SHA1 hash for the content of the stream.
uint32_t Size
Definition: Profile.cpp:47
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49