※C++随笔※=>☆C++基础☆=>※№ C++文件操作 (fstream)(九)

2014-11-24 07:22:03 · 作者: · 浏览: 10
ID
* @note put () corresponds to the form: ifstream & get (char & ch); function is to read a single character
from the stream, and the result is stored in the reference ch, if the end of the file, and returns
a null character. As file2.get (x); represents a character read from the file, and read characters
stored in x.
* @attention
*/
VOID
AL_File::Get(NCHAR& ch)
{
if (NULL == m_pfstream) {
return;
}
m_pfstream->get(ch);
}
/**
* Get (Reading and writing binary files)
*
* @param NCHAR* pStr
* @param DWORD dwGetNum
* @param NCHAR chEndChar
* @return VOID
* @note ifstream & get (char * buf, int num, char delim = '\ n'); this form to read characters into the
array pointed to by buf until reads num characters or encounter characters specified by delim,
ifdelim this parameter will use the default value of the newline character '\ n'. For example:
file2.get (str1, 127, 'A') ;/ / read characters from a file into a string str1 terminate when
to encounter characters 'A' or read 127 characters.
* @attention
*/
VOID
AL_File::Get(NCHAR* pStr, DWORD dwGetNum, NCHAR chEndChar)
{
if (NULL == m_pfstream) {
return;
}
m_pfstream->get(pStr, dwGetNum, chEndChar);
}
/**
* Read (Reading and writing binary files)
*
* @param NCHAR* buf
* @param DWORD dwNum
* @return BOOL
* @note Prototype: read (unsigned char * buf, int num); read () num characters to read from the file
cache buf points to the end of the file has not been read into the num characters can use member
functionsint gcount (); to get the actual number of characters read
* @attention
*/
VOID
AL_File::Read(NCHAR* buf, DWORD dwNum)
{
if (NULL == m_pfstream) {
return;
}
m_pfstream->read(buf, dwNum);
}
/**
* Write (Reading and writing binary files)
*
* @param NCHAR* buf
* @param DWORD dwNum
* @return BOOL
* @note Prototype: write (const unsigned char * buf, int num); write () from buf points to the cache
write num characters to the file, it is noteworthy cache type is unsigned char *, may sometimes
be necessary type conversion.
* @attention
*/
VOID
AL_File::Write(const NCHAR* buf, DWORD dwNum)
{
if (NULL == m_pfstream) {
return;
}
m_pfstream->write(buf, dwNum);
}
/**
* Eof End of file is read (Reading and writing binary files)
*
* @param VOID
* @return BOOL
* @note
* @attention
*/
BOOL
AL_File::Eof(VOID)
{
if (NULL == m_pfstream) {
return FALSE;
}
return m_pfstream->eof();
}
/**
* Gcount The actual number of bytes read (Reading and writing binary files)
*
* @param VOID
* @return DWORD
* @note
* @attention
*/
DWORD
AL_File::Gcount(VOID)
{
if (NULL == m_pfstream) {
return FALSE;
}
return m_pfstream->gcount();
}
/**
* Seekg Absolutely move (Reading and writing binary files)
*
* @param DWORD dwSeek absolute move position
* @return VOID
* @note
* @attention Input stream operation
*/
VOID
AL_File::S