Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Streams/InStreams.h

Go to the documentation of this file.
00001 /**
00002 * @file InStreams.h
00003 *
00004 * Declaration of in stream classes for different media and formats.
00005 *
00006 * @author Thomas Röfer
00007 * @author Martin Lötzsch
00008 */
00009 
00010 #ifndef __InStreams_h_
00011 #define __InStreams_h_
00012 
00013 #include "InOut.h"
00014 #include "Platform/File.h"
00015 #include <stdlib.h>
00016 
00017 /** 
00018 * @class PhysicalInStream
00019 *
00020 * The base class for physical in streams. Derivates of PhysicalInStream only handle the 
00021 * reading of data from a medium, not of formating data.
00022 */
00023 class PhysicalInStream
00024 {
00025 public:
00026   /**
00027   * The function reads a number of bytes from a stream.
00028   * @param p The address the data is written to. Note that p
00029   *          must point to a memory area that is at least
00030   *          "size" bytes large.
00031   * @param size The number of bytes to be read.
00032   */
00033   virtual void readFromStream(void* p,int size) = 0;
00034   
00035   /**
00036   * The function skips a number of bytes in a stream.
00037   * @param size The number of bytes to be read.
00038   */
00039   virtual void skipInStream(int size);
00040   
00041   /**
00042   * The function states whether this stream actually exists.
00043   * This function is relevant if the stream represents a file.
00044   * @return Does the stream exist?
00045   */
00046   virtual bool exists() const {return true;};
00047   
00048   /**
00049   * The function states whether the end of the stream has been reached.
00050   * @return End of stream reached?
00051   */
00052   virtual bool getEof() const = 0;
00053 };
00054 
00055 /**
00056 * @class StreamReader
00057 *
00058 * Generic class for formated reading of data to be used in streams. 
00059 * The physical reading is then done by PhysicalOutStream derivates.
00060 */
00061 class StreamReader
00062 {
00063 protected:
00064 /**
00065 * reads a character from a stream
00066 * @param d the data to read from the stream
00067 * @param stream the stream to read from 
00068   */
00069   virtual void readChar(char& d, PhysicalInStream& stream) = 0;
00070   
00071   /**
00072   * reads a unsigned character from a stream
00073   * @param d the data to read from the stream
00074   * @param stream the stream to read from 
00075   */
00076   virtual void readUChar(unsigned char& d, PhysicalInStream& stream) = 0;
00077   
00078   /**
00079   * reads a short from a stream
00080   * @param d the data to read from the stream
00081   * @param stream the stream to read from 
00082   */
00083   virtual void readShort(short& d, PhysicalInStream& stream) = 0;
00084   
00085   /**
00086   * reads a unsigned short from a stream
00087   * @param d the data to read from the stream
00088   * @param stream the stream to read from 
00089   */
00090   virtual void readUShort(unsigned short& d, PhysicalInStream& stream) = 0;
00091   
00092   /**
00093   * reads a int from a stream
00094   * @param d the data to read from the stream
00095   * @param stream the stream to read from 
00096   */
00097   virtual void readInt(int& d, PhysicalInStream& stream) = 0;
00098   
00099   /**
00100   * reads a unsigned int from a stream
00101   * @param d the data to read from the stream
00102   * @param stream the stream to read from 
00103   */
00104   virtual void readUInt(unsigned int& d, PhysicalInStream& stream) = 0;
00105   
00106   /**
00107   * reads a long from a stream
00108   * @param d the data to read from the stream
00109   * @param stream the stream to read from 
00110   */
00111   virtual void readLong(long& d, PhysicalInStream& stream) = 0;
00112   
00113   /**
00114   * reads a unsigned long from a stream
00115   * @param d the data to read from the stream
00116   * @param stream the stream to read from 
00117   */
00118   virtual void readULong(unsigned long& d, PhysicalInStream& stream) = 0;
00119   
00120   /**
00121   * reads a float from a stream
00122   * @param d the data to read from the stream
00123   * @param stream the stream to read from 
00124   */
00125   virtual void readFloat(float& d, PhysicalInStream& stream) = 0;
00126   
00127   /**
00128   * reads a double from a stream
00129   * @param d the data to read from the stream
00130   * @param stream the stream to read from 
00131   */
00132   virtual void readDouble(double& d, PhysicalInStream& stream) = 0;
00133   
00134   /**
00135   * reads a string from a stream
00136   * @param d the data to read from the stream
00137   * @param stream the stream to read from 
00138   */
00139   virtual void readString(char* d, PhysicalInStream& stream) = 0;
00140   
00141   /**
00142   * reads the 'end of line' from a stream
00143   * @param stream the stream to read from 
00144   */
00145   virtual void readEndl(PhysicalInStream& stream) = 0;
00146   
00147   /**
00148   * The function reads a number of bytes from the file.
00149   * @param p The address the data is written to. Note that p
00150   *          must point to a memory area that is at least
00151   *          "size" bytes large.
00152   * @param size The number of bytes to be read.
00153   * @param stream The stream to read from.
00154   */
00155   virtual void readData(void* p,int size, PhysicalInStream& stream) = 0;
00156 
00157   /**
00158   * The function skips a number of bytes in the file.
00159   * @param size The number of bytes to be skipped.
00160   * @param stream The stream to read from.
00161   */
00162   virtual void skipData(int size, PhysicalInStream& stream);
00163 
00164   /**
00165   * The function states whether the end of the stream has been reached.
00166   * @param stream The stream to be tested 
00167   * @return End of stream reached?
00168   */
00169   virtual bool isEof(const PhysicalInStream& stream) const = 0;
00170 };
00171 
00172 /**
00173 * @class InStream
00174 *
00175 * Generic class for classes that do both formated and physical reading of data from streams.
00176 */
00177 template <class S, class R> class InStream : public S, public R, public In
00178 {
00179 public:
00180   /** Standard constructor */
00181   InStream() {};
00182   
00183   /**
00184   * The function reads a number of bytes from a stream.
00185   * @param p The address the data is written to. Note that p
00186   *          must point to a memory area that is at least
00187   *          "size" bytes large.
00188   * @param size The number of bytes to be read.
00189   */
00190   virtual void read(void* p,int size)
00191   { readData(p, size, *this); }
00192   
00193   /**
00194   * The function skips a number of bytes in the stream.
00195   * @param size The number of bytes to be skipped.
00196   */
00197   virtual void skip(int size)
00198   { skipData(size, *this); }
00199 
00200   /**
00201   * Determines whether the end of file has been reached.
00202   */ 
00203   virtual bool eof() const { return isEof(*this); }
00204   
00205 protected:
00206 /**
00207 * Virtual redirection for operator>>(char& value).
00208   */
00209   virtual void inChar(char& d) 
00210   { readChar(d, *this); }
00211   
00212   /**
00213   * Virtual redirection for operator>>(unsigend char& value).
00214   */
00215   virtual void inUChar(unsigned char& d) 
00216   { readUChar(d, *this); }
00217   
00218   /**
00219   * Virtual redirection for operator>>(short& value).
00220   */
00221   virtual void inShort(short& d) 
00222   { readShort(d, *this); }
00223   
00224   /**
00225   * Virtual redirection for operator>>(unsigend short& value).
00226   */
00227   virtual void inUShort(unsigned short& d) 
00228   { readUShort(d, *this); }
00229   
00230   /**
00231   * Virtual redirection for operator>>(int& value).
00232   */
00233   virtual void inInt(int& d) 
00234   { readInt(d, *this); }
00235   
00236   /**
00237   * Virtual redirection for operator>>(unsigend int& value).
00238   */
00239   virtual void inUInt(unsigned int& d) 
00240   { readUInt(d, *this); }
00241   
00242   /**
00243   * Virtual redirection for operator>>(long& value).
00244   */
00245   virtual void inLong(long& d) 
00246   { readLong(d, *this); }
00247   
00248   /**
00249   * Virtual redirection for operator>>(unsigend long& value).
00250   */
00251   virtual void inULong(unsigned long& d) 
00252   { readULong(d, *this); }
00253   
00254   /**
00255   * Virtual redirection for operator>>(float& value).
00256   */
00257   virtual void inFloat(float& d) 
00258   { readFloat(d, *this); }
00259   
00260   /**
00261   * Virtual redirection for operator>>(double& value).
00262   */
00263   virtual void inDouble(double& d) 
00264   { readDouble(d, *this); }
00265   
00266   /**
00267   * Virtual redirection for operator>>(char* value).
00268   */
00269   virtual void inString(char* d) 
00270   { readString(d, *this); }
00271   
00272   /**
00273   * Virtual redirection for operator>>(In& (*f)(In&)) that reads
00274   * the symbol "endl";
00275   */
00276   virtual void inEndL() 
00277   { readEndl(*this); }
00278 };
00279 
00280 /**
00281 * @class InText
00282 *
00283 * Formated reading of text data to be used in streams. 
00284 * The physical reading is done by PhysicalInStream derivates.
00285 */
00286 class InText : public StreamReader
00287 {
00288 private:
00289   char buf[200]; /**< A buffer to convert read strings. */
00290   bool eof;
00291     
00292 public:
00293   /** Default constructor */
00294   InText() { reset(); };
00295   
00296   /** Resets theChar to be able to use the same instance of InText or InConfig
00297   * more than once. 
00298   */
00299   void reset()
00300    { theChar = ' '; eof = false;}
00301 
00302 
00303 protected:
00304   /** The last character read. */
00305   char theChar;
00306 
00307   /**
00308   * The function returns whether the end of stream has been reached.
00309   * If this function returns false, "theChar" is valid, otherwise it is not.
00310   * @param stream The stream.
00311   * @return End of stream reached?
00312   */
00313   virtual bool isEof(const PhysicalInStream& stream) const {return eof;}
00314   
00315   /**
00316   * reads a character from a stream
00317   * @param d the data to read from the stream
00318   * @param stream the stream to read from 
00319   */
00320   virtual void readChar(char& d, PhysicalInStream& stream)
00321   { readString(buf,stream); d = (char)strtol(buf,(char**)NULL,0); }
00322   
00323   /**
00324   * reads a unsigned character from a stream
00325   * @param d the data to read from the stream
00326   * @param stream the stream to read from 
00327   */
00328   virtual void readUChar(unsigned char& d, PhysicalInStream& stream) 
00329   { readString(buf, stream); d = (unsigned char)strtoul(buf,(char**)NULL,0); }
00330   
00331   /**
00332   * reads a short from a stream
00333   * @param d the data to read from the stream
00334   * @param stream the stream to read from 
00335   */
00336   virtual void readShort(short& d, PhysicalInStream& stream)
00337   { readString(buf, stream); d = (short)strtol(buf,(char**)NULL,0); }
00338   
00339   /**
00340   * reads a unsigned short from a stream
00341   * @param d the data to read from the stream
00342   * @param stream the stream to read from 
00343   */
00344   virtual void readUShort(unsigned short& d, PhysicalInStream& stream) 
00345   {readString(buf, stream); d = (unsigned short)strtoul(buf,(char**)NULL,0);}
00346   
00347   /**
00348   * reads a int from a stream
00349   * @param d the data to read from the stream
00350   * @param stream the stream to read from 
00351   */
00352   virtual void readInt(int& d, PhysicalInStream& stream)
00353   {readString(buf, stream); d = (int)strtol(buf,(char**)NULL,0);}
00354   
00355   
00356   /**
00357   * reads a unsigned int from a stream
00358   * @param d the data to read from the stream
00359   * @param stream the stream to read from 
00360   */
00361   virtual void readUInt(unsigned int& d, PhysicalInStream& stream) 
00362   {readString(buf, stream); d = (unsigned int)strtoul(buf,(char**)NULL,0);}
00363   
00364   /**
00365   * reads a long from a stream
00366   * @param d the data to read from the stream
00367   * @param stream the stream to read from 
00368   */
00369   virtual void readLong(long& d, PhysicalInStream& stream)
00370   {readString(buf, stream); d = (long)strtol(buf,(char**)NULL,0);}
00371   
00372   /**
00373   * reads a unsigned long from a stream
00374   * @param d the data to read from the stream
00375   * @param stream the stream to read from 
00376   */
00377   virtual void readULong(unsigned long& d, PhysicalInStream& stream) 
00378   {readString(buf, stream); d = (unsigned long)strtoul(buf,(char**)NULL,0);}
00379   
00380   /**
00381   * reads a float from a stream
00382   * @param d the data to read from the stream
00383   * @param stream the stream to read from 
00384   */
00385   virtual void readFloat(float& d, PhysicalInStream& stream) 
00386   {readString(buf, stream); d = float(atof(buf));}
00387   
00388   /**
00389   * reads a double from a stream
00390   * @param d the data to read from the stream
00391   * @param stream the stream to read from 
00392   */
00393   virtual void readDouble(double& d, PhysicalInStream& stream)
00394   {readString(buf, stream); d = atof(buf);}
00395   
00396   /**
00397   * The function reads a string from a stream.
00398   * It skips all whitespace characters, and then reads
00399   * a sequence of non-whitespace characters to a buffer, until it 
00400   * again recognizes a whitespace.
00401   * @param d The value that is read. Note that value must point
00402   *              to a memory area that is large enough to carry 
00403   *              the string.
00404   * @param stream the stream to read from
00405   */
00406   virtual void readString(char* d, PhysicalInStream& stream);
00407   
00408   /**
00409   * reads the 'end of line' from a stream
00410   * @param stream the stream to read from 
00411   */
00412   virtual void readEndl(PhysicalInStream& stream) {};
00413   
00414   /**
00415   * The function determines whether the current character is a whitespace.
00416   */
00417   virtual bool isWhitespace();
00418   
00419   /**
00420   * The function skips the whitespace.
00421   */
00422   virtual void skipWhitespace(PhysicalInStream& stream);
00423   
00424   /**
00425   * The function reads the next character from the stream.
00426   */
00427   virtual void nextChar(PhysicalInStream& stream) 
00428   {
00429     if(stream.getEof())
00430     {
00431       eof = true;
00432       theChar = ' ';
00433     }
00434     else
00435       stream.readFromStream(&theChar,1);
00436   }
00437   
00438   /**
00439   * The function reads a number of bytes from the file.
00440   * @param p The address the data is written to. Note that p
00441   *          must point to a memory area that is at least
00442   *          "size" bytes large.
00443   * @param size The number of bytes to be read.
00444   * @param stream The stream to read from.
00445   */
00446   virtual void readData(void* p,int size, PhysicalInStream& stream);
00447 };
00448 
00449 /**
00450 * The class InConfig reads text data from config (file) streams
00451 * that contain comments and sections.
00452 * The following comment styles are supported:
00453 * / * comment * / (ignore the space between "*" and "/")
00454 * // comment till endl
00455 * # comment till endl
00456 * Note that "/" is not allowed elsewhere in the stream.
00457 */
00458 class InConfig : public InText
00459 {
00460 public:
00461 /** 
00462 * Default constructor
00463   */
00464   InConfig() : readSection(false) {};
00465   
00466 protected:
00467 /**
00468 * Creates the reader.
00469 * @param sectionName If given the section is searched
00470 * @param stream The medium that should be read from.
00471   */
00472   void create(const char* sectionName, PhysicalInStream& stream);
00473   
00474   /**
00475   * The function determines whether the current character is a whitespace.
00476   * In this context, the start of 
00477   */
00478   virtual bool isWhitespace();
00479   
00480   /**
00481   * The function skips the whitespace.
00482   */
00483   virtual void skipWhitespace(PhysicalInStream& stream);
00484   
00485   /**
00486   * The function reads the next character from the stream.
00487   */
00488   virtual void nextChar(PhysicalInStream& stream);
00489 
00490 private:
00491   /** Are we reading a section? */
00492   bool readSection; 
00493   
00494   /**
00495   * The functions skip all characters to the end of the line.
00496   */
00497   void skipLine(PhysicalInStream& stream);
00498   
00499   /**
00500   * The functions skip all characters to the end of the comment.
00501   */
00502   void skipComment(PhysicalInStream& stream);
00503 };
00504 
00505 /**
00506 * @class InBinary
00507 *
00508 * Formated reading of binary data to be used in streams. 
00509 * The physical reading is done by PhysicalInStream derivates.
00510 */
00511 class InBinary : public StreamReader
00512 {
00513 protected:
00514   /**
00515   * The function returns whether the end of stream has been reached.
00516   * @return End of stream reached?
00517   */
00518   virtual bool isEof(const PhysicalInStream& stream) const {return stream.getEof();}
00519 
00520   /**
00521   * The function reads a char from the stream.
00522   * @param d The value that is read.
00523   * @param stream A Stream to read from.
00524   */
00525   virtual void readChar(char& d, PhysicalInStream& stream)
00526   {stream.readFromStream(&d,sizeof(d));}
00527   
00528   /**
00529   * The function reads an unsigned char from the stream.
00530   * @param d The value that is read.
00531   * @param stream A Stream to read from.
00532   */
00533   virtual void readUChar(unsigned char& d, PhysicalInStream& stream)
00534   {stream.readFromStream(&d,sizeof(d));}
00535   
00536   /**
00537   * The function reads a short int from the stream.
00538   * @param d The value that is read.
00539   * @param stream A Stream to read from.
00540   */
00541   virtual void readShort(short& d, PhysicalInStream& stream) 
00542   {stream.readFromStream(&d,sizeof(d));}
00543   
00544   /**
00545   * The function reads an unsigned short int from the stream.
00546   * @param d The value that is read.
00547   * @param stream A Stream to read from.
00548   */
00549   virtual void readUShort(unsigned short& d, PhysicalInStream& stream) 
00550   {stream.readFromStream(&d,sizeof(d));}
00551   
00552   /**
00553   * The function reads an int from the stream.
00554   * @param d The value that is read.
00555   * @param stream A Stream to read from.
00556   */
00557   virtual void readInt(int& d, PhysicalInStream& stream) 
00558   {stream.readFromStream(&d,sizeof(d));}
00559   
00560   /**
00561   * The function reads an unsigned int from the stream.
00562   * @param d The value that is read.
00563   * @param stream A Stream to read from.
00564   */
00565   virtual void readUInt(unsigned int& d, PhysicalInStream& stream) 
00566   {stream.readFromStream(&d,sizeof(d));}
00567   
00568   /**
00569   * The function reads a long int from the stream.
00570   * @param d The value that is read.
00571   * @param stream A Stream to read from.
00572   */
00573   virtual void readLong(long& d, PhysicalInStream& stream) 
00574   {stream.readFromStream(&d,sizeof(d));}
00575   
00576   /**
00577   * The function reads an unsigned long int from the stream.
00578   * @param d The value that is read.
00579   * @param stream A Stream to read from.
00580   */
00581   virtual void readULong(unsigned long& d, PhysicalInStream& stream) 
00582   {stream.readFromStream(&d,sizeof(d));}
00583   
00584   /**
00585   * The function reads a float from the stream.
00586   * @param d The value that is read.
00587   * @param stream A Stream to read from.
00588   */
00589   virtual void readFloat(float& d, PhysicalInStream& stream) 
00590   {stream.readFromStream(&d,sizeof(d));}
00591   
00592   /**
00593   * The function reads a double from the stream.
00594   * @param d The value that is read.
00595   * @param stream A Stream to read from.
00596   */
00597   virtual void readDouble(double& d, PhysicalInStream& stream) 
00598   {stream.readFromStream(&d,sizeof(d));}
00599   
00600   /**
00601   * The function reads a string from the stream.
00602   * @param d The value that is read. Note that d must point
00603   *              to a memory area that is large enough to carry 
00604   *              the string.
00605   * @param stream A Stream to read from.
00606   */
00607   virtual void readString(char* d, PhysicalInStream& stream) 
00608   {int size; stream.readFromStream(&size,sizeof(size)); stream.readFromStream(d,size); d[size] = 0;}
00609   
00610   /**
00611   * The function is intended to read an endl-symbol from the stream.
00612   * In fact, the function does nothing.
00613   * @param stream A Stream to read from.
00614   */
00615   virtual void readEndl(PhysicalInStream& stream) {};
00616   
00617   /**
00618   * The function reads a number of bytes from a stream.
00619   * @param p The address the data is written to. Note that p
00620   *          must point to a memory area that is at least
00621   *          "size" bytes large.
00622   * @param size The number of bytes to be read.
00623   * @param stream A Stream to read from.
00624   */
00625   virtual void readData(void* p,int size, PhysicalInStream& stream)
00626   { stream.readFromStream(p, size); }
00627 
00628   /**
00629   * The function skips a number of bytes in the file.
00630   * @param size The number of bytes to be skipped.
00631   * @param stream The stream to read from.
00632   */
00633   virtual void skipData(int size, PhysicalInStream& stream)
00634   { stream.skipInStream(size); }
00635 };
00636 
00637 /**
00638 * @class InFile.
00639 *
00640 * An PhysicalInStream that reads the data from a file.
00641 */
00642 class InFile : public PhysicalInStream
00643 {
00644 private:
00645   File* stream; /**< Object representing the file. */
00646   
00647 public:
00648   /** Default constructor */
00649   InFile() : stream(0) {};
00650   
00651   /** Destructor */
00652   ~InFile() { if (stream != 0) delete stream; }
00653   
00654   /**
00655   * The function states whether the file actually exists.
00656   * @return Does the file exist?
00657   */
00658   virtual bool exists() const 
00659   { return  (stream != 0 ? stream->exists() : false); }
00660   
00661   /**
00662   * The function states whether the end of the file has been reached.
00663   * @return End of file reached?
00664   */
00665   virtual bool getEof() const 
00666   { return (stream != 0 ? stream->eof() : false); }
00667   
00668 protected:
00669 /**
00670 * opens the file.
00671 * @param name The name of the file to open. It will be interpreted
00672 *             as relative to the configuration directory.
00673   */
00674   void open(const char* name) 
00675   { if (stream == 0) stream = new File(name,"rb"); }
00676   
00677   /**
00678   * The function reads a number of bytes from the file.
00679   * @param p The address the data is written to. Note that p
00680   *          must point to a memory area that is at least
00681   *          "size" bytes large.
00682   * @param size The number of bytes to be read.
00683   */
00684   virtual void readFromStream(void* p,int size) 
00685   { if (stream != 0) stream->read(p,size); }
00686 };
00687 
00688 /**
00689 * @class InMemory.
00690 *
00691 * An PhysicalInStream that reads the data from a memory region.
00692 */
00693 class InMemory : public PhysicalInStream
00694 {
00695 private:
00696   const char* memory, /**< Points to the next byte to read from memory. */
00697     * end; /**< Points to the end of the memory block. */
00698   
00699 public:
00700   /** Default constructor */
00701   InMemory() : memory(0), end(0) {};
00702   
00703   /**
00704   * The function states whether the stream actually exists.
00705   * @return Does the stream exist? This is always true for memory streams.
00706   */
00707   virtual bool exists() const {return (memory != 0); }
00708   
00709   /**
00710   * The function states whether the end of the file has been reached.
00711   * It will only work if the correct size of the memory block was 
00712   * specified during the construction of the stream.
00713   * @return End of file reached?
00714   */
00715   virtual bool getEof() const 
00716   {return (memory != 0 ? memory >= end: false); }
00717   
00718 protected:
00719 /**
00720 * Opens the stream.
00721 * @param mem The address of the memory block from which is read.
00722 * @param size The size of the memory block. It is only used to 
00723 *             implement the function eof(). If the size is not
00724 *             specified, eof() will always return true, but reading
00725 *             from the stream is still possible.
00726   */
00727   void open(const void* mem,unsigned size = 0) 
00728   { if (memory == 0) { memory = (const char*) mem; end = (const char*) mem + size; }}
00729   
00730   /**
00731   * The function reads a number of bytes from memory.
00732   * @param p The address the data is written to. Note that p
00733   *          must point to a memory area that is at least
00734   *          "size" bytes large.
00735   * @param size The number of bytes to be read.
00736   */
00737   virtual void readFromStream(void* p,int size);
00738   
00739   /**
00740   * The function skips a number of bytes.
00741   * @param size The number of bytes to be skipped.
00742   */
00743   virtual void skipInStream(int size) {memory += size;}
00744 };
00745 
00746 /**
00747 * @class InBinaryFile
00748 *
00749 * A binary stream from a file.
00750 */
00751 class InBinaryFile : public InStream<InFile,InBinary>
00752 {
00753 public:
00754 /**
00755 * Constructor.
00756 * @param name The name of the file to open. It will be interpreted
00757 *             as relative to the configuration directory.
00758   */
00759   InBinaryFile(const char* name) { open(name); }
00760 };
00761 
00762 /**
00763 * @class InBinaryMemory
00764 *
00765 * A Binary Stream from a memory region.
00766 */
00767 class InBinaryMemory : public InStream<InMemory,InBinary>
00768 {
00769 public:
00770 /**
00771 * Constructor.
00772 * @param mem The address of the memory block from which is read.
00773 * @param size The size of the memory block. It is only used to 
00774 *             implement the function eof(). If the size is not
00775 *             specified, eof() will always return true, but reading
00776 *             from the stream is still possible.
00777   */
00778   InBinaryMemory(const void* mem, unsigned size = 0) { open(mem, size); }
00779 };
00780 
00781 /**
00782 * @class InTextFile
00783 *
00784 * A binary stream from a file.
00785 */
00786 class InTextFile : public InStream<InFile,InText>
00787 {
00788 public:
00789 /**
00790 * Constructor.
00791 * @param name The name of the file to open. It will be interpreted
00792 *             as relative to the configuration directory.
00793   */
00794   InTextFile(const char* name) { open(name); }
00795 };
00796 
00797 /**
00798 * @class InTextMemory
00799 *
00800 * A Binary Stream from a memory region.
00801 */
00802 class InTextMemory : public InStream<InMemory,InText>
00803 {
00804 public:
00805 /**
00806 * Constructor.
00807 * @param mem The address of the memory block from which is read.
00808 * @param size The size of the memory block. It is only used to 
00809 *             implement the function eof(). If the size is not
00810 *             specified, eof() will always return true, but reading
00811 *             from the stream is still possible.
00812   */
00813   InTextMemory(const void* mem, unsigned size = 0) { open(mem, size); }
00814 };
00815 
00816 /**
00817 * @class InConfigFile
00818 *
00819 * A config-file-style-formated text stream from a file.
00820 */
00821 class InConfigFile : public InStream<InFile,InConfig>
00822 {
00823 public:
00824 /**
00825 * Constructor.
00826 * @param name The name of the file to open. It will be interpreted
00827 *             as relative to the configuration directory. Note that
00828 *             the file is treated as binary file, in order
00829 *             to gain the same results on all supported platforms.
00830 * @param sectionName If given the section is searched
00831   */
00832   InConfigFile(const char* name, const char* sectionName = 0)
00833   { open(name); create(sectionName,*this); }
00834 };
00835 
00836 /**
00837 * @class InConfigMemory
00838 *
00839 * A config-file-style-formated text stream from a memory region.
00840 */
00841 class InConfigMemory : public InStream<InMemory,InConfig>
00842 {
00843 public:
00844 /**
00845 * Constructor.
00846 * @param mem The address of the memory block from which is read.
00847 * @param size The size of the memory block. It is only used to 
00848 *             implement the function eof(). If the size is not
00849 *             specified, eof() will always return true, but reading
00850 *             from the stream is still possible.
00851 * @param sectionName If given the section is searched
00852   */
00853   InConfigMemory(const void* mem, unsigned size = 0, const char* sectionName = 0)
00854   { open(mem, size); create(sectionName,*this); }
00855 };
00856 
00857 #endif //__InStreams_h_
00858 
00859 /*
00860 * Change Log:
00861 *
00862 * $Log: InStreams.h,v $
00863 * Revision 1.1.1.1  2004/05/22 17:37:38  cvsadm
00864 * created new repository GT2004_WM
00865 *
00866 * Revision 1.2  2003/12/30 20:12:04  roefer
00867 * Image size is now 208 x 160. Smaller images are placed in the upper left corner
00868 *
00869 * Revision 1.1  2003/10/07 10:13:24  cvsadm
00870 * Created GT2004 (M.J.)
00871 *
00872 * Revision 1.1.1.1  2003/07/02 09:40:29  cvsadm
00873 * created new repository for the competitions in Padova from the 
00874 * tamara CVS (Tuesday 2:00 pm)
00875 *
00876 * removed unused solutions
00877 *
00878 * Revision 1.6  2003/01/26 19:35:16  loetzsch
00879 * InText and InConfig now have a reset() member that sets the
00880 * 'theChar' variable to ' '. This allows to use an instance of InText
00881 * more than once.
00882 *
00883 * Revision 1.5  2002/11/19 17:12:04  risler
00884 * replaced atoi with strtol to enable hexadecimal input (0x...)
00885 *
00886 * Revision 1.4  2002/10/14 13:14:24  dueffert
00887 * doxygen comments corrected
00888 *
00889 * Revision 1.3  2002/10/11 21:21:16  roefer
00890 * eof() handling in text input corrected
00891 *
00892 * Revision 1.2  2002/09/24 18:41:58  risler
00893 * human readable solutionrequest streaming operator
00894 * default module solutions read from modules.cfg
00895 *
00896 * Revision 1.1  2002/09/10 15:53:59  cvsadm
00897 * Created new project GT2003 (M.L.)
00898 * - Cleaned up the /Src/DataTypes directory
00899 * - Removed challenge related source code
00900 * - Removed processing of incoming audio data
00901 * - Renamed AcousticMessage to SoundRequest
00902 *
00903 * Revision 1.3  2002/08/29 13:48:21  dueffert
00904 * includes in correct case, system includes in <>
00905 *
00906 * Revision 1.2  2002/08/04 17:53:18  roefer
00907 * SimGT2002 connection to physical robots added
00908 *
00909 * Revision 1.1  2002/07/23 13:46:43  loetzsch
00910 * - new streaming classes
00911 *
00912 */

Generated on Thu Sep 23 19:57:41 2004 for GT2004 by doxygen 1.3.6