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

Add OppositeNativeEndian alias #88

Closed
wants to merge 1 commit into from

Conversation

Enet4
Copy link
Contributor

@Enet4 Enet4 commented May 7, 2017

This PR is merely a proposal for an addition that is indeed awkard: an alias for LittleEndian in a big endian system and BigEndian 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 after dim[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.

@BurntSushi
Copy link
Owner

Hmm. So I was actually hesitant to bring in the NetworkEndian alias (see #44), which has far broader appeal than this. I grant that while you might have a valid use case, I propose that:

  1. You can create these type aliases yourself at very little cost.
  2. I wager you might be one of the few people to ever do so.

I've been very stingy with the byteorder API. I personally think we need more compelling data points than what's given here.

@Enet4
Copy link
Contributor Author

Enet4 commented May 7, 2017

I am fine with that, and I understand your concern of keeping the API clean. I guess I'll take the initiative of closing this. Kind regards.

@Enet4 Enet4 closed this May 7, 2017
@Enet4 Enet4 deleted the opposite-native-endian branch October 6, 2017 15:38
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

Successfully merging this pull request may close these issues.

None yet

2 participants