EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h

Go to the documentation of this file.
00001 
00002 /************************************************************/
00003 /*                              */
00004 /*    Predefined char stream: Input from (c++) stream.  */
00005 /*                              */
00006 /* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998.    */
00007 /*                              */
00008 /* This is completely free stuff, do whatever you want with  */
00009 /* it (but then, I will take no responsability for whatever  */
00010 /* may happen if you do either... caveat emptor!).      */
00011 /*                              */
00012 /************************************************************/
00013 
00014 #ifndef _DLG_STREAM_INPUT_H
00015 #define _DLG_STREAM_INPUT_H
00016 
00017 #include "pccts_istream.h"
00018 
00019 PCCTS_NAMESPACE_STD
00020 
00021 #ifndef DLGX_H
00022 #include "DLexerBase.h"
00023 #endif
00024 
00025 
00026 // NOTES:  The semantics of the copy constructor
00027 //      and the affectation operator may be unwaranted...
00028 //      and the stream may not be reset.
00029 //
00030 //      It would have been so much nicer for nextChar()
00031 //      to throw (of for the DLGInputStream to change status)
00032 //      upon hiting EOF than to return an "int"...
00033 
00034 template  <
00035         class E,
00036         class T = ::std::char_traits<E>
00037       >
00038 class DLG_stream_input : public DLGInputStream
00039 {
00040 public:
00041   
00042             DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)
00043   :  input(p_input_stream)
00044   {
00045     // nothing to do!
00046   };
00047   
00048             DLG_stream_input(const DLG_stream_input & a_recopier)
00049   :  input(a_recopier.input)
00050   {
00051     // nothing to do!
00052   };
00053   
00054   virtual        ~DLG_stream_input()
00055   {
00056     this->purge();  // bloody templarized lookup...
00057   };
00058   
00059   DLG_stream_input  operator = (const DLG_stream_input & a_affecter)
00060   {
00061     if (this != &a_affecter)
00062     {
00063       input = a_affecter.input;
00064     }
00065 
00066     return(*this);
00067   };
00068   
00069   virtual int      nextChar()
00070   {
00071     E  extracted_stuff;
00072     
00073     input->get(extracted_stuff);
00074     
00075     if  (*input)
00076     {
00077       return(int(extracted_stuff));
00078     }
00079     else
00080     {
00081       return(EOF);
00082     }
00083   };
00084   
00085 protected:
00086   
00087   ::std::basic_istream<E,T> *  input;
00088   
00089 private:
00090   
00091   void  purge()
00092   {
00093     // nothing to do!
00094   };
00095 };
00096 
00097 #endif /* _DLG_STREAM_INPUT_H */
00098 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines