]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/VfrCompile/Pccts/h/DLG_stream_input.h
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / Pccts / h / DLG_stream_input.h
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/DLG_stream_input.h b/BaseTools/Source/C/VfrCompile/Pccts/h/DLG_stream_input.h
new file mode 100644 (file)
index 0000000..d2147f5
--- /dev/null
@@ -0,0 +1,98 @@
+\r
+/************************************************************/\r
+/*                                                                                                                     */\r
+/*             Predefined char stream: Input from (c++) stream.        */\r
+/*                                                                                                                     */\r
+/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998.           */\r
+/*                                                                                                                     */\r
+/* This is completely free stuff, do whatever you want with    */\r
+/* it (but then, I will take no responsability for whatever    */\r
+/* may happen if you do either... caveat emptor!).                     */\r
+/*                                                                                                                     */\r
+/************************************************************/\r
+\r
+#ifndef _DLG_STREAM_INPUT_H\r
+#define _DLG_STREAM_INPUT_H\r
+\r
+#include "pccts_istream.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef DLGX_H\r
+#include "DLexerBase.h"\r
+#endif\r
+\r
+\r
+// NOTES:      The semantics of the copy constructor\r
+//                     and the affectation operator may be unwaranted...\r
+//                     and the stream may not be reset.\r
+//\r
+//                     It would have been so much nicer for nextChar()\r
+//                     to throw (of for the DLGInputStream to change status)\r
+//                     upon hiting EOF than to return an "int"...\r
+\r
+template       <\r
+                               class E,\r
+                               class T = ::std::char_traits<E>\r
+                       >\r
+class DLG_stream_input : public DLGInputStream\r
+{\r
+public:\r
+       \r
+                                               DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)\r
+       :       input(p_input_stream)\r
+       {\r
+               // nothing to do!\r
+       };\r
+       \r
+                                               DLG_stream_input(const DLG_stream_input & a_recopier)\r
+       :       input(a_recopier.input)\r
+       {\r
+               // nothing to do!\r
+       };\r
+       \r
+       virtual                         ~DLG_stream_input()\r
+       {\r
+               this->purge();  // bloody templarized lookup...\r
+       };\r
+       \r
+       DLG_stream_input        operator = (const DLG_stream_input & a_affecter)\r
+       {\r
+               if (this != &a_affecter)\r
+               {\r
+                       input = a_affecter.input;\r
+               }\r
+\r
+               return(*this);\r
+       };\r
+       \r
+       virtual int                     nextChar()\r
+       {\r
+               E       extracted_stuff;\r
+               \r
+               input->get(extracted_stuff);\r
+               \r
+               if      (*input)\r
+               {\r
+                       return(int(extracted_stuff));\r
+               }\r
+               else\r
+               {\r
+                       return(EOF);\r
+               }\r
+       };\r
+       \r
+protected:\r
+       \r
+       ::std::basic_istream<E,T> *     input;\r
+       \r
+private:\r
+       \r
+       void    purge()\r
+       {\r
+               // nothing to do!\r
+       };\r
+};\r
+\r
+#endif /* _DLG_STREAM_INPUT_H */\r
+\r