Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. #ifndef _CCSV
  2. #define _CCSV
  3. #define CCSVFILE_BUFFER_SIZE 2*512
  4. // simple file i/o for comma seperated files
  5. class CCSVFile
  6. {
  7. public:
  8. void far * operator new( size_t cb ) { return GlobalAlloc(GPTR, cb); };
  9. void operator delete( void far * p ) {GlobalFree(p); };
  10. CCSVFile();
  11. ~CCSVFile();
  12. BOOLEAN Open(LPCWSTR pszFileName);
  13. BOOLEAN ReadToken(LPWSTR pszDest, DWORD cbMax); // reads up to comma or newline, returns fFalse on EOF
  14. BOOLEAN SkipTillEOL(void); // reads up to EOL
  15. void Close(void);
  16. inline int ILastRead(void)
  17. {
  18. return m_iLastRead;
  19. }
  20. private:
  21. BOOL FReadInBuffer(void);
  22. inline int ChNext(void);
  23. CHAR m_rgchBuf[CCSVFILE_BUFFER_SIZE]; //buffer
  24. WCHAR m_rgwchBuf[CCSVFILE_BUFFER_SIZE];
  25. LPWSTR m_pchBuf; //pointer to the next item in the buffer to read
  26. LPWSTR m_pchLast; //pointer to the last item in the buffer
  27. int m_iLastRead; //the character last read.
  28. DWORD m_cchAvail;
  29. HANDLE m_hFile;
  30. }; // ccsv
  31. #endif //_CCSV