本文整理汇总了C++中std::iostream::tellg方法的典型用法代码示例。如果您正苦于以下问题:C++ iostream::tellg方法的具体用法?C++ iostream::tellg怎么用?C++ iostream::tellg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::iostream
的用法示例。
在下文中一共展示了iostream::tellg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveFile
bool ResourceManager::saveFile(const std::string& fileName, std::iostream& in)
{
std::streampos oldPos = in.tellg();
in.seekg(0, std::ios::end);
std::streampos size = in.tellg();
in.seekg(0, std::ios::beg);
std::vector<char> buffer(size);
in.read(&buffer[0], size);
bool ret = saveFile(fileName, (const uchar*)&buffer[0], size);
in.seekg(oldPos, std::ios::beg);
return ret;
}
示例2: inttostr
void Client::setResponseContentLength(Transaction& trans, std::iostream& os)
{
os.seekg(0, std::ios::end);
int os_length = os.tellg();
os_length--;
os.seekg(0, std::ios::beg);
trans.getResponse().getHeaders().setValue("CONTENT-LENGTH", inttostr(os_length));
}
示例3: GetAsString
std::string StringUtilities::GetAsString(std::iostream& i_stream)
{
int length;
char* p_buffer;
// get length of file:
i_stream.seekg (0, std::iostream::end);
length = static_cast<int>(i_stream.tellg());
i_stream.seekg (0, std::iostream::beg);
// allocate memory:
p_buffer = new char [length];
//write file
int pos = 0;
while(i_stream.good())
{
p_buffer[pos] = i_stream.get();
++pos;
}
std::string out(p_buffer, pos);
delete[] p_buffer;
return out;
}