Developer Documentation
RAVL, Recognition And Vision Library
USER HOME PAGE CLASS LIST CONTENTS
Ravl - Core - IO - Streams


Streams

You can use the RAVL streams IStreamC, OStreamC, together with the standard C++ syntax of the I/O operators << and >>, in conjunction with most of the RAVL classes. These will read and write in ASCII format, just as the standard C++ streams do for simple types. E.g. to load an image of reals from standard input:

ImageC<RealT> x;
cin >> x;
This mechanism has been implemented for most of the RAVL classes. If you find a class without it, please bug report.
N.B. For floating-point data types, there is generally a loss of accuracy if data is written to a file in ASCII format and subsequently read back in to a program.

You can use the same mechanism for reading from and writing to RAVL strings, using the IStrStreamC and OStrStreamC classes. This is especially useful for initialising small arrays, e.g.:

  SArray1dC coeffs(5);
  StrIStreamC ("5 0.363 0.291 0.135 0.012 -0.030") >> coeffs;

For some classes there are also stream operators for the BinIStreamC and BinOStreamC classes. These read and write binary files. These streams have advantages over IStreamC and OStreamC: they are faster; they are often more compact, and they store floating point data without loss of precision. If you need this operator for the class you are using, and it is not there, again it is worth asking.

  • Both of the above input stream operators always expect to read data in the format that is written by the corresponding output streams, particularly in the case of the more complex objects.
  • Since the stream operators are not members of the classes being read/written, they are not found in the class documentation itself. They can however be found either in the namespace page, or in page listing related classes.

Normal classes:

 BinOStreamC Machine independant binary output stream.
 BinIStreamC Machine independant binary input stream.
 OStreamC Standard output streams with reference counting.
 IStreamC Standard input streams with reference counting.
 StrOStreamC Output stream to memory.
 StrIStreamC Input stream from memory.
 BitIStreamC Input bit stream
 BitOStreamC Output bit stream.
 BufOStreamC Output stream to memory.
 BufIStreamC Input stream from memory.

Normal functions:

 operator >>(istream &,bool &) Fix for Visual C++'s lack of a bool stream operator.
 operator <<(ostream &,bool) Fix for Visual C++'s lack of a bool stream operator.
 EnableURLMapper(void) Enable url mapping of filenames.
 DisableURLMapper(void) Dissable url mapping of filenames.
 IsURLMappingEnabled(void) Test if URL mapping enabled.
 operator >>(BinIStreamC &,IndexC &)
 operator <<(BinOStreamC &,const IndexC &)
 operator <<(BinOStreamC &,const TFVectorC &)
 operator >>(BinIStreamC &,TFVectorC &)

Advanced functions:

 bswap_16(const short &) Swap bytes of a 16 bit number.
 bswap_32(const int &) Swap bytes of a 32 bit number.

Develop classes:

 StreamBaseC Reference counter IO stream base class.
 StreamTypeC Type of stream.
 BitStreamBaseC Bit stream base.
Documentation by CxxDoc: Tue Aug 13 10:00:48 2002