[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / Support / raw_sha1_ostream.h
blob3991691796b598065935707813d7fc57f2c0e7db
1 //==- raw_sha1_ostream.h - raw_ostream that compute SHA1 --*- C++ -*-==//
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 //
9 // This file defines the raw_sha1_ostream class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
14 #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
16 #include "llvm/ADT/ArrayRef.h"
17 #include "llvm/Support/SHA1.h"
18 #include "llvm/Support/raw_ostream.h"
20 namespace llvm {
22 /// A raw_ostream that hash the content using the sha1 algorithm.
23 class raw_sha1_ostream : public raw_ostream {
24 SHA1 State;
26 /// See raw_ostream::write_impl.
27 void write_impl(const char *Ptr, size_t Size) override {
28 State.update(ArrayRef<uint8_t>((const uint8_t *)Ptr, Size));
31 public:
32 /// Return the current SHA1 hash for the content of the stream
33 StringRef sha1() {
34 flush();
35 return State.result();
38 /// Reset the internal state to start over from scratch.
39 void resetHash() { State.init(); }
41 uint64_t current_pos() const override { return 0; }
44 } // end llvm namespace
46 #endif