Introduce SerializeIF::Endianness::NETWORK #379

Closed
opened 2021-03-04 18:56:35 +01:00 by muellerr · 3 comments
Owner

Just something I saw in the Python struct library: A explicit endianness specifier for network endianness, which is of course equal to big endian.

Just something I saw in the Python `struct` library: A explicit endianness specifier for network endianness, which is of course equal to big endian.
muellerr added the
feature
label 2021-03-04 18:56:35 +01:00
Owner

Hm "The Internet has established a standard “network byte order,” which happens to be Big Endian" so this would be

enum class Endianness : uint8_t {
		NETWORK, BIG, LITTLE, MACHINE
	};

where Network means the same as BIG, so every check looks like:

			switch (streamEndianness) {
				case SerializeIF::Endianness::NETWORK:
				case SerializeIF::Endianness::BIG:
					tmp = EndianConverter::convertBigEndian<T>(*object);
					break;
				case SerializeIF::Endianness::LITTLE:
					tmp = EndianConverter::convertLittleEndian<T>(*object);
					break;
				default:
				case SerializeIF::Endianness::MACHINE:
					tmp = *object;
					break;
				}

I'm not sure about that. BIG is even more explicit than NETWORK which kind of hides what is going on with the same effect.

Hm "The Internet has established a standard “network byte order,” which happens to be Big Endian" so this would be ``` c++ enum class Endianness : uint8_t { NETWORK, BIG, LITTLE, MACHINE }; ``` where Network means the same as BIG, so every check looks like: ``` c++ switch (streamEndianness) { case SerializeIF::Endianness::NETWORK: case SerializeIF::Endianness::BIG: tmp = EndianConverter::convertBigEndian<T>(*object); break; case SerializeIF::Endianness::LITTLE: tmp = EndianConverter::convertLittleEndian<T>(*object); break; default: case SerializeIF::Endianness::MACHINE: tmp = *object; break; } ``` I'm not sure about that. BIG is even more explicit than NETWORK which kind of hides what is going on with the same effect.
Author
Owner

so you don't like it?

so you don't like it?
Owner

Ah I'm stupid. We could just introduce somehting like that

Class SerializeIF {
....
namespace Endianness{
  static const uint8_t NETWORK = SerializeIF::Endianness::BIG;
  }
....
}

But still... I'm not sure if this is needed.

Ah I'm stupid. We could just introduce somehting like that ``` c++ Class SerializeIF { .... namespace Endianness{ static const uint8_t NETWORK = SerializeIF::Endianness::BIG; } .... } ``` But still... I'm not sure if this is needed.
gaisser added this to the ASTP 1.1.0 milestone 2021-05-11 16:32:39 +02:00
gaisser self-assigned this 2021-05-11 16:32:42 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fsfw/fsfw#379
No description provided.