~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to ACEXML/common/FileCharStream.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- C++ -*-
2
 
 
3
 
//=============================================================================
4
 
/**
5
 
 *  @file    FileCharStream.h
6
 
 *
7
 
 *  FileCharStream.h,v 1.13 2003/11/06 16:34:32 dhinton Exp
8
 
 *
9
 
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
10
 
 */
11
 
//=============================================================================
12
 
 
13
 
#ifndef _ACEXML_FILECHARSTREAM_H_
14
 
#define _ACEXML_FILECHARSTREAM_H_
15
 
 
16
 
#include /**/ "ace/pre.h"
17
 
#include "ACEXML/common/ACEXML_Export.h"
18
 
 
19
 
#if !defined (ACE_LACKS_PRAGMA_ONCE)
20
 
#pragma once
21
 
#endif /* ACE_LACKS_PRAGMA_ONCE */
22
 
 
23
 
#include "ACEXML/common/CharStream.h"
24
 
#include "ACEXML/common/Encoding.h"
25
 
 
26
 
/**
27
 
 * @class ACEXML_FileCharStream FileCharStream.h "ACEXML/common/FileCharStream.h"
28
 
 *
29
 
 * An implementation of ACEXML_CharStream for reading input from a file.
30
 
 */
31
 
class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream
32
 
{
33
 
public:
34
 
  /// Default constructor.
35
 
  ACEXML_FileCharStream (void);
36
 
 
37
 
  /// Destructor
38
 
  virtual ~ACEXML_FileCharStream (void);
39
 
 
40
 
  /// Open a file.
41
 
  int open (const ACEXML_Char *name);
42
 
 
43
 
  /**
44
 
   * Returns the available ACEXML_Char in the buffer.  -1
45
 
   * if the object is not initialized properly.
46
 
   */
47
 
  virtual int available (void);
48
 
 
49
 
  /**
50
 
   * Close this stream and release all resources used by it.
51
 
   */
52
 
  virtual int close (void);
53
 
 
54
 
  /**
55
 
   * Read the next ACEXML_Char.  Return -1 if we are not able to
56
 
   * return an ACEXML_Char, 0 if succees.
57
 
   */
58
 
  virtual int get (ACEXML_Char& ch);
59
 
 
60
 
  /**
61
 
   * Read the next batch of ACEXML_Char strings
62
 
   */
63
 
  virtual int read (ACEXML_Char *str,
64
 
                    size_t len);
65
 
 
66
 
  /**
67
 
   *  Determine the encoding of the file.
68
 
   */
69
 
  virtual int determine_encoding (void);
70
 
 
71
 
 
72
 
  /**
73
 
   * Peek the next ACEXML_Char in the CharStream.  Return the
74
 
   * character if success, -1 if EOF is reached.
75
 
   */
76
 
  virtual int peek (void);
77
 
 
78
 
  /**
79
 
   *  Resets the file pointer to the beginning of the stream.
80
 
   */
81
 
  virtual void rewind (void);
82
 
 
83
 
  /*
84
 
   * Get the character encoding for the file.
85
 
   */
86
 
  virtual const ACEXML_Char *getEncoding (void);
87
 
 
88
 
  /*
89
 
   * Get the systemId for the underlying CharStream
90
 
   */
91
 
  virtual const ACEXML_Char* getSystemId (void);
92
 
 
93
 
private:
94
 
 
95
 
  /** Read the next character as a normal character. Return -1 if EOF is
96
 
   *  reached, else return 0.
97
 
   */
98
 
  int getchar_i (char& ch);
99
 
 
100
 
#if defined (ACE_USES_WCHAR)
101
 
  /**
102
 
   *  Read the next character from the stream taking into account the
103
 
   *  encoding of the file.
104
 
   */
105
 
  int get_i (ACEXML_Char& ch);
106
 
 
107
 
  /**
108
 
   *  Read the next character from the stream taking into account the
109
 
   *  encoding of the file. Subsequent call to get() returns this
110
 
   *  character.
111
 
   */
112
 
  int peek_i (void);
113
 
 
114
 
#endif /* ACE_USES_WCHAR */
115
 
 
116
 
  ACEXML_Char*  filename_;
117
 
  ACEXML_Char*  encoding_;
118
 
  off_t         size_;
119
 
  FILE*         infile_;
120
 
  // This is needed to ensure that we can implement a peek operation on a
121
 
  // UTF-16 encoded file. It is a bit hackish, but there is no other way of
122
 
  // implementing a peek() as the standard I/O FILE* guarantees only one
123
 
  // pushback.
124
 
  ACEXML_Char   peek_;
125
 
};
126
 
 
127
 
 
128
 
#include /**/ "ace/post.h"
129
 
 
130
 
#endif /* _ACEXML_FILECHARSTREAM_H_ */