Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Input Class Reference

#include <Input.hpp>

Inheritance diagram for Input::

CFile FileParser XMLParse List of all members.

Public Methods

 Input ()
void FillBuf ()
char OpenFile (char *filename)
char ReadData (char *dest, int len)
void GetChar (char *ptr)
void ReadFullUInt32 (unsigned long *data)
void ReadUInt32 (unsigned long *data)
void PeekData (char *ptr, int len)
void PeekChar (char *ptr)
void SkipData (int len)
void FastSkipData (int len)
void SkipChar ()
char IsEndOfFile (unsigned len=0)
int GetCurBlockPtr (char **ptr)
void RefillAndGetCurBlockPtr (char **ptr, int *len)
void UndoReadChar ()

Constructor & Destructor Documentation

Input::Input   [inline]
 

Definition at line 64 of file Input.hpp.

00065    {
00066       curptr=endptr=NULL;
00067       curlineno=1;
00068    }


Member Function Documentation

void Input::FastSkipData int    len [inline]
 

Definition at line 232 of file Input.hpp.

00234    {
00235       curptr+=len;
00236    }

void Input::FillBuf   [inline]
 

Definition at line 70 of file Input.hpp.

00071    {
00072       int bytesread;
00073 
00074       if(endptr-curptr>0)
00075          // Is there some unread data ?
00076       {
00077          memmove(databuf,curptr,endptr-curptr);
00078          endptr=databuf+(endptr-curptr);
00079          curptr=databuf;
00080       }
00081       else
00082          curptr=endptr=databuf;
00083 
00084       // We try to fill the rest of the buffer
00085       bytesread=ReadBlock(endptr,databuf+FILEBUF_SIZE-endptr);
00086 
00087       endptr+=bytesread;
00088    }

void Input::GetChar char *    c [inline]
 

Reimplemented in FileParser.

Definition at line 144 of file Input.hpp.

00146    {
00147       FillBufLen(1);
00148       *ptr=*curptr;
00149       if(*curptr=='\n')
00150          curlineno++;
00151       curptr++;
00152    }

int Input::GetCurBlockPtr char **    ptr [inline]
 

Definition at line 253 of file Input.hpp.

00256    {
00257       *ptr=curptr;
00258       return endptr-curptr;
00259    }

char Input::IsEndOfFile unsigned    len = 0 [inline]
 

Definition at line 247 of file Input.hpp.

00249    {
00250       return (curptr+len==endptr)&&(iseof);
00251    }

char Input::OpenFile char *    filename [inline]
 

Reimplemented from CFile.

Reimplemented in FileParser.

Definition at line 90 of file Input.hpp.

00092    {
00093       if(CFile::OpenFile(filename)==0)
00094          return 0;
00095 
00096       curptr=endptr=databuf;
00097 
00098       FillBuf();
00099 
00100       curlineno=1;
00101 
00102       return 1;
00103    }

void Input::PeekChar char *    ptr [inline]
 

Definition at line 204 of file Input.hpp.

00209    {
00210       FillBufLen(1);
00211       *ptr=*curptr;
00212    }

void Input::PeekData char *    ptr,
int    len
[inline]
 

Definition at line 197 of file Input.hpp.

00199    {
00200       FillBufLen(len);
00201       mymemcpy(ptr,curptr,len);
00202    }

char Input::ReadData char *    dest,
int    len
[inline]
 

Definition at line 105 of file Input.hpp.

00111    {
00112       int savelen=len;
00113 
00114       while(endptr-curptr<len)
00115       {
00116          if(IsEndOfFile())
00117             return 1;
00118 
00119          len-=endptr-curptr;
00120 
00121          while(curptr<endptr)
00122          {
00123             *dest=*curptr;
00124             if(*curptr=='\n')
00125                curlineno++;
00126             dest++;
00127             curptr++;
00128          }
00129          FillBuf();
00130       }
00131 
00132       while(len>0)
00133       {
00134          *dest=*curptr;
00135          if(*curptr=='\n')
00136             curlineno++;
00137          dest++;
00138          curptr++;
00139          len--;
00140       }
00141       return 0;
00142    }

void Input::ReadFullUInt32 unsigned long *    data [inline]
 

Definition at line 156 of file Input.hpp.

00158    {
00159       FillBufLen(sizeof(unsigned long));
00160 
00161       *data=*(unsigned long *)curptr;
00162       curptr+=4;
00163    }

void Input::ReadUInt32 unsigned long *    data [inline]
 

Definition at line 165 of file Input.hpp.

00171    {
00172       FillBufLen(1);
00173 
00174       if(*(unsigned char *)curptr<128)
00175          *data=(unsigned)(unsigned char)*(curptr++);
00176       else
00177       {
00178          if(*(unsigned char *)curptr<192)
00179          {
00180             FillBufLen(1);
00181             *data=(((unsigned)(unsigned char)*(curptr++)-128)<<8)+(unsigned)(unsigned char)*(curptr++);
00182          }
00183          else
00184          {
00185             FillBufLen(3);
00186 
00187             *data=   (((unsigned)(unsigned char)*(curptr++)-192)<<24)+
00188                      (((unsigned)(unsigned char)*(curptr++))<<16)+
00189                      (((unsigned)(unsigned char)*(curptr++))<<8)+
00190                      (unsigned)(unsigned char)*(curptr++);
00191          }
00192       }
00193    }

void Input::RefillAndGetCurBlockPtr char **    ptr,
int *    len
[inline]
 

Definition at line 261 of file Input.hpp.

00265    {
00266       FillBuf();
00267       *ptr=curptr;
00268       *len=endptr-curptr;
00269    }

void Input::SkipChar   [inline]
 

Reimplemented in FileParser.

Definition at line 238 of file Input.hpp.

00240    {
00241       FillBufLen(1);
00242       if(*curptr=='\n')
00243          curlineno++;
00244       curptr++;
00245    }

void Input::SkipData int    len [inline]
 

Reimplemented in FileParser.

Definition at line 214 of file Input.hpp.

00221    {
00222       while(endptr-curptr<len)
00223       {
00224          len-=endptr-curptr;
00225          curptr=endptr=databuf;
00226 
00227          FillBuf();
00228       }
00229       curptr+=len;
00230    }

void Input::UndoReadChar   [inline]
 

Definition at line 271 of file Input.hpp.

00273    {
00274       curptr--;
00275    }


The documentation for this class was generated from the following file:
Generated on Sat Oct 13 16:08:54 2001 for XMILL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001