Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is merely a proposal for an addition that is indeed awkard: an alias for
LittleEndian
in a big endian system andBigEndian
in a little endian system. However, I stumbled upon a use case where it is actually useful, and I thought of at least sharing it.The NIfTI-1 data format does not specify a byte order for the file, so its contents could be in either endianness. In order to detect the file's byte order, the specification of the format itself advises implementations to check the value of a very specific field (
dim[0]
), and swap all fields if it's not between 1 and 7. An efficient solution would begin reading the header in system-native endian up to this value, and choose whether to continue reading the same way afterdim[0]
or swap everything before that and continue with the opposite byte order. It becomes an elegant solution when separated in two functions.Of course, given the nature of this alias and its trivial implementation, feel free to close this PR if you think it doesn't quite fit in.