3
//=============================================================================
5
* @file FileCharStream.h
7
* FileCharStream.h,v 1.13 2003/11/06 16:34:32 dhinton Exp
9
* @author Nanbor Wang <nanbor@cs.wustl.edu>
11
//=============================================================================
13
#ifndef _ACEXML_FILECHARSTREAM_H_
14
#define _ACEXML_FILECHARSTREAM_H_
16
#include /**/ "ace/pre.h"
17
#include "ACEXML/common/ACEXML_Export.h"
19
#if !defined (ACE_LACKS_PRAGMA_ONCE)
21
#endif /* ACE_LACKS_PRAGMA_ONCE */
23
#include "ACEXML/common/CharStream.h"
24
#include "ACEXML/common/Encoding.h"
27
* @class ACEXML_FileCharStream FileCharStream.h "ACEXML/common/FileCharStream.h"
29
* An implementation of ACEXML_CharStream for reading input from a file.
31
class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream
34
/// Default constructor.
35
ACEXML_FileCharStream (void);
38
virtual ~ACEXML_FileCharStream (void);
41
int open (const ACEXML_Char *name);
44
* Returns the available ACEXML_Char in the buffer. -1
45
* if the object is not initialized properly.
47
virtual int available (void);
50
* Close this stream and release all resources used by it.
52
virtual int close (void);
55
* Read the next ACEXML_Char. Return -1 if we are not able to
56
* return an ACEXML_Char, 0 if succees.
58
virtual int get (ACEXML_Char& ch);
61
* Read the next batch of ACEXML_Char strings
63
virtual int read (ACEXML_Char *str,
67
* Determine the encoding of the file.
69
virtual int determine_encoding (void);
73
* Peek the next ACEXML_Char in the CharStream. Return the
74
* character if success, -1 if EOF is reached.
76
virtual int peek (void);
79
* Resets the file pointer to the beginning of the stream.
81
virtual void rewind (void);
84
* Get the character encoding for the file.
86
virtual const ACEXML_Char *getEncoding (void);
89
* Get the systemId for the underlying CharStream
91
virtual const ACEXML_Char* getSystemId (void);
95
/** Read the next character as a normal character. Return -1 if EOF is
96
* reached, else return 0.
98
int getchar_i (char& ch);
100
#if defined (ACE_USES_WCHAR)
102
* Read the next character from the stream taking into account the
103
* encoding of the file.
105
int get_i (ACEXML_Char& ch);
108
* Read the next character from the stream taking into account the
109
* encoding of the file. Subsequent call to get() returns this
114
#endif /* ACE_USES_WCHAR */
116
ACEXML_Char* filename_;
117
ACEXML_Char* encoding_;
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
128
#include /**/ "ace/post.h"
130
#endif /* _ACEXML_FILECHARSTREAM_H_ */