add C++ convenience overloads to uint*.h

master
leitner 1 year ago
parent 5b6e6a0671
commit b4ba06aee4

@ -1,5 +1,6 @@
0.34: 0.34:
be more C99 compliant (Florian Weimer) be more C99 compliant (Florian Weimer)
add C++ convenience overloads to uint*.h
0.33: 0.33:
add byte_start, byte_starts add byte_start, byte_starts

@ -83,6 +83,64 @@ static inline size_t scan_uint16_big(const char* in, size_t len, uint16_t* b) {
#ifdef __cplusplus #ifdef __cplusplus
} }
inline void uint16_pack(unsigned char* out,uint16 in) {
uint16_pack(reinterpret_cast<char*>(out), in);
}
inline void uint16_pack_big(unsigned char* out,uint16 in) {
uint16_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint16_unpack(const unsigned char *in,uint16* out) {
uint16_unpack(reinterpret_cast<const char*>(in), out);
}
inline void uint16_unpack_big(const unsigned char *in,uint16* out) {
uint16_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline void uint16_pack(uint16* out,uint16 in) {
uint16_pack(reinterpret_cast<char*>(out), in);
}
inline void uint16_pack_big(uint16* out,uint16 in) {
uint16_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint16_unpack(uint16* *in,uint16* out) {
uint16_unpack(reinterpret_cast<const char*>(in), out);
}
inline void uint16_unpack_big(uint16* *in,uint16* out) {
uint16_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline uint16 uint16_read(const unsigned char *in) {
return uint16_read(reinterpret_cast<const char*>(in));
}
inline uint16 uint16_read_big(const unsigned char *in) {
return uint16_read_big(reinterpret_cast<const char*>(in));
}
inline uint16 uint16_read(const uint16 *in) {
return uint16_read(reinterpret_cast<const char*>(in));
}
inline uint16 uint16_read_big(const uint16 *in) {
return uint16_read_big(reinterpret_cast<const char*>(in));
}
inline uint16 uint_read(const uint16* in) {
return uint16_read(reinterpret_cast<const char*>(in));
}
inline uint16 uint_read_big(const uint16* in) {
return uint16_read_big(reinterpret_cast<const char*>(in));
}
#endif #endif
#endif #endif

@ -83,6 +83,62 @@ static inline size_t scan_uint32_big(const char* in, size_t len, uint32_t* b) {
#ifdef __cplusplus #ifdef __cplusplus
} }
inline void uint32_pack(unsigned char* out,uint32 in) {
uint32_pack(reinterpret_cast<char*>(out), in);
}
inline void uint32_pack_big(unsigned char* out,uint32 in) {
uint32_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint32_unpack(const unsigned char *in,uint32* out) {
uint32_unpack(reinterpret_cast<const char*>(in), out);
}
inline void uint32_unpack_big(const unsigned char *in,uint32* out) {
uint32_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline void uint32_pack(uint32* out,uint32 in) {
uint32_pack(reinterpret_cast<char*>(out), in);
}
inline void uint32_pack_big(uint32* out,uint32 in) {
uint32_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint32_unpack(uint32* *in,uint32* out) {
uint32_unpack(reinterpret_cast<const char*>(in), out);
}
inline void uint32_unpack_big(uint32* *in,uint32* out) {
uint32_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline uint32 uint32_read(const unsigned char *in) {
return uint32_read(reinterpret_cast<const char*>(in));
}
inline uint32 uint32_read_big(const unsigned char *in) {
return uint32_read_big(reinterpret_cast<const char*>(in));
}
inline uint32 uint32_read(const uint32 *in) {
return uint32_read(reinterpret_cast<const char*>(in));
}
inline uint32 uint32_read_big(const uint32 *in) {
return uint32_read_big(reinterpret_cast<const char*>(in));
}
inline uint32 uint_read(const uint32* in) {
return uint32_read(reinterpret_cast<const char*>(in));
}
inline uint32 uint_read_big(const uint32* in) {
return uint32_read_big(reinterpret_cast<const char*>(in));
}
#endif #endif
#endif #endif

@ -54,6 +54,65 @@ static inline size_t scan_uint64_big(const char* in, size_t len, uint64_t* b) {
#ifdef __cplusplus #ifdef __cplusplus
} }
#ifndef uint64_pack
inline void uint64_pack(unsigned char* out,uint64 in) {
uint64_pack(reinterpret_cast<char*>(out), in);
}
inline void uint64_unpack(const unsigned char *in,uint64* out) {
uint64_unpack(reinterpret_cast<const char*>(in), out);
}
inline void uint64_pack(uint64* out,uint64 in) {
uint64_pack(reinterpret_cast<char*>(out), in);
}
inline void uint64_unpack(uint64* *in,uint64* out) {
uint64_unpack(reinterpret_cast<const char*>(in), out);
}
inline uint64 uint64_read(const unsigned char *in) {
return uint64_read(reinterpret_cast<const char*>(in));
}
inline uint64 uint64_read(const uint64 *in) {
return uint64_read(reinterpret_cast<const char*>(in));
}
#endif
inline uint64 uint64_read_big(const unsigned char *in) {
return uint64_read_big(reinterpret_cast<const char*>(in));
}
inline uint64 uint64_read_big(const uint64 *in) {
return uint64_read_big(reinterpret_cast<const char*>(in));
}
inline void uint64_pack_big(unsigned char* out,uint64 in) {
uint64_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint64_unpack_big(const unsigned char *in,uint64* out) {
uint64_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline void uint64_pack_big(uint64* out,uint64 in) {
uint64_pack_big(reinterpret_cast<char*>(out), in);
}
inline void uint64_unpack_big(uint64* *in,uint64* out) {
uint64_unpack_big(reinterpret_cast<const char*>(in), out);
}
inline uint64 uint_read(const uint64* in) {
return uint64_read(reinterpret_cast<const char*>(in));
}
inline uint64 uint_read_big(const uint64* in) {
return uint64_read_big(reinterpret_cast<const char*>(in));
}
#endif #endif
#endif #endif

Loading…
Cancel
Save