sqstdio.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* see copyright notice in squirrel.h */
  2. #ifndef _SQSTDIO_H_
  3. #define _SQSTDIO_H_
  4. #ifdef __cplusplus
  5. #define SQSTD_STREAM_TYPE_TAG 0x80000000
  6. struct SQStream {
  7. virtual ~SQStream() {}
  8. virtual SQInteger Read(void *buffer, SQInteger size) = 0;
  9. virtual SQInteger Write(void *buffer, SQInteger size) = 0;
  10. virtual SQInteger Flush() = 0;
  11. virtual SQInteger Tell() = 0;
  12. virtual SQInteger Len() = 0;
  13. virtual SQInteger Seek(SQInteger offset, SQInteger origin) = 0;
  14. virtual bool IsValid() = 0;
  15. virtual bool EOS() = 0;
  16. };
  17. extern "C" {
  18. #endif
  19. #define SQ_SEEK_CUR 0
  20. #define SQ_SEEK_END 1
  21. #define SQ_SEEK_SET 2
  22. typedef void* SQFILE;
  23. SQUIRREL_API SQFILE sqstd_fopen(const SQChar *,const SQChar *);
  24. SQUIRREL_API SQInteger sqstd_fread(SQUserPointer, SQInteger, SQInteger, SQFILE);
  25. SQUIRREL_API SQInteger sqstd_fwrite(const SQUserPointer, SQInteger, SQInteger, SQFILE);
  26. SQUIRREL_API SQInteger sqstd_fseek(SQFILE , SQInteger , SQInteger);
  27. SQUIRREL_API SQInteger sqstd_ftell(SQFILE);
  28. SQUIRREL_API SQInteger sqstd_fflush(SQFILE);
  29. SQUIRREL_API SQInteger sqstd_fclose(SQFILE);
  30. SQUIRREL_API SQInteger sqstd_feof(SQFILE);
  31. SQUIRREL_API SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own);
  32. SQUIRREL_API SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file);
  33. //compiler helpers
  34. SQUIRREL_API SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror);
  35. SQUIRREL_API SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror);
  36. SQUIRREL_API SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename);
  37. SQUIRREL_API SQRESULT sqstd_register_iolib(HSQUIRRELVM v);
  38. #ifdef __cplusplus
  39. } /*extern "C"*/
  40. #endif
  41. #endif /*_SQSTDIO_H_*/