CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
hash_algorithm_name.h
1
2#pragma once
3
4#include <system/string.h>
5#include <system/boxable_traits.h>
6
7namespace System { namespace Security { namespace Cryptography {
8
13{
16 {
17 return HashAlgorithmName(u"MD5");
18 }
19
22 {
23 return HashAlgorithmName(u"SHA1");
24 }
25
28 {
29 return HashAlgorithmName(u"SHA256");
30 }
31
34 {
35 return HashAlgorithmName(u"SHA384");
36 }
37
40 {
41 return HashAlgorithmName(u"SHA512");
42 }
43
48 static ASPOSECPP_SHARED_API bool TryFromOid(const String& oid_value, HashAlgorithmName& value);
49
53 static ASPOSECPP_SHARED_API HashAlgorithmName FromOid(const String& oid_value);
54
55 HashAlgorithmName() = default;
56
60 : m_name(name)
61 {}
62
64
67 {
68 return m_name;
69 }
70
73 {
74 return m_name == nullptr ? String::Empty : m_name;
75 }
76
77 bool Equals(const HashAlgorithmName& other) const
78 {
79 return m_name == other.m_name;
80 }
81
82 int GetHashCode() const
83 {
84 return m_name == nullptr ? 0 : m_name.GetHashCode();
85 }
86
87 bool operator==(const HashAlgorithmName& other) const
88 {
89 return Equals(other);
90 }
91
92 bool operator!=(const HashAlgorithmName& other) const
93 {
94 return !Equals(other);
95 }
96
98 static const TypeInfo& Type()
99 {
100 return *static_holder<ThisTypeInfo>();
101 }
102
103 bool IsNull() const { return false; }
104 bool operator==(std::nullptr_t) const { return false; }
105 bool operator!=(std::nullptr_t) const { return true; }
106 bool operator<(std::nullptr_t) const { return false; }
107 bool operator<=(std::nullptr_t) const { return false; }
108 bool operator>(std::nullptr_t) const { return false; }
109 bool operator>=(std::nullptr_t) const { return false; }
110
111private:
112 String m_name;
113
115 struct ThisTypeInfo : TypeInfoPtr
116 {
118 ThisTypeInfo()
119 : TypeInfoPtr(u"System::Security::Cryptography::HashAlgorithmName")
120 {}
121 };
122};
123
124constexpr bool operator==(std::nullptr_t, const HashAlgorithmName&) { return false; }
125constexpr bool operator!=(std::nullptr_t, const HashAlgorithmName&) { return true; }
126constexpr bool operator<(std::nullptr_t, const HashAlgorithmName&) { return false; }
127constexpr bool operator<=(std::nullptr_t, const HashAlgorithmName&) { return false; }
128constexpr bool operator>(std::nullptr_t, const HashAlgorithmName&) { return false; }
129constexpr bool operator>=(std::nullptr_t, const HashAlgorithmName&) { return false; }
130
135inline std::ostream& operator<<(std::ostream& stream, const HashAlgorithmName& name)
136{
137 stream << name.ToString();
138 return stream;
139}
140
145inline std::wostream& operator<<(std::wostream& stream, const HashAlgorithmName& name)
146{
147 stream << name.ToString();
148 return stream;
149}
150
151}}} // namespace System::Security::Cryptography
152
153namespace System {
154
157template<> struct IsBoxable<System::Security::Cryptography::HashAlgorithmName> : std::true_type {};
159
160} // namespace System
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
int GetHashCode() const
Hashes contained string. Implemented in ICU, doesn't match hashes in C#.
static const String Empty
Empty string.
Definition: string.h:894
Represents a particular type and provides information about it.
Definition: type_info.h:109
constexpr bool operator<=(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:127
constexpr bool operator<(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:126
constexpr bool operator==(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:124
constexpr bool operator!=(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:125
constexpr bool operator>(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:128
constexpr bool operator>=(std::nullptr_t, const HashAlgorithmName &)
Definition: hash_algorithm_name.h:129
std::ostream & operator<<(std::ostream &stream, const HashAlgorithmName &name)
Insert data into the stream using UTF-8 encoding.
Definition: hash_algorithm_name.h:135
Definition: db_command.h:9
String representing the name of a hash algorithm. This type should be allocated on stack and passed t...
Definition: hash_algorithm_name.h:13
static HashAlgorithmName get_SHA512()
Gets a HashAlgorithmName representing SHA512.
Definition: hash_algorithm_name.h:39
static HashAlgorithmName get_MD5()
Gets a HashAlgorithmName representing MD5.
Definition: hash_algorithm_name.h:15
bool operator<=(std::nullptr_t) const
Definition: hash_algorithm_name.h:107
String ToString() const
Gets string representation of the algorithm name.
Definition: hash_algorithm_name.h:72
bool operator!=(std::nullptr_t) const
Definition: hash_algorithm_name.h:105
static HashAlgorithmName get_SHA256()
Gets a HashAlgorithmName representing SHA256.
Definition: hash_algorithm_name.h:27
bool operator==(const HashAlgorithmName &other) const
Definition: hash_algorithm_name.h:87
HashAlgorithmName(const String &name)
Constructor.
Definition: hash_algorithm_name.h:59
bool operator!=(const HashAlgorithmName &other) const
Definition: hash_algorithm_name.h:92
static const TypeInfo & Type()
Returns a TypeInfo object that represent TimeSpan structure.
Definition: hash_algorithm_name.h:98
bool operator<(std::nullptr_t) const
Definition: hash_algorithm_name.h:106
bool Equals(const HashAlgorithmName &other) const
Definition: hash_algorithm_name.h:77
static HashAlgorithmName FromOid(const String &oid_value)
Create HashAlgorithmName from OID-value.
static HashAlgorithmName get_SHA1()
Gets a HashAlgorithmName representing SHA1.
Definition: hash_algorithm_name.h:21
static HashAlgorithmName get_SHA384()
Gets a HashAlgorithmName representing SHA384.
Definition: hash_algorithm_name.h:33
bool IsNull() const
Definition: hash_algorithm_name.h:103
static bool TryFromOid(const String &oid_value, HashAlgorithmName &value)
Try to create HashAlgorithmName from OID-value.
String get_Name() const
Gets string representation of the algorithm name.
Definition: hash_algorithm_name.h:66
bool operator==(std::nullptr_t) const
Definition: hash_algorithm_name.h:104
int GetHashCode() const
Definition: hash_algorithm_name.h:82
bool operator>(std::nullptr_t) const
Definition: hash_algorithm_name.h:108
HashAlgorithmName & operator=(const HashAlgorithmName &)=default
bool operator>=(std::nullptr_t) const
Definition: hash_algorithm_name.h:109
Wrapper for a pointer to an instance of TypeInfo class. This type should be allocated on stack and pa...
Definition: type_info.h:72