本文整理汇总了C++中std::iostream::good方法的典型用法代码示例。如果您正苦于以下问题:C++ iostream::good方法的具体用法?C++ iostream::good怎么用?C++ iostream::good使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::iostream
的用法示例。
在下文中一共展示了iostream::good方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _serialize
void _serialize(std::iostream &fs, serialization_context &context) {
assert(target > 0);
assert(context.ss.objects.count(target) > 0);
fs << target << " ";
target = 0;
assert(fs.good());
context.is_leaf = false;
}
示例2: grab_content
void grab_content(const char* file_name, std::iostream& in) {
parser p(file_name);
interpreter_DAG ipt(p.get_problem_representation(), in);
if (!in.good())
error("unexpected error");
}
示例3: _deserialize
void _deserialize(std::iostream &fs, serialization_context &context) {
assert(target == 0);
ss = &context.ss;
fs >> target;
assert(fs.good());
assert(context.ss.objects.count(target) > 0);
// We just created a new reference to this object and
// invalidated the on-disk reference, so the total refcount
// stays the same.
}
示例4: serialize
template<class Key, class Value> void serialize(std::iostream &fs,
serialization_context &context,
std::map<Key, Value> &mp)
{
fs << "map " << mp.size() << " {" << std::endl;
assert(fs.good());
for (auto it = mp.begin(); it != mp.end(); ++it) {
fs << " ";
serialize(fs, context, it->first);
fs << " -> ";
serialize(fs, context, it->second);
fs << std::endl;
}
fs << "}" << std::endl;
}
示例5: deserialize
template<class Key, class Value> void deserialize(std::iostream &fs,
serialization_context &context,
std::map<Key, Value> &mp)
{
std::string dummy;
int size = 0;
fs >> dummy >> size >> dummy;
assert(fs.good());
for (int i = 0; i < size; i++) {
Key k;
Value v;
deserialize(fs, context, k);
fs >> dummy;
deserialize(fs, context, v);
mp[k] = v;
}
fs >> dummy;
}
示例6: 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;
}