qBittorrent
Digest32< N > Class Template Reference

#include <digest32.h>

Public Types

using UnderlyingType = lt::digest32< N >
 

Public Member Functions

 Digest32 ()=default
 
 Digest32 (const UnderlyingType &nativeDigest)
 
bool isValid () const
 
 operator UnderlyingType () const
 
QString toString () const
 

Static Public Member Functions

static constexpr int length ()
 
static Digest32 fromString (const QString &digestString)
 

Private Attributes

bool m_valid = false
 
UnderlyingType m_nativeDigest
 
QString m_hashString
 

Detailed Description

template<int N>
class Digest32< N >

Definition at line 38 of file digest32.h.

Member Typedef Documentation

◆ UnderlyingType

template<int N>
using Digest32< N >::UnderlyingType = lt::digest32<N>

Definition at line 41 of file digest32.h.

Constructor & Destructor Documentation

◆ Digest32() [1/2]

template<int N>
Digest32< N >::Digest32 ( )
default

◆ Digest32() [2/2]

template<int N>
Digest32< N >::Digest32 ( const UnderlyingType nativeDigest)
inline

Definition at line 45 of file digest32.h.

46  : m_valid {true}
47  , m_nativeDigest {nativeDigest}
48  {
49  const QByteArray raw = QByteArray::fromRawData(nativeDigest.data(), length());
50  m_hashString = QString::fromLatin1(raw.toHex());
51  }
bool m_valid
Definition: digest32.h:91
static constexpr int length()
Definition: digest32.h:53
UnderlyingType m_nativeDigest
Definition: digest32.h:92
QString m_hashString
Definition: digest32.h:93

References Digest32< N >::length(), and Digest32< N >::m_hashString.

Here is the call graph for this function:

Member Function Documentation

◆ fromString()

template<int N>
static Digest32 Digest32< N >::fromString ( const QString &  digestString)
inlinestatic

Definition at line 68 of file digest32.h.

69  {
70  if (digestString.size() != (length() * 2))
71  return {};
72 
73  const QByteArray raw = QByteArray::fromHex(digestString.toLatin1());
74  if (raw.size() != length()) // QByteArray::fromHex() will skip over invalid characters
75  return {};
76 
77  Digest32 result;
78  result.m_valid = true;
79  result.m_hashString = digestString;
80  result.m_nativeDigest.assign(raw.constData());
81 
82  return result;
83  }

References Digest32< N >::length(), Digest32< N >::m_hashString, Digest32< N >::m_nativeDigest, and Digest32< N >::m_valid.

Here is the call graph for this function:

◆ isValid()

template<int N>
bool Digest32< N >::isValid ( ) const
inline

◆ length()

template<int N>
static constexpr int Digest32< N >::length ( )
inlinestaticconstexpr

Definition at line 53 of file digest32.h.

54  {
55  return UnderlyingType::size();
56  }

Referenced by Digest32< N >::Digest32(), Digest32< N >::fromString(), and anonymous_namespace{magneturi.cpp}::isV2Hash().

Here is the caller graph for this function:

◆ operator UnderlyingType()

template<int N>
Digest32< N >::operator UnderlyingType ( ) const
inline

Definition at line 63 of file digest32.h.

64  {
65  return m_nativeDigest;
66  }

References Digest32< N >::m_nativeDigest.

◆ toString()

Member Data Documentation

◆ m_hashString

template<int N>
QString Digest32< N >::m_hashString
private

◆ m_nativeDigest

template<int N>
UnderlyingType Digest32< N >::m_nativeDigest
private

Definition at line 92 of file digest32.h.

Referenced by Digest32< N >::fromString(), and Digest32< N >::operator UnderlyingType().

◆ m_valid

template<int N>
bool Digest32< N >::m_valid = false
private

Definition at line 91 of file digest32.h.

Referenced by Digest32< N >::fromString(), and Digest32< N >::isValid().


The documentation for this class was generated from the following file: