summaryrefslogtreecommitdiff
path: root/ACEXML/common/FileCharStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'ACEXML/common/FileCharStream.h')
-rw-r--r--ACEXML/common/FileCharStream.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/ACEXML/common/FileCharStream.h b/ACEXML/common/FileCharStream.h
new file mode 100644
index 00000000000..0be3a14217c
--- /dev/null
+++ b/ACEXML/common/FileCharStream.h
@@ -0,0 +1,67 @@
+// -*- C++ -*- $Id$
+
+#ifndef _ACEXML_FILECHARSTREAM_H_
+#define _ACEXML_FILECHARSTREAM_H_
+
+#include "Common/CharStream.h"
+#include "ace/streams.h"
+
+/**
+ * An implementation of ACEXML_CharStream for reading
+ * input from a file.
+ * defines the basic opertion the parser
+ * could use to retrieve XML charater sequence. The sequence
+ * can be read from a file or a character buffer.
+ */
+class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_FileCharStream (void);
+
+ /// Construct and opening a file.
+ ACEXML_FileCharStream (const ACEXML_Char *name);
+
+ /// Destructor
+ virtual ~ACEXML_FileCharStream (void);
+
+ /// Open a file.
+ int open (const ACEXML_Char *name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str,
+ size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+private:
+ ACEXML_Char *filename_;
+
+ ifstream istream_;
+
+};
+
+#endif /* _ACEXML_FILECHARSTREAM_H_ */