Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why no WriteUnsignedInt/WriteUnsignedIntLE methods? #611

Open
Himmelt opened this issue Aug 17, 2023 · 2 comments
Open

Why no WriteUnsignedInt/WriteUnsignedIntLE methods? #611

Himmelt opened this issue Aug 17, 2023 · 2 comments

Comments

@Himmelt
Copy link

Himmelt commented Aug 17, 2023

There are ReadUnsignedInt/ReadUnsignedIntLE/GetUnsignedInt/GetUnsignedIntLE/SetUnsignedInt/SetUnsignedIntLE methods, but no WriteUnsignedInt/WriteUnsignedIntLE ? why? How should I do to write an uint with little-endian to the ByteBuf ?

/// <summary>
/// Gets an unsigned integer at the current <see cref="ReaderIndex" /> and increases the <see cref="ReaderIndex" />
/// by <c>4</c> in this buffer.
/// </summary>
/// <exception cref="IndexOutOfRangeException">if <see cref="ReadableBytes" /> is less than <c>4</c></exception>
uint ReadUnsignedInt();
/// <summary>
/// Gets an unsigned integer at the current <see cref="ReaderIndex" /> in the Little Endian Byte Order and
/// increases the <see cref="ReaderIndex" /> by <c>4</c> in this buffer.
/// </summary>
/// <exception cref="IndexOutOfRangeException">if <see cref="ReadableBytes" /> is less than <c>4</c></exception>
uint ReadUnsignedIntLE();

@ScarletKuro
Copy link
Contributor

Try something like this:

public static IByteBuffer WriteUnsignedInt(this IByteBuffer buffer, uint value)
{
	unchecked
	{
		return buffer.WriteInt((int)value);
	}
}

public static IByteBuffer WriteUnsignedIntLE(this IByteBuffer buffer,uint value)
{
	unchecked
	{
		return buffer.WriteIntLE((int)value);
	}
}

why?

Probably missing by mistake, I would PR them, but this repository is dead.

@Himmelt
Copy link
Author

Himmelt commented Aug 28, 2023

@ScarletKuro Thanks, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants