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

panda/src/express/streamWriter.h

Go to the documentation of this file.
00001 // Filename: streamWriter.h
00002 // Created by:  drose (04Aug02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef STREAMWRITER_H
00020 #define STREAMWRITER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "numeric_types.h"
00025 #include "littleEndian.h"
00026 #include "bigEndian.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : StreamWriter
00030 // Description : A StreamWriter object is used to write sequential
00031 //               binary data directly to an ostream.  Its interface is
00032 //               very similar to Datagram by design; it's primarily
00033 //               intended as a convenience to eliminate the overhead
00034 //               of writing bytes to a Datagram and then writing the
00035 //               Datagram to a stream.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDAEXPRESS StreamWriter {
00038 public:
00039   INLINE StreamWriter(ostream &out);
00040 PUBLISHED:
00041   INLINE StreamWriter(ostream *out);
00042   INLINE StreamWriter(const StreamWriter &copy);
00043   INLINE void operator = (const StreamWriter &copy);
00044   INLINE ~StreamWriter();
00045 
00046   INLINE ostream *get_ostream() const;
00047 
00048   INLINE void add_bool(bool value);
00049   INLINE void add_int8(PN_int8 value);
00050   INLINE void add_uint8(PN_uint8 value);
00051 
00052   // The default numeric packing is little-endian.
00053   INLINE void add_int16(PN_int16 value);
00054   INLINE void add_int32(PN_int32 value);
00055   INLINE void add_int64(PN_int64 value);
00056   INLINE void add_uint16(PN_uint16 value);
00057   INLINE void add_uint32(PN_uint32 value);
00058   INLINE void add_uint64(PN_uint64 value);
00059   INLINE void add_float32(float value);
00060   INLINE void add_float64(PN_float64 value);
00061 
00062   // These functions pack numbers big-endian, in case that's desired.
00063   INLINE void add_be_int16(PN_int16 value);
00064   INLINE void add_be_int32(PN_int32 value);
00065   INLINE void add_be_int64(PN_int64 value);
00066   INLINE void add_be_uint16(PN_uint16 value);
00067   INLINE void add_be_uint32(PN_uint32 value);
00068   INLINE void add_be_uint64(PN_uint64 value);
00069   INLINE void add_be_float32(float value);
00070   INLINE void add_be_float64(PN_float64 value);
00071 
00072   INLINE void add_string(const string &str);
00073   INLINE void add_z_string(string str);
00074   INLINE void add_fixed_string(const string &str, size_t size);
00075 
00076   void pad_bytes(size_t size);
00077   INLINE void append_data(const void *data, size_t size);
00078   INLINE void append_data(const string &data);
00079 
00080 private:
00081   ostream *_out;
00082 };
00083 
00084 #include "streamWriter.I"
00085 
00086 #endif

Generated on Fri May 2 00:38:35 2003 for Panda by doxygen1.3