Exemple #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;
    }

}
Exemple #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());
    }
}
Exemple #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' ;
}
Exemple #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();
}
Exemple #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;
}
Exemple #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);
	}
Exemple #10
0
Fichier : io.cpp Projet : 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;
}
Exemple #11
0
Fichier : io.cpp Projet : FMX/CGAL
IO::Mode
set_pretty_mode(std::ios& i)
{
    IO::Mode m = get_mode(i);
    i.iword(IO::mode) = IO::PRETTY;
    return m;
}
Exemple #12
0
Fichier : io.cpp Projet : 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);
}
Exemple #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();
}
Exemple #15
0
 explicit StreamRedirector(std::ios& stream, std::streambuf* newBuf) : savedBuf_(stream.rdbuf()), stream_(stream)
 {
     stream_.rdbuf(newBuf);
 }
Exemple #16
0
 ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
Exemple #17
0
	RedirectStreamBuffer(std::ios &stream, std::streambuf * new_sb) : stream(stream) {
		orig_sb = stream.rdbuf( new_sb );
	}
Exemple #18
0
Fichier : io.cpp Projet : FMX/CGAL
bool
is_binary(std::ios& i)
{
    return i.iword(IO::mode) == IO::BINARY;
}
Exemple #19
0
Fichier : io.cpp Projet : FMX/CGAL
bool
is_ascii(std::ios& i)
{
    return i.iword(IO::mode) == IO::ASCII;
}
Exemple #20
0
Fichier : io.cpp Projet : FMX/CGAL
bool
is_pretty(std::ios& i)
{
    return i.iword(IO::mode) == IO::PRETTY;
}
Exemple #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());
}