本文整理汇总了C++中std::fstream::gcount方法的典型用法代码示例。如果您正苦于以下问题:C++ fstream::gcount方法的具体用法?C++ fstream::gcount怎么用?C++ fstream::gcount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::fstream
的用法示例。
在下文中一共展示了fstream::gcount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encryptData
bool XorEncryptor::encryptData(std::fstream &original, std::fstream &result)
{
if (!original.is_open() || !result.is_open())
{
return false;
}
original.seekg(0, std::ios::beg);
result.seekp(0, std::ios::beg);
char c = 0;
unsigned i = 0;
while (original.good())
{
original.read(&c, 1);
c ^= password[i];
if(original.gcount() > 0)
{
result.write(&c, 1);
}
if (++i == passSize)
{
i = 0;
}
}
original.seekg(0, std::ios::beg);
result.seekg(0, std::ios::beg);
result.flush();
return true;
}
示例2: leerLinea
void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
linea.clear();
char buffer[T_BUFFER];
bool seguirLeyendo = true;
do {
archivo.getline(buffer, T_BUFFER, '\n');
linea.append(buffer, archivo.gcount());
seguirLeyendo = (archivo.gcount() == T_BUFFER);
if (archivo.bad())
archivo.clear();
} while (seguirLeyendo);
}
示例3:
bool
StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize )
{
_fstream.read( (char*)buffer, size );
if( _fstream.fail() )
return true;
nin = _fstream.gcount();
return false;
}
示例4: read
/**
* Read data from the stream. Subclasses must implement this
* method; all other read methods are implemented using it.
*
* @note The semantics of any implementation of this method are
* supposed to match those of ISO C fread(), in particular where
* it concerns setting error and end of file/stream flags.
*
* @param dataPtr pointer to a buffer into which the data is read
* @param dataSize number of bytes to be read
* @return the number of bytes which were actually read.
*/
virtual uint32 read(void *dataPtr, uint32 dataSize) {
_stream->read((char*)dataPtr, dataSize);
return _stream->gcount();
}