OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [include/] [ustl/] [ofstream.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#ifndef FDOSTREAM_H_5E27FC3D530BF3CA04D6C73F5700EECC
7
#define FDOSTREAM_H_5E27FC3D530BF3CA04D6C73F5700EECC
8
 
9
#include "sistream.h"
10
#include "sostream.h"
11
#include "fstream.h"
12
#include "config.h"
13
 
14
namespace ustl {
15
 
16
/// \class ofstream fdostream.h ustl.h
17
/// \ingroup DeviceStreams
18
/// \brief A string stream that writes to an fd. Implements cout and cerr.
19
class ofstream : public ostringstream {
20
public:
21
                        ofstream (void);
22
    explicit            ofstream (int Fd);
23
    explicit            ofstream (const char* filename, openmode mode = out);
24
    virtual            ~ofstream (void) throw();
25
    inline void         open (const char* filename, openmode mode = out) { m_File.open (filename, mode); clear (m_File.rdstate()); }
26
    void                close (void);
27
    inline bool         is_open (void) const    { return (m_File.is_open()); }
28
    inline iostate      exceptions (iostate v)  { ostringstream::exceptions(v); return (m_File.exceptions(v)); }
29
    inline void         setstate (iostate v)    { ostringstream::setstate(v); m_File.setstate(v); }
30
    inline void         clear (iostate v = goodbit)     { ostringstream::clear(v); m_File.clear(v); }
31
    inline off_t        tellp (void) const              { return (m_File.tellp() + ostringstream::tellp()); }
32
    inline int          fd (void) const                 { return (m_File.fd()); }
33
    inline void         stat (struct stat& rs) const    { m_File.stat (rs); }
34
    inline void         set_nonblock (bool v = true)    { m_File.set_nonblock (v); }
35
    inline int          ioctl (const char* rname, int request, long argument = 0)        { return (m_File.ioctl (rname, request, argument)); }
36
    inline int          ioctl (const char* rname, int request, int argument)            { return (m_File.ioctl (rname, request, argument)); }
37
    inline int          ioctl (const char* rname, int request, void* argument)          { return (m_File.ioctl (rname, request, argument)); }
38
    ofstream&           seekp (off_t p, seekdir d = beg);
39
    ofstream&           flush (void);
40
    virtual size_type   overflow (size_type n = 1);
41
private:
42
    fstream             m_File;
43
};
44
 
45
/// \class ifstream fdostream.h ustl.h
46
/// \ingroup DeviceStreams
47
/// \brief A string stream that reads from an fd. Implements cin.
48
class ifstream : public istringstream {
49
public:
50
                        ifstream (void);
51
    explicit            ifstream (int Fd);
52
    explicit            ifstream (const char* filename, openmode mode = in);
53
    inline void         open (const char* filename, openmode mode = in) { m_File.open (filename, mode); clear (m_File.rdstate()); }
54
    inline void         close (void)            { m_File.close(); clear (m_File.rdstate()); }
55
    inline bool         is_open (void) const    { return (m_File.is_open()); }
56
    inline iostate      exceptions (iostate v)  { istringstream::exceptions(v); return (m_File.exceptions(v)); }
57
    inline void         setstate (iostate v)    { istringstream::setstate(v); m_File.setstate(v); }
58
    inline void         clear (iostate v = goodbit)     { istringstream::clear(v); m_File.clear(v); }
59
    inline off_t        tellg (void) const              { return (m_File.tellg() - remaining()); }
60
    inline int          fd (void) const                 { return (m_File.fd()); }
61
    inline void         stat (struct stat& rs) const    { m_File.stat (rs); }
62
    inline void         set_nonblock (bool v = true)    { m_File.set_nonblock (v); }
63
    inline int          ioctl (const char* rname, int request, long argument = 0)        { return (m_File.ioctl (rname, request, argument)); }
64
    inline int          ioctl (const char* rname, int request, int argument)            { return (m_File.ioctl (rname, request, argument)); }
65
    inline int          ioctl (const char* rname, int request, void* argument)          { return (m_File.ioctl (rname, request, argument)); }
66
    ifstream&           seekg (off_t p, seekdir d = beg);
67
    int                 sync (void);
68
    virtual size_type   underflow (size_type n = 1);
69
private:
70
    string              m_Buffer;
71
    fstream             m_File;
72
};
73
 
74
#ifdef CYGVAR_USTL_CIN_COUT_CERR
75
extern ofstream cout, cerr;
76
extern ifstream cin;
77
#endif
78
 
79
} // namespace ustl
80
 
81
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.