|
Unicorn XML Toolkit Version 1.50.00 |
|||||||||
� PREV CLASS ��NEXT CLASS | FRAMES��NO FRAMES | |||||||||
SUMMARY: � CONSTR �|� FUNCTION �|�DATA | DETAIL: � CONSTR �|� FUNCTION �|�DATA |
class CTextFile: public CInterface { public: enum { standardInput, standardOutput, standardError }; enum { fromBegin, fromCurrent, fromEnd }; enum { errOk = 0, errFileNotOpen = 10001, errFileAlreadyOpen = 10002, errInvalidPath = 10003, errInvalidMode = 10004, errFunctionNotSupported = 10005 }; public: CTextFile(); CTextFile(int nStandard); ~CTextFile(); public: static bool Exists(const WCHAR *pszPath); static bool Remove(const WCHAR *pszPath); static bool Rename( const WCHAR *pszOldPath, const WCHAR *pszNewPath); public: void ClearError(); bool Close(); bool Eof(); int Error(); bool Flush(); int GetLength(); int GetPosition(); bool Open( const WCHAR *pszPath, const WCHAR *pszMode, CEncoding *pEncoding=NULL); CString Read(); CString Read(int nCount); bool SetPosition(int nPosition, int nFrom=fromBegin); bool Write(const WCHAR *pszData); bool Write(const WCHAR *pchData, int nCount); }; typedef XInterface<CTextFile> XTextFile;
The Unicode-based text file.
The Unicode-based text file contains a Unicode text encoded as a sequence of bytes according to the certain encoding algorithm.
CEncoding
Constructor/Destructor Summary | |
CTextFile
();
����������Constructs the text file. |
|
CTextFile
(int nStandard);
����������Constructs the text file, mapping one of three standard file streams (standard input, standard output, or standard error output). |
|
~CTextFile
();
����������Destroys the text file. |
Function Summary | |
bool
|
Exists
(const WCHAR *pszPath);
����������Tests whether a file with the specified path exists. |
bool
|
Remove
(const WCHAR *pszPath);
����������Removes (deletes) a file with the specified path. |
bool
|
Rename
(const WCHAR *pszOldPath, const WCHAR *pszNewPath);
����������Renames a file with the specified path. |
void
|
ClearError
();
����������Clears the last error code associated with this file. |
bool
|
Close
();
����������Closes this file. |
bool
|
Eof
();
����������Tests whether the last read operation on this file attempted to read past the end of file. |
int
|
Error
();
����������Returns an error code associated with the last operation performed on this file. |
bool
|
Flush
();
����������Flushes a stream associated with this file. |
int
|
GetLength
();
����������Returns a length, in bytes, of this file. |
int
|
GetPosition
();
����������Returns a current position of the file pointer for this file. |
bool
|
Open
(const WCHAR *pszPath, const WCHAR *pszMode, CEncoding *pEncoding=NULL);
����������Opens this file, using the specified file path, the specified access mode, and the optional encoding. |
CString
|
Read
();
����������Reads a line from this file. |
CString
|
Read
(int nCount);
����������Reads a specified number of characters from this file. |
bool
|
SetPosition
(int nPosition, int nFrom=fromBegin);
����������Moves the file pointer to a specified position. |
bool
|
Write
(const WCHAR *pszData);
����������Writes the specified string to this file. |
bool
|
Write
(const WCHAR *pchData, int nCount);
����������Writes the array of characters to this file. |
Constructor/Destructor Detail |
CTextFile();
Constructs the text file.
CTextFile(int nStandard);
Constructs the text file, mapping one of three standard file streams (standard input, standard output, or standard error output).
The parameter
nStandard
is used to specify the standard
stream. Allowed values are:
standardInput
,
standardOutput
, and
standardError
.
nStandard
- the code of the standard stream~CTextFile();
Destroys the text file.
Function Detail |
static bool Exists(const WCHAR *pszPath);
Tests whether a file with the specified path exists.
The syntax of the file path is platform-dependent.
pszPath
- the file pathtrue
if a file with the specified
path exists;
false
otherwisestatic bool Remove(const WCHAR *pszPath);
Removes (deletes) a file with the specified path.
The syntax of the file path is platform-dependent.
pszPath
- the file pathtrue
if the file was successfully
removed;
false
otherwisestatic bool Rename( const WCHAR *pszOldPath, const WCHAR *pszNewPath);
Renames a file with the specified path.
The syntax of the file path is platform-dependent.
pszOldPath
- the original file pathpszNewPath
- the new file pathtrue
if the file was successfully
renamed;
false
otherwisevoid ClearError();
Clears the last error code associated with this file.
bool Close();
Closes this file.
Operation failes if this file is not open.
true
if this file was successfully closed;
false
otherwisebool Eof();
Tests whether the last read operation on this file attempted to read past the end of file.
Operation failes if this file is not open.
true
if
the last read operation on this file attempted to
read past the end of file;
false
otherwiseint Error();
Returns an error code associated with the last operation performed on this file.
Allowed values are those returned by
the standard
ferror
function of the C run-time library,
and the extended error codes
errOk
,
errFileNotOpen
,
errFileAlreadyOpen
,
errInvalidPath
,
errInvalidMode
, and
errFunctionNotSupported
.
If the last operation was completed successfully,
the code
errOk
is returned.
bool Flush();
Flushes a stream associated with this file.
This operation has the same effect as the standard
fflush
function of the C run-time library.
true
if this file was successfully
flushed;
false
otherwiseint GetLength();
Returns a length, in bytes, of this file.
Operation failes if this file is not open.
-1
if operation failedint GetPosition();
Returns a current position of the file pointer for this file.
Operation failes if this file is not open or if it is open with the explicitly specified encoding.
-1
if operation failedbool Open( const WCHAR *pszPath, const WCHAR *pszMode, CEncoding *pEncoding=NULL);
Opens this file, using the specified file path, the specified access mode, and the optional encoding.
The access mode string has the same syntax and
meaning as the second argument of the standard
fopen
function of the C run-time library.
The encoding, if specified, describes the character encoding
used to interpret the byte content of this file. If the
encoding is not specified explicitly (the corresponding parameter
is set to
NULL
), the ISO-8859-1 encoding is
implicitly used.
If the encoding is explicitly specified, the access
mode string is not allowed to contain characters
'+'
(read/write access) and
'b'
(binary access).
Furthermore,
GetPosition
and
SetPosition
functions are not permitted
and will fail in this case.
Operation failes if this file is already open.
pszPath
- the file pathpszMode
- the access modepEncoding
- the encoding;
NULL
if no explicit encoding specifiedtrue
if this file was open
successfully;
false
otherwiseCString Read();
Reads a line from this file.
Operation failes if this file is not open.
CString Read(int nCount);
Reads a specified number of characters from this file.
Operation failes if this file is not open.
nCount
- the number of characters to readbool SetPosition(int nPosition, int nFrom=fromBegin);
Moves the file pointer to a specified position.
The file pointer is positioned relatively to the origin.
The origin is specified using the origin code; allowed values
are:
fromBegin
for beginning of file,
fromCurrent
for current position of file pointer, and
fromEnd
for end of file.
Operation failes if this file is not open or if it is open with the explicitly specified encoding.
nPosition
- the position relative to the originnFrom
- the indicator of the origintrue
if the file pointer was
successfully positioned;
false
otherwisebool Write(const WCHAR *pszData);
Writes the specified string to this file.
Operation failes if this file is not open.
pszData
- the string to writetrue
if the string was
successfully written;
false
otherwisebool Write(const WCHAR *pchData, int nCount);
Writes the array of characters to this file.
Operation failes if this file is not open.
pchData
- the array of characters to writenCount
- the number of characters to writetrue
if the string was
successfully written;
false
otherwise
|
Unicorn XML Toolkit Version 1.50.00 |
|||||||||
� PREV CLASS ��NEXT CLASS | FRAMES��NO FRAMES | |||||||||
SUMMARY: � CONSTR �|� FUNCTION �|�DATA | DETAIL: � CONSTR �|� FUNCTION �|�DATA |