CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
secure_string.h
1
2#pragma once
3
4#include <system/object.h>
5#include <system/idisposable.h>
6#include <system/string.h>
7#include <system/details/spin_lock.h>
8#include <mutex>
9#include <memory>
10
11namespace System { namespace Runtime { namespace InteropServices { class Marshal; }}}
12
13namespace System { namespace Security {
14
15class SecureString;
18
24class ASPOSECPP_SHARED_CLASS SecureString final : public IDisposable
25{
27 RTTI_INFO(System::Security::SecureString, ::System::BaseTypesInfo<System::Object>)
28
29public:
31 ASPOSECPP_SHARED_API SecureString();
32
36 ASPOSECPP_SHARED_API SecureString(const char16_t* value, int32_t length);
37
39 ASPOSECPP_SHARED_API ~SecureString();
40
41 SecureString(const SecureString&) = delete;
43
45 ASPOSECPP_SHARED_API int32_t get_Length() const;
46
49 ASPOSECPP_SHARED_API void AppendChar(char16_t c);
50
52 ASPOSECPP_SHARED_API void Clear();
53
55 ASPOSECPP_SHARED_API SecureStringPtr Copy() const;
56
60 ASPOSECPP_SHARED_API void InsertAt(int32_t index, char16_t c);
61
63 ASPOSECPP_SHARED_API bool IsReadOnly() const;
64
66 ASPOSECPP_SHARED_API void MakeReadOnly();
67
70 ASPOSECPP_SHARED_API void RemoveAt(int32_t index);
71
75 ASPOSECPP_SHARED_API void SetAt(int32_t index, char16_t c);
76
78 ASPOSECPP_SHARED_API void Dispose() override;
79
82 ASPOSECPP_SHARED_API String ToUnsecureString() const;
83
84private:
85 struct Impl;
86 std::unique_ptr<Impl> m_impl;
87
88 using Lockable = Details::SpinLock;
89 using LockGuard = std::lock_guard<Lockable>;
90
92 mutable Lockable m_lockable;
93
95 void VerifyWriteable() const;
97 void VerifyNotDisposed() const;
99 void VerifyEnoughSpace() const;
100
102
104 IntPtr MarshalToString(bool global_alloc, bool unicode);
105};
106
107}} // namespace System::Security
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Provides marshalling implementation. For compatibility with translated code only, as no managed code ...
Definition: marshal.h:19
Secure string, represents text that should be kept confidential. This class DON'T ENCRYPTING the inte...
Definition: secure_string.h:25
void Dispose() override
Release all resources used by the current object.
String ToUnsecureString() const
Copies contents of this secure string into unsecure String object. Use with caution.
void InsertAt(int32_t index, char16_t c)
Inserts a character at the specified index.
void MakeReadOnly()
Makes this secure string read-only.
SecureString & operator=(const SecureString &)=delete
void RemoveAt(int32_t index)
Removes the character at the specified position.
SecureStringPtr Copy() const
Creates a duplicate of this secure string.
void Clear()
Delete all characters from the current secure string.
SecureString(const SecureString &)=delete
SecureString()
RTTI information.
bool IsReadOnly() const
Gets flag that indicates whether this object is marked read-only.
int32_t get_Length() const
Gets number of characters in this secure string.
void SetAt(int32_t index, char16_t c)
Replaces the existing character at the specified position.
void AppendChar(char16_t c)
Appends a character to the end of the string.
SecureString(const char16_t *value, int32_t length)
Constructor.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
SharedPtr< SecureString > SecureStringPtr
SecureString pointer type.
Definition: secure_string.h:17
Definition: db_command.h:9