byte.h 776 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef AFUN_BYTE_H
  2. #define AFUN_BYTE_H
  3. #include <cstdio> // NOLINT
  4. #include <iostream>
  5. #include "aFunToolExport.h"
  6. namespace aFuntool {
  7. enum af_EndianType {
  8. little_endian = 0,
  9. big_endian
  10. };
  11. extern enum af_EndianType endian;
  12. AFUN_TOOL_EXPORT void getEndian();
  13. template <typename T>
  14. AFUN_TOOL_EXPORT bool byteWriteInt(FILE *file, T num);;
  15. AFUN_TOOL_EXPORT bool byteWriteStr(FILE *file, const char *str);
  16. AFUN_TOOL_EXPORT bool byteWriteStr(FILE *file, const std::string &str);
  17. template <typename T>
  18. AFUN_TOOL_EXPORT bool byteReadInt(FILE *file, T *num);
  19. AFUN_TOOL_EXPORT bool byteReadStr(FILE *file, std::string &str);
  20. AFUN_TOOL_EXPORT bool byteReadStr(FILE *file, char *&str);
  21. }
  22. #endif //AFUN_BYTE_H