celtic / rubyex

a Ruby VM/interpreter

This URL has Read+Write access

rubyex / vm / rio.h
100644 47 lines (34 sloc) 0.975 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef RIO_H
#define RIO_H
 
#include <stdio.h>
#include "rei.h"
#include "robject.h"
#include "renvironment.h"
 
class RubyIOEI : public RubyEnvironmentInitializer
{
  public:
    void init(RubyEnvironment &);
};
 
extern const char SEPARATOR;
 
class RubyIO : public RubyObject
{
  public:
    RubyIO(RubyEnvironment &);
    RubyIO(linked_ptr<Binding> &, int, const char *);
    ~RubyIO();
 
    static std::string rv_to_mode(linked_ptr<Binding> &, RubyValue);
 
    void init(linked_ptr<Binding> &, int, const char *);
    std::string read(linked_ptr<Binding> &);
    std::string read(linked_ptr<Binding> &, int);
    int write(linked_ptr<Binding> &, const std::string &);
    void flush(linked_ptr<Binding> &);
    void close(linked_ptr<Binding> &);
 
    bool sync;
    FILE *file;
 
    static std::string filename_join(const std::string &, const std::string &);
 
  protected:
    void _check(linked_ptr<Binding> &);
};
 
class IOEOFError : public std::exception
{ };
 
#endif