KiCad PCB EDA Suite
Loading...
Searching...
No Matches
hash_128.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 Alex Shvartzkop <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef HASH_128_H_
22#define HASH_128_H_
23
24#include <cstdint>
25#include <cstring>
26#include <iomanip>
27#include <sstream>
28
33{
34 void Clear()
35 {
36 memset( Value64, 0, sizeof( Value64 ) ); //
37 }
38
39 bool operator==( const HASH_128& aOther ) const
40 {
41 return memcmp( Value64, aOther.Value64, sizeof( Value64 ) ) == 0;
42 }
43
44 std::string ToString() const
45 {
46 std::stringstream ss;
47 ss << std::hex << std::uppercase << std::setfill( '0' )
48 << std::setw( 16 ) << Value64[0]
49 << std::setw( 16 ) << Value64[1];
50 return ss.str();
51 }
52
53public:
54 union
55 {
56 uint8_t Value8[16]{}; // Zero-initialized
57 uint32_t Value32[4];
58 uint64_t Value64[2];
59 };
60};
61
62#endif // HASH_128_H_
A storage class for 128-bit hash value.
Definition hash_128.h:33
void Clear()
Definition hash_128.h:34
uint32_t Value32[4]
Definition hash_128.h:57
bool operator==(const HASH_128 &aOther) const
Definition hash_128.h:39
uint8_t Value8[16]
Definition hash_128.h:56
std::string ToString() const
Definition hash_128.h:44
uint64_t Value64[2]
Definition hash_128.h:58