peerplays-fc/include/fc/io/fstream.hpp

48 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
2012-11-15 17:37:56 +00:00
#include <fc/shared_ptr.hpp>
2013-01-20 20:44:16 +00:00
#include <fc/filesystem.hpp>
#include <fc/io/iostream.hpp>
namespace fc {
2012-11-15 16:55:36 +00:00
class path;
class ofstream : virtual public ostream {
public:
enum mode { out, binary };
ofstream();
2012-11-15 16:55:36 +00:00
ofstream( const fc::path& file, int m = binary );
~ofstream();
2012-11-15 16:55:36 +00:00
void open( const fc::path& file, int m = binary );
size_t writesome( const char* buf, size_t len );
void put( char c );
void close();
void flush();
private:
class impl;
2012-11-15 17:37:56 +00:00
fc::shared_ptr<impl> my;
};
2012-11-15 16:55:36 +00:00
class ifstream : virtual public istream {
public:
enum mode { in, binary };
2012-12-02 21:46:28 +00:00
enum seekdir { beg, cur, end };
ifstream();
2012-11-15 16:55:36 +00:00
ifstream( const fc::path& file, int m );
~ifstream();
2012-12-02 21:46:28 +00:00
void open( const fc::path& file, int m );
size_t readsome( char* buf, size_t len );
ifstream& read( char* buf, size_t len );
2012-12-02 21:46:28 +00:00
ifstream& seekg( size_t p, seekdir d = beg );
void get( char& c ) { read( &c, 1 ); }
void close();
bool eof()const;
private:
class impl;
2012-11-15 17:37:56 +00:00
fc::shared_ptr<impl> my;
};
} // namespace fc