本文整理汇总了C++中std::ios类的典型用法代码示例。如果您正苦于以下问题:C++ ios类的具体用法?C++ ios怎么用?C++ ios使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ios类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char**)
{
const std::ios ios(0);
assert(ios.fill() == ' ');
return 0;
}
示例2:
void DenseLinAlgPack::LinAlgPackIO::ios_format_memento::set_format(std::ios& s) const {
s.flags(flags_);
s.precision(prec_);
s.width(wdt_);
s.fill(fill_);
}
示例3: printstate
void
printstate(const std::ios &ios)
{
if (ios.good()) {
std::cout << "ios.good" << std::endl;
} else if (ios.eof()){
std::cout << "ios.eof" << std::endl;
} else if (ios.fail()){
std::cout << "ios.fail" << std::endl;
} else if (ios.bad()){
std::cout << "ios.bad" << std::endl;
}
}
示例4: set_ascii_mode
IO::Mode
set_ascii_mode(std::ios& i)
{
IO::Mode m = get_mode(i);
i.iword(IO::mode) = IO::ASCII;
return m;
}
示例5: throwIfNotGood
void throwIfNotGood(const std::ios& stream, const std::string& file) {
if (!stream.good()) {
std::stringstream ss;
ss << "Cannot open file " << file;
throw std::runtime_error(ss.str());
}
}
示例6: StreamStateSaver
explicit StreamStateSaver(std::ios &stream)
: stream(stream)
, state(nullptr)
{
// Save the stream's state.
state.copyfmt(stream);
}
示例7: set_mode
IO::Mode
set_mode(std::ios& i, IO::Mode m)
{
IO::Mode old = get_mode(i);
i.iword(IO::mode) = m;
return old;
}
示例8: set_binary_mode
IO::Mode
set_binary_mode(std::ios& i)
{
IO::Mode m = get_mode(i);
i.iword(IO::mode) = IO::BINARY;
return m;
}
示例9: set_pretty_mode
IO::Mode
set_pretty_mode(std::ios& i)
{
IO::Mode m = get_mode(i);
i.iword(IO::mode) = IO::PRETTY;
return m;
}
示例10: turnExceptionsOn
void FragmentedFileWriter::turnExceptionsOn(std::ios& stream)
{
stream.exceptions( std::ios_base::badbit|std::ios_base::failbit);
}
示例11: print_state
//prints the error flags when an attempt to open a file fails
void util::print_state (const std::ios& stream) {
cerr << " good()=" << stream.good();
cerr << " eof()=" << stream.eof();
cerr << " fail()=" << stream.fail();
cerr << " bad()=" << stream.bad();
}
示例12: StreamRedirector
explicit StreamRedirector(std::ios& stream, std::streambuf* newBuf) : savedBuf_(stream.rdbuf()), stream_(stream)
{
stream_.rdbuf(newBuf);
}
示例13: print_state
void print_state (const std::ios& stream) {
std::cout << " good()=" << stream.good();
std::cout << " eof()=" << stream.eof();
std::cout << " fail()=" << stream.fail();
std::cout << " bad()=" << stream.bad();
}
示例14: show_results
void show_results( std::ios& stm )
{
std::cout << std::boolalpha << "bad: " << stm.bad() << " fail: " << stm.fail()
<< " eof: " << stm.eof() << " good: " << stm.good()
<< " bool(stm): " << bool(stm) << " !stm: " << !stm << '\n' ;
}
示例15: is_binary
bool
is_binary(std::ios& i)
{
return i.iword(IO::mode) == IO::BINARY;
}