using System;
using System.Runtime.InteropServices;
namespace System.Text
{
/// Converts a sequence of encoded bytes into a set of characters.
/// 1
// Token: 0x020005E1 RID: 1505
[ComVisible(true)]
[Serializable]
public abstract class Decoder
{
/// Gets or sets a object for the current object.
/// A object.
/// The value in a set operation is null (Nothing).
/// A new value cannot be assigned in a set operation because the current object contains data that has not been decoded yet.
/// 1
// Token: 0x17000AB5 RID: 2741
// (get) Token: 0x060036D1 RID: 14033 RVA: 0x000BC41C File Offset: 0x000BA61C
// (set) Token: 0x060036D2 RID: 14034 RVA: 0x000BC424 File Offset: 0x000BA624
[ComVisible(false)]
public DecoderFallback Fallback
{
get
{
return this.fallback;
}
set
{
if (value == null)
{
throw new ArgumentNullException();
}
this.fallback = value;
this.fallback_buffer = null;
}
}
/// Gets the object associated with the current object.
/// A object.
/// 1
// Token: 0x17000AB6 RID: 2742
// (get) Token: 0x060036D3 RID: 14035 RVA: 0x000BC440 File Offset: 0x000BA640
[ComVisible(false)]
public DecoderFallbackBuffer FallbackBuffer
{
get
{
if (this.fallback_buffer == null)
{
this.fallback_buffer = this.fallback.CreateFallbackBuffer();
}
return this.fallback_buffer;
}
}
/// When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
/// The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.
/// The byte array containing the sequence of bytes to decode.
/// The index of the first byte to decode.
/// The number of bytes to decode.
///
/// is null (Nothing).
///
/// or is less than zero.-or- and do not denote a valid range in .
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D4 RID: 14036
public abstract int GetCharCount(byte[] bytes, int index, int count);
/// When overridden in a derived class, decodes a sequence of bytes from the specified byte array and any bytes in the internal buffer into the specified character array.
/// The actual number of characters written into .
/// The byte array containing the sequence of bytes to decode.
/// The index of the first byte to decode.
/// The number of bytes to decode.
/// The character array to contain the resulting set of characters.
/// The index at which to start writing the resulting set of characters.
///
/// is null (Nothing).-or- is null (Nothing).
///
/// or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in .
///
/// does not have enough capacity from to the end of the array to accommodate the resulting characters.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D5 RID: 14037
public abstract int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex);
/// When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. A parameter indicates whether to clear the internal state of the decoder after the calculation.
/// The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.
/// The byte array containing the sequence of bytes to decode.
/// The index of the first byte to decode.
/// The number of bytes to decode.
/// true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
///
/// is null (Nothing).
///
/// or is less than zero.-or- and do not denote a valid range in .
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D6 RID: 14038 RVA: 0x000BC470 File Offset: 0x000BA670
[ComVisible(false)]
public virtual int GetCharCount(byte[] bytes, int index, int count, bool flush)
{
if (flush)
{
this.Reset();
}
return this.GetCharCount(bytes, index, count);
}
/// When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer. A parameter indicates whether to clear the internal state of the decoder after the calculation.
/// The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.
/// A pointer to the first byte to decode.
/// The number of bytes to decode.
/// true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
///
/// is null (Nothing in Visual Basic .NET).
///
/// is less than zero.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D7 RID: 14039 RVA: 0x000BC488 File Offset: 0x000BA688
[CLSCompliant(false)]
[ComVisible(false)]
public unsafe virtual int GetCharCount(byte* bytes, int count, bool flush)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count");
}
byte[] array = new byte[count];
Marshal.Copy((IntPtr)((void*)bytes), array, 0, count);
return this.GetCharCount(array, 0, count, flush);
}
/// When overridden in a derived class, decodes a sequence of bytes from the specified byte array and any bytes in the internal buffer into the specified character array. A parameter indicates whether to clear the internal state of the decoder after the conversion.
/// The actual number of characters written into the parameter.
/// The byte array containing the sequence of bytes to decode.
/// The index of the first byte to decode.
/// The number of bytes to decode.
/// The character array to contain the resulting set of characters.
/// The index at which to start writing the resulting set of characters.
/// true to clear the internal state of the decoder after the conversion; otherwise, false.
///
/// is null (Nothing).-or- is null (Nothing).
///
/// or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in .
///
/// does not have enough capacity from to the end of the array to accommodate the resulting characters.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D8 RID: 14040 RVA: 0x000BC4D8 File Offset: 0x000BA6D8
public virtual int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, bool flush)
{
this.CheckArguments(bytes, byteIndex, byteCount);
this.CheckArguments(chars, charIndex);
if (flush)
{
this.Reset();
}
return this.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
}
/// When overridden in a derived class, decodes a sequence of bytes starting at the specified byte pointer and any bytes in the internal buffer into a set of characters that are stored starting at the specified character pointer. A parameter indicates whether to clear the internal state of the decoder after the conversion.
/// The actual number of characters written at the location indicated by the parameter.
/// A pointer to the first byte to decode.
/// The number of bytes to decode.
/// A pointer to the location at which to start writing the resulting set of characters.
/// The maximum number of characters to write.
/// true to clear the internal state of the decoder after the conversion; otherwise, false.
///
/// is null (Nothing).-or- is null (Nothing).
///
/// or is less than zero.
///
/// is less than the resulting number of characters.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036D9 RID: 14041 RVA: 0x000BC514 File Offset: 0x000BA714
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe virtual int GetChars(byte* bytes, int byteCount, char* chars, int charCount, bool flush)
{
this.CheckArguments(chars, charCount, bytes, byteCount);
char[] array = new char[charCount];
Marshal.Copy((IntPtr)((void*)chars), array, 0, charCount);
byte[] array2 = new byte[byteCount];
Marshal.Copy((IntPtr)((void*)bytes), array2, 0, byteCount);
return this.GetChars(array2, 0, byteCount, array, 0, flush);
}
/// When overridden in a derived class, sets the decoder back to its initial state.
/// 2
// Token: 0x060036DA RID: 14042 RVA: 0x000BC568 File Offset: 0x000BA768
[ComVisible(false)]
public virtual void Reset()
{
if (this.fallback_buffer != null)
{
this.fallback_buffer.Reset();
}
}
/// Converts a buffer of encoded bytes to Unicode characters and stores the result in another buffer.
/// The address of a buffer that contains the byte sequences to convert.
/// The number of bytes in to convert.
/// The address of a buffer to store the converted characters.
/// The maximum number of characters in to use in the conversion.
/// true to indicate no further data is to be converted; otherwise, false.
/// When this method returns, contains the number of bytes that were produced by the conversion. This parameter is passed uninitialized.
/// When this method returns, contains the number of characters from that were used in the conversion. This parameter is passed uninitialized.
/// When this method returns, contains true if all the characters specified by were converted; otherwise, false. This parameter is passed uninitialized.
///
/// or is null (Nothing).
///
/// or is less than zero.
/// The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the method.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036DB RID: 14043 RVA: 0x000BC580 File Offset: 0x000BA780
[CLSCompliant(false)]
[ComVisible(false)]
public unsafe virtual void Convert(byte* bytes, int byteCount, char* chars, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
{
this.CheckArguments(chars, charCount, bytes, byteCount);
bytesUsed = byteCount;
for (;;)
{
charsUsed = this.GetCharCount(bytes, bytesUsed, flush);
if (charsUsed <= charCount)
{
break;
}
flush = false;
bytesUsed >>= 1;
}
completed = bytesUsed == byteCount;
charsUsed = this.GetChars(bytes, bytesUsed, chars, charCount, flush);
}
/// Converts an array of encoded bytes to Unicode characters and stores the result in a byte array.
/// A byte array to convert.
/// The first element of to convert.
/// The number of elements of to convert.
/// An array to store the converted characters.
/// The first element of in which data is stored.
/// The maximum number of elements of to use in the conversion.
/// true to indicate that no further data is to be converted; otherwise, false.
/// When this method returns, contains the number of bytes that were used in the conversion. This parameter is passed uninitialized.
/// When this method returns, contains the number of characters from that were produced by the conversion. This parameter is passed uninitialized.
/// When this method returns, contains true if all the characters specified by were converted; otherwise, false. This parameter is passed uninitialized.
///
/// or is null (Nothing).
///
/// , , , or is less than zero.-or-The length of - is less than .-or-The length of - is less than .
/// The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the method.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x060036DC RID: 14044 RVA: 0x000BC5E8 File Offset: 0x000BA7E8
[ComVisible(false)]
public virtual void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
{
this.CheckArguments(bytes, byteIndex, byteCount);
this.CheckArguments(chars, charIndex);
if (charCount < 0 || chars.Length < charIndex + charCount)
{
throw new ArgumentOutOfRangeException("charCount");
}
bytesUsed = byteCount;
for (;;)
{
charsUsed = this.GetCharCount(bytes, byteIndex, bytesUsed, flush);
if (charsUsed <= charCount)
{
break;
}
flush = false;
bytesUsed >>= 1;
}
completed = bytesUsed == byteCount;
charsUsed = this.GetChars(bytes, byteIndex, bytesUsed, chars, charIndex, flush);
}
// Token: 0x060036DD RID: 14045 RVA: 0x000BC67C File Offset: 0x000BA87C
private void CheckArguments(char[] chars, int charIndex)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (charIndex < 0 || chars.Length <= charIndex)
{
throw new ArgumentOutOfRangeException("charIndex");
}
}
// Token: 0x060036DE RID: 14046 RVA: 0x000BC6B8 File Offset: 0x000BA8B8
private void CheckArguments(byte[] bytes, int byteIndex, int byteCount)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (byteIndex < 0 || bytes.Length <= byteIndex)
{
throw new ArgumentOutOfRangeException("byteIndex");
}
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
{
throw new ArgumentOutOfRangeException("byteCount");
}
}
// Token: 0x060036DF RID: 14047 RVA: 0x000BC710 File Offset: 0x000BA910
private unsafe void CheckArguments(char* chars, int charCount, byte* bytes, int byteCount)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (charCount < 0)
{
throw new ArgumentOutOfRangeException("charCount");
}
if (byteCount < 0)
{
throw new ArgumentOutOfRangeException("byteCount");
}
}
// Token: 0x0400166A RID: 5738
private DecoderFallback fallback = new DecoderReplacementFallback();
// Token: 0x0400166B RID: 5739
private DecoderFallbackBuffer fallback_buffer;
}
}