summaryrefslogtreecommitdiff
path: root/ACEXML/common/FileCharStream.cpp
blob: 029ffc3b2c4fc53e9906ac1f33b13ceedd8dceb8 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// $Id$

#include "common/FileCharStream.h"
#include "ace/ACE.h"

ACEXML_FileCharStream::ACEXML_FileCharStream (void)
  : filename_ (0),
    istream_ ()
{
}

ACEXML_FileCharStream::ACEXML_FileCharStream (const ACEXML_Char *name)
  : filename_ (),
    istream_ ()
{
  this->open (name);
}


ACEXML_FileCharStream::~ACEXML_FileCharStream (void)
{
  delete this->filename_;
}

int
ACEXML_FileCharStream::open (const ACEXML_Char *name)
{
  delete this->filename_;
  this->filename_ = 0;

  this->istream_.open (name, ios::in);
  if (this->istream_.bad ())
    return -1;

  this->filename_ = ACE::strnew (name);
  return 0;
}

int
ACEXML_FileCharStream::available (void)
{
  // Should return # of char available.

  if (this->istream_.is_open ())
    return 0;

  return -1;
}

int
ACEXML_FileCharStream::close (void)
{
  delete this->filename_;
  this->filename_ = 0;
  this->istream_.close ();
  return 0;
}

int
ACEXML_FileCharStream::get (ACEXML_Char& ch)
{
  // @@ Error checking?
  ch = this->istream_.get ();
  return 0;
}

int
ACEXML_FileCharStream::read (ACEXML_Char *str,
                             size_t len)
{
  // @@ Error Checking?
  this->istream_.read (str, len);
  return 0;
}

int
ACEXML_FileCharStream::peek (void)
{
  return this->istream_.peek ();
}