btye.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef AFUN_BYTE_H
  2. #define AFUN_BYTE_H
  3. #include <stdio.h>
  4. #include "aFunToolExport.h"
  5. // byte工具
  6. #define byteWriteInt_8(file, s) (byteWriteUint_8(file, ((uint8_t)(s))))
  7. #define byteWriteInt_16(file, s) (byteWriteUint_16(file, ((uint16_t)(s))))
  8. #define byteWriteInt_32(file, s) (byteWriteUint_32(file, ((uint32_t)(s))))
  9. #define byteWriteInt_64(file, s) (byteWriteUint_64(file, ((uint64_t)(s))))
  10. #define byteReadInt_8(file, s) (byteReadUint_8(file, ((uint8_t *)(s))))
  11. #define byteReadInt_16(file, s) (byteReadUint_16(file, ((uint16_t *)(s))))
  12. #define byteReadInt_32(file, s) (byteReadUint_32(file, ((uint32_t *)(s))))
  13. #define byteReadInt_64(file, s) (byteReadUint_64(file, ((uint64_t *)(s))))
  14. enum af_EndianType{
  15. little_endian = 0,
  16. big_endian
  17. };
  18. extern enum af_EndianType endian;
  19. AFUN_TOOL_EXPORT void getEndian();
  20. AFUN_TOOL_EXPORT bool byteWriteUint_8(FILE *file, uint8_t ch);
  21. AFUN_TOOL_EXPORT bool byteWriteUint_16(FILE *file, uint16_t num);
  22. AFUN_TOOL_EXPORT bool byteWriteUint_32(FILE *file, uint32_t num);
  23. AFUN_TOOL_EXPORT bool byteWriteUint_64(FILE *file, uint64_t num);
  24. AFUN_TOOL_EXPORT bool byteWriteStr(FILE *file, const char *str);
  25. AFUN_TOOL_EXPORT bool byteReadUint_8(FILE *file, uint8_t *ch);
  26. AFUN_TOOL_EXPORT bool byteReadUint_16(FILE *file, uint16_t *num);
  27. AFUN_TOOL_EXPORT bool byteReadUint_32(FILE *file, uint32_t *num);
  28. AFUN_TOOL_EXPORT bool byteReadUint_64(FILE *file, uint64_t *num);
  29. AFUN_TOOL_EXPORT bool byteReadStr(FILE *file, char **str);
  30. #endif //AFUN_BYTE_H