Beispiel #1
1
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;
    }

}
Beispiel #2
1
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());
    }
}
Beispiel #3
1
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' ;
}
Beispiel #4
1
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();
}
Beispiel #5
0
int main(int, char**)
{
    const std::ios ios(0);
    assert(ios.fill() == ' ');

  return 0;
}
void DenseLinAlgPack::LinAlgPackIO::ios_format_memento::set_format(std::ios& s) const {

  s.flags(flags_);
  s.precision(prec_);
  s.width(wdt_);
  s.fill(fill_);

}
DenseLinAlgPack::LinAlgPackIO::ios_format_memento
DenseLinAlgPack::LinAlgPackIO::ios_format_memento::save_format(const std::ios& s) {

  ios_format_memento m;

  m.flags_	= s.flags();
  m.prec_		= s.precision();
  m.wdt_		= s.width();
  m.fill_		= s.fill();

  return m;
}
Beispiel #8
0
IO::Mode
set_ascii_mode(std::ios& i)
{
    IO::Mode m = get_mode(i);
    i.iword(IO::mode) = IO::ASCII;
    return m;
}
	explicit StreamStateSaver(std::ios &stream)
		: stream(stream)
		, state(nullptr)
	{
		// Save the stream's state.
		state.copyfmt(stream);
	}
Beispiel #10
0
Datei: io.cpp Projekt: FMX/CGAL
IO::Mode
set_mode(std::ios& i, IO::Mode m)
{
    IO::Mode old = get_mode(i);
    i.iword(IO::mode) = m;
    return old;
}
Beispiel #11
0
Datei: io.cpp Projekt: FMX/CGAL
IO::Mode
set_pretty_mode(std::ios& i)
{
    IO::Mode m = get_mode(i);
    i.iword(IO::mode) = IO::PRETTY;
    return m;
}
Beispiel #12
0
Datei: io.cpp Projekt: FMX/CGAL
IO::Mode
set_binary_mode(std::ios& i)
{
    IO::Mode m = get_mode(i);
    i.iword(IO::mode) = IO::BINARY;
    return m;
}
void FragmentedFileWriter::turnExceptionsOn(std::ios& stream)
{
	stream.exceptions( std::ios_base::badbit|std::ios_base::failbit);
}
Beispiel #14
0
//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();
}
Beispiel #15
0
 explicit StreamRedirector(std::ios& stream, std::streambuf* newBuf) : savedBuf_(stream.rdbuf()), stream_(stream)
 {
     stream_.rdbuf(newBuf);
 }
Beispiel #16
0
 ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
Beispiel #17
0
	RedirectStreamBuffer(std::ios &stream, std::streambuf * new_sb) : stream(stream) {
		orig_sb = stream.rdbuf( new_sb );
	}
Beispiel #18
0
Datei: io.cpp Projekt: FMX/CGAL
bool
is_binary(std::ios& i)
{
    return i.iword(IO::mode) == IO::BINARY;
}
Beispiel #19
0
Datei: io.cpp Projekt: FMX/CGAL
bool
is_ascii(std::ios& i)
{
    return i.iword(IO::mode) == IO::ASCII;
}
Beispiel #20
0
Datei: io.cpp Projekt: FMX/CGAL
bool
is_pretty(std::ios& i)
{
    return i.iword(IO::mode) == IO::PRETTY;
}
Beispiel #21
0
IO::Mode
get_mode(std::ios& i)
{
    return static_cast<IO::Mode>(i.iword(IO::mode));
}
void DenseLinAlgPack::LinAlgPackIO::format::set_format(std::ios& s) const {
  s.flags(ios_base_flags().flags());
  s.precision(precision());
  s.width(width());
  s.fill(fill());
}
void DenseLinAlgPack::LinAlgPackIO::format::copy_format(const std::ios& s) {
  ios_base_flags().flags(s.flags());
  precision(s.precision());
  width(s.width());
  fill(s.fill());
}