readonlytextfilestream.h

Go to the documentation of this file.
00001 //
00002 // Copyright [2010] Autodesk, Inc.  All rights reserved.
00003 //
00004 // Use of this software is subject to the terms of the Autodesk license
00005 // agreement provided at the time of installation or download, or which
00006 // otherwise accompanies this software in either electronic or hard copy form.  
00007 //
00008 //
00009 
00010 #pragma once
00011 
00012 #include "streams.h"
00013 
00014 invisible_class (ReadonlyTextFileStream)
00015 
00016 
00025 class ReadonlyTextFileStream : public CharStream
00026 {
00027 public:
00031     ScripterExport ReadonlyTextFileStream();
00035     ScripterExport ~ReadonlyTextFileStream();
00036 
00043     ScripterExport ReadonlyTextFileStream* open(const MCHAR* ifile_name);
00044 
00045     /* internal char stream protocol */
00046     MCHAR   get_char();
00047     void    unget_char(MCHAR c);
00048     MCHAR   peek_char();
00049     int     at_eos();
00050     unsigned int    pos();
00051     void    seek(int pos);
00052     void    rewind();
00053     void    flush_to_eol();
00054     MCHAR   putch(MCHAR c);
00055     const MCHAR*    puts(const MCHAR* str);
00056     int     printf(const MCHAR *format, ...);
00057 
00058     void    collect();
00059     void    close();
00060 
00061     void    gc_trace();
00062     void    log_to(CharStream* log);
00063     void    close_log();
00064     CharStream* get_log();
00065 private:
00066     void VerifyFileOpen() const;
00067     MCHAR CharAtPos(size_t pos);
00068     int mUngetcharCount;
00069     MCHAR mUngetcharBuf[8];
00070     char* mFileBuf;
00071     size_t mCharCount;
00072     size_t mCharPos;
00073     CharStream* mLog;
00074 };