Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
XStdioFile.h
Go to the documentation of this file.
1//! @file XStdioFile.h
2//! @brief CXStdioFile is the base class for reading text file
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(CXSTDIOFILE_INCLUDE_H)
7#define CXSTDIOFILE_INCLUDE_H
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "XFile.h"
14
15BEGIN_MOOTOOLS_NAMESPACE
16
17 ////////////////////////////////////////////////////////////////////////////////////////////////
18 //! @class CXStdioFile
19 //! @brief CXStdioFile reads or write strings from the file.
20 //! @details The string read or write depends on the operating system (unicode on windows, ansi / utf8 on linux and macos).
21 //! It is recommended to use CXStdioFileEx which is the advanced version that support unicode / ansi file as well as a simple ReadString method.\n
22 //!
23 class DLL_TOOLSFUNCTION CXStdioFile : public CXFile
24 {
25 DECLARE_DYNAMIC_XOBJECT(CXStdioFile)
26
27 public:
28 // Constructors
29 CXStdioFile(bool allowException = true);
31 CXStdioFile(LPCTSTR lpszFileName, unsigned int nOpenFlags); //!< nOpenFlags is a combination of CXFile::OpenFlags
32
33 // Operations
34 // reading and writing strings
35 virtual void WriteString(LPCTSTR lpsz);
36 virtual LPTSTR ReadString(LPTSTR lpsz, unsigned int nMax);
37 virtual bool ReadString(CXString& rString);
38
39 // Implementation
40 public:
41 virtual ~CXStdioFile();
42
43#ifdef _DEBUG
44 void Dump() const;
45#endif
46
47 virtual fileuint GetPosition() const;
48 virtual fileuint GetLength() const;
49 virtual bool Open(LPCTSTR lpszFileName, unsigned int nOpenFlags, CXFileException* pError = NULL); //!< nOpenFlags is a combination of CXFile::OpenFlags
50
51 virtual unsigned int Read(void* buffer, unsigned int maxByteToRead);
52 virtual void Write(const void* buffer, unsigned int byteToWrite);
53 virtual fileuint Seek(longint lOff, CXFile::SeekPosition nFrom);
54 virtual void Abort();
55 virtual void Flush();
56 virtual void Close();
57
58 FILE *GetStream() { return fileStream; }
59
60 protected:
61 // Attributes
62 FILE *fileStream; // stdio FILE
63
64 void *buffer;
65 unsigned int bufferSize; // Number of TCHAR allocated
66
67 bool ReadStringA(CXStringA& rString); // Used by CStdioFileEx which check unicode mode
68 bool ReadStringW(CXStringW& rString); // Used by CStdioFileEx which check unicode mode
69
70 void ThrowErrno(CXFileException::FileExceptionType exceptionType) const;
71
72 private:
73 void Init(FILE* openStream);
74 };
75
76END_MOOTOOLS_NAMESPACE
77
78#endif // !defined(CXSTDIOFILE_INCLUDE_H)
CXFile is the base class for different kind of file (CXStdioFile, CXMemFile...)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CXFile is the base class for CXStdioFile, CXStdioFileEx, CXMemFile.
Definition XFile.h:42
CXStdioFile reads or write strings from the file.
Definition XStdioFile.h:24
virtual bool Open(LPCTSTR lpszFileName, unsigned int nOpenFlags, CXFileException *pError=NULL)
nOpenFlags is a combination of CXFile::OpenFlags
CXStdioFile(LPCTSTR lpszFileName, unsigned int nOpenFlags)
nOpenFlags is a combination of CXFile::OpenFlags