Class ByteConverter
Converts types and arrays before being sent or after being received across the network. Unless an overload is called with useNbo = false, Network Byte Order will be used in the conversion.
Inherited Members
Namespace: Couchbase.Core.IO.Converters
Assembly: Couchbase.NetClient.dll
Syntax
public static class ByteConverter
Methods
| Edit this page View SourceFromInt16(short, Span<byte>)
Writes a short to a buffer, using network byte order.
Declaration
public static void FromInt16(short value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
short | value | The value. |
Span<byte> | buffer | The buffer. |
FromInt16(short, Span<byte>, bool)
Writes a short to a buffer.
Declaration
public static void FromInt16(short value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
short | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
FromInt32(int, Span<byte>)
Writes a int to a buffer, using network byte order.
Declaration
public static void FromInt32(int value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value. |
Span<byte> | buffer | The buffer. |
FromInt32(int, Span<byte>, bool)
Writes a int to a buffer.
Declaration
public static void FromInt32(int value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
FromInt64(long, Span<byte>)
Writes a long to a buffer, using network byte order.
Declaration
public static void FromInt64(long value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
long | value | The value. |
Span<byte> | buffer | The buffer. |
FromInt64(long, Span<byte>, bool)
Writes a long to a buffer.
Declaration
public static void FromInt64(long value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
long | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
FromString(string, Span<byte>)
Writes a string to a buffer.
Declaration
public static int FromString(string value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value. |
Span<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
int | Number of bytes written to the buffer. |
FromUInt16(ushort, Span<byte>)
Writes a ushort to a buffer, using network byte order.
Declaration
public static void FromUInt16(ushort value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ushort | value | The value. |
Span<byte> | buffer | The buffer. |
FromUInt16(ushort, Span<byte>, bool)
Writes a ushort to a buffer.
Declaration
public static void FromUInt16(ushort value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ushort | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
FromUInt32(uint, Span<byte>)
Writes a uint to a buffer, using network byte order.
Declaration
public static void FromUInt32(uint value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
uint | value | The value. |
Span<byte> | buffer | The buffer. |
FromUInt32(uint, Span<byte>, bool)
Writes a uint to a buffer.
Declaration
public static void FromUInt32(uint value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
uint | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
FromUInt64(ulong, Span<byte>)
Writes a ulong to a buffer, using network byte order.
Declaration
public static void FromUInt64(ulong value, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ulong | value | The value. |
Span<byte> | buffer | The buffer. |
FromUInt64(ulong, Span<byte>, bool)
Writes a ulong to a buffer.
Declaration
public static void FromUInt64(ulong value, Span<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ulong | value | The value. |
Span<byte> | buffer | The buffer. |
bool | useNbo | If |
GetStringByteCount(string)
Gets the number of bytes required to convert a string.
Declaration
public static int GetStringByteCount(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value. |
Returns
Type | Description |
---|---|
int | The number of bytes required to convert the string. |
ToBoolean(ReadOnlySpan<byte>, bool)
Reads a bool from a buffer.
Declaration
public static bool ToBoolean(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | if set to |
Returns
Type | Description |
---|---|
bool |
ToDateTime(ReadOnlySpan<byte>, bool)
Reads a DateTime from a buffer.
Declaration
public static DateTime ToDateTime(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | if set to |
Returns
Type | Description |
---|---|
DateTime |
ToDouble(ReadOnlySpan<byte>, bool)
To the double.
Declaration
public static double ToDouble(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | if set to |
Returns
Type | Description |
---|---|
double |
ToInt16(ReadOnlySpan<byte>)
Reads a short from a buffer, using network byte order.
Declaration
public static short ToInt16(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
short |
ToInt16(ReadOnlySpan<byte>, bool)
Reads a short from a buffer starting.
Declaration
public static short ToInt16(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
short |
ToInt32(ReadOnlySpan<byte>)
Reads a int from a buffer, using network byte order.
Declaration
public static int ToInt32(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
int |
ToInt32(ReadOnlySpan<byte>, bool)
Reads a int from a buffer.
Declaration
public static int ToInt32(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
int |
ToInt64(ReadOnlySpan<byte>)
Reads a long from a buffer, using network byte order.
Declaration
public static long ToInt64(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
long |
ToInt64(ReadOnlySpan<byte>, bool)
Reads a long from a buffer.
Declaration
public static long ToInt64(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
long |
ToSingle(ReadOnlySpan<byte>, bool)
Reads a float from a buffer.
Declaration
public static float ToSingle(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | if set to |
Returns
Type | Description |
---|---|
float |
ToString(ReadOnlySpan<byte>)
Returns a string from the buffer.
Declaration
public static string ToString(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
string | A string that represents this instance. |
ToUInt16(ReadOnlySpan<byte>)
Reads a ushort from a buffer, using network byte order.
Declaration
public static ushort ToUInt16(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
ushort |
ToUInt16(ReadOnlySpan<byte>, bool)
Reads a ushort from a buffer.
Declaration
public static ushort ToUInt16(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
ushort |
ToUInt32(ReadOnlySpan<byte>)
Reads a uint from a buffer, using network byte order.
Declaration
public static uint ToUInt32(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
uint |
ToUInt32(ReadOnlySpan<byte>, bool)
Reads a uint from a buffer.
Declaration
public static uint ToUInt32(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
uint |
ToUInt64(ReadOnlySpan<byte>)
Reads a ulong from a buffer, using network byte order.
Declaration
public static ulong ToUInt64(ReadOnlySpan<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
Returns
Type | Description |
---|---|
ulong |
ToUInt64(ReadOnlySpan<byte>, bool)
Reads a ulong from a buffer.
Declaration
public static ulong ToUInt64(ReadOnlySpan<byte> buffer, bool useNbo)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | buffer | The buffer. |
bool | useNbo | If |
Returns
Type | Description |
---|---|
ulong |