CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
utf7_encoding.h
1
2#pragma once
3
4#include <system/text/encoding.h>
5
6namespace System { namespace Text {
7
12class ASPOSECPP_SHARED_CLASS UTF7Encoding : public Encoding
13{
14private:
16 class UTF7Decoder : public Decoder
17 {
18 private:
20 int m_left_over;
21
22 public:
24 using Decoder::Convert;
25
27 ASPOSECPP_SHARED_API UTF7Decoder();
28
34 ASPOSECPP_SHARED_API int GetCharCount(const uint8_t* bytes, int count, bool flush) override;
44 ASPOSECPP_SHARED_API void Convert(const uint8_t* bytes, int byte_count, char_t* chars, int char_count, bool flush, int& bytes_used, int& chars_used, bool& completed) override;
45 }; // class UTF7Decoder
46
47private:
49 class UTF7Encoder : public Encoder
50 {
51 private:
53 bool m_allow_optionals;
55 int m_left_over;
57 bool m_is_in_shifted;
58
59 public:
61 using Encoder::Convert;
62
65 ASPOSECPP_SHARED_API UTF7Encoder(bool allow_optionals);
66
72 ASPOSECPP_SHARED_API int GetByteCount(const char_t* chars, int count, bool flush) override;
82 ASPOSECPP_SHARED_API void Convert(const char_t* chars, int char_count, uint8_t* bytes, int byte_count, bool flush, int& chars_used, int& bytes_used, bool& completed) override;
83 }; // class UTF7Encoder
84
85public:
87 static constexpr int UTF7_CODE_PAGE = 65000;
88
89private:
91 bool m_allow_optionals;
92
95 static const ArrayPtr<uint8_t> encoding_rules;
97 static const String base64_chars;
99 static const ArrayPtr<char> base64_values;
100
101public:
103 using Encoding::GetBytes;
105 using Encoding::GetChars;
107
109 ASPOSECPP_SHARED_API UTF7Encoding();
112 ASPOSECPP_SHARED_API UTF7Encoding(bool allow_optionals);
113
117 ASPOSECPP_SHARED_API bool operator==(const UTF7Encoding& other) const;
121 ASPOSECPP_SHARED_API bool Equals(SharedPtr<Object> obj) override;
124 ASPOSECPP_SHARED_API int GetHashCode() const override;
125
128 ASPOSECPP_SHARED_API SharedPtr<Object> Clone() override;
129
137 ASPOSECPP_SHARED_API int GetBytes(ArrayPtr<char_t> chars, int char_index, int char_count, ArrayPtr<uint8_t> bytes, int byte_index) override;
143 ASPOSECPP_SHARED_API int GetCharCount(ArrayPtr<uint8_t> bytes, int index, int count) override;
144
145public:
153 ASPOSECPP_SHARED_API int GetChars(ArrayPtr<uint8_t> bytes, int byte_index, int byte_count, ArrayPtr<char_t> chars, int char_index) override;
157 ASPOSECPP_SHARED_API int GetMaxByteCount(int char_count) override;
161 ASPOSECPP_SHARED_API int GetMaxCharCount(int byte_count) override;
164 ASPOSECPP_SHARED_API DecoderPtr GetDecoder() override;
167 ASPOSECPP_SHARED_API EncoderPtr GetEncoder() override;
168
173 ASPOSECPP_SHARED_API int GetByteCount(const char_t* chars, int count) override;
174
181 ASPOSECPP_SHARED_API int GetBytes(const char_t* chars, int char_count, uint8_t* bytes, int byte_count) override;
189 ASPOSECPP_SHARED_API int GetBytes(const String& s, int char_index, int char_count, ArrayPtr<uint8_t> bytes, int byte_index) override;
190
195 ASPOSECPP_SHARED_API int GetCharCount(const uint8_t* bytes, int count) override;
202 ASPOSECPP_SHARED_API int GetChars(const uint8_t* bytes, int byte_count, char_t* chars, int char_count) override;
203
209 ASPOSECPP_SHARED_API String GetString(ArrayPtr<uint8_t> bytes, int index, int count) override;
210
211private:
213 void InitializeInstanceFields();
214
225 static int InternalGetByteCount(const char_t* chars, int chars_count, int index, int count, bool flush, int left_over, bool is_in_shifted, bool allow_optionals);
237 static int InternalGetBytes(const ArrayPtr<char_t>& chars, int char_index, int char_count, const ArrayPtr<uint8_t>& bytes, int byte_index, bool flush, int& left_over, bool& is_in_shifted, bool allow_optionals);
248 static int InternalGetBytes(const char_t* chars, int char_count, uint8_t* bytes, int byte_count, bool flush, int& left_over, bool& is_in_shifted, bool allow_optionals);
249
257 static int InternalGetCharCount(const uint8_t* bytes, int bytes_count, int index, int count, int left_over);
266 static int InternalGetChars(const ArrayPtr<uint8_t>& bytes, int byte_index, int byte_count, const ArrayPtr<char_t>& chars, int char_index, int& left_over);
275 static int InternalGetChars(const uint8_t* bytes, int& byte_count, char_t* chars, int char_count, int& left_over,
276 bool& completed);
277}; // class UTF7Encoding
278
279}} // namespace System::Text
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
Encapsulates decoding byte sequence into character sequence. Objects of this class should only be all...
Definition: decoder.h:19
virtual int GetCharCount(ArrayPtr< uint8_t > bytes, int index, int count)
Gets the number of characters needed to decode a buffer.
virtual void Convert(ArrayPtr< uint8_t > bytes, int byteIndex, int byteCount, ArrayPtr< char_t > chars, int charIndex, int charCount, bool flush, int &bytesUsed, int &charsUsed, bool &completed)
Converts bytes to characters.
Encapsulates encoding character sequence into byte sequence. Objects of this class should only be all...
Definition: encoder.h:18
virtual int GetByteCount(ArrayPtr< char_t > chars, int index, int count, bool flush)
Gets the number of bytes needed to encode a buffer.
virtual void Convert(ArrayPtr< char_t > chars, int charIndex, int charCount, ArrayPtr< uint8_t > bytes, int byteIndex, int byteCount, bool flush, int &charsUsed, int &bytesUsed, bool &completed)
Converts characters to bytes.
Encoding services.
Definition: encoding.h:67
virtual int GetByteCount(ArrayPtr< char_t > chars, int index, int count)
Get the number of characters needed to encode a character buffer.
virtual int GetBytes(ArrayPtr< char_t > chars, int char_index, int char_count, ArrayPtr< uint8_t > bytes, int byte_index)
Get the bytes that result from encoding a character buffer.
virtual int GetCharCount(ArrayPtr< uint8_t > bytes, int index, int count)
Get the number of characters needed to decode a byte buffer.
virtual String GetString(uint8_t *bytes, int byte_count)
Decodes a buffer of bytes into a string.
virtual int GetChars(ArrayPtr< uint8_t > bytes, int byte_index, int byte_count, ArrayPtr< char_t > chars, int char_index)
Get the characters that result from decoding a byte buffer.
UTF-7 encoding. Objects of this class should only be allocated using System::MakeObject() function....
Definition: utf7_encoding.h:13
int GetByteCount(const char_t *chars, int count) override
Get the number of characters needed to encode a character buffer.
String GetString(ArrayPtr< uint8_t > bytes, int index, int count) override
Decodes a buffer of bytes into a string.
int GetBytes(ArrayPtr< char_t > chars, int char_index, int char_count, ArrayPtr< uint8_t > bytes, int byte_index) override
Get the bytes that result from encoding a character buffer.
int GetChars(ArrayPtr< uint8_t > bytes, int byte_index, int byte_count, ArrayPtr< char_t > chars, int char_index) override
Get the characters that result from decoding a byte buffer.
bool Equals(SharedPtr< Object > obj) override
Compares with object.
SharedPtr< Object > Clone() override
Clones encoding object.
int GetMaxCharCount(int byte_count) override
Get the maximum number of characters needed to decode a specified number of bytes.
int GetHashCode() const override
Gets encoding hash code.
int GetChars(const uint8_t *bytes, int byte_count, char_t *chars, int char_count) override
Get the characters that result from decoding a byte buffer.
int GetCharCount(const uint8_t *bytes, int count) override
Get the number of characters needed to decode a byte buffer.
int GetBytes(const String &s, int char_index, int char_count, ArrayPtr< uint8_t > bytes, int byte_index) override
Get the bytes that result from encoding a character buffer.
bool operator==(const UTF7Encoding &other) const
Compares encodings parameters.
EncoderPtr GetEncoder() override
Get an encoder that forwards requests to this object.
int GetMaxByteCount(int char_count) override
Get the maximum number of bytes needed to encode a specified number of characters.
DecoderPtr GetDecoder() override
Get a decoder that forwards requests to this object.
int GetBytes(const char_t *chars, int char_count, uint8_t *bytes, int byte_count) override
Get the bytes that result from encoding a character buffer.
UTF7Encoding(bool allow_optionals)
Constructor.
int GetCharCount(ArrayPtr< uint8_t > bytes, int index, int count) override
Get the number of characters needed to decode a byte buffer.
@ Text
Defines color adjustment information for text.
Definition: db_command.h:9
The structure that contains methods performing conversion of values of one type to the values of anot...
Definition: convert.h:44