Index: code/branches/network/src/util/Bytestream.cc
===================================================================
--- code/branches/network/src/util/Bytestream.cc	(revision 1669)
+++ code/branches/network/src/util/Bytestream.cc	(revision 1669)
@@ -0,0 +1,58 @@
+#include "Bytestream.h"
+#include <assert.h>
+
+#define DEFAULT_SIZE 100 // bytes
+#define RESIZE_AMOUNT 100
+
+  Bytestream::Bytestream(){
+    data_ = new DATA_TYPE[DEFAULT_SIZE+1];
+    readIterator_ = 0;
+    writeIterator_ = 0;
+    maxSize_ = DEFAULT_SIZE;
+  }
+  
+  Bytestream::Bytestream( unsigned int size ){
+    data_ = new DATA_TYPE[ size+1 ];
+    readIterator_ = 0;
+    writeIterator_ = 0;
+    maxSize_ = size;
+  }
+  
+  Bytestream::Bytestream( DATA_TYPE *data, unsigned int size, bool empty ){
+    data_ = data;
+    if(empty)
+      writeIterator_ = 0;
+    else
+      writeIterator_ = size;
+    readIterator_ = 0;
+    maxSize_ = size;
+  }
+  
+  Bytestream::~Bytestream(){
+    delete [] data_;
+  }
+  
+  
+  void Bytestream::write( void *data, unsigned int length ){
+    if(writeIterator_+length > maxSize_){
+      maxSize_ += RESIZE_AMOUNT;
+      data_ = (DATA_TYPE* )realloc(data_, maxSize_);
+    }
+    memcpy( &data_[writeIterator_], &data, length );
+    writeIterator_+= length;
+  }
+  
+  void Bytestream::read( void *data, unsigned int length ){
+    assert(readIterator_+length <= maxSize_);
+    memcpy( &data, &data_[readIterator_], length );
+    readIterator_ += length;
+    assert(readIterator_<=maxSize_);
+  }
+  
+  void Bytestream::readString(std::string& s){
+    void readString(std::string& s);
+    readIterator_ += s.length()+1;
+    assert(readIterator_<=maxSize_);
+  }
+  
+  
Index: code/branches/network/src/util/Bytestream.h
===================================================================
--- code/branches/network/src/util/Bytestream.h	(revision 1669)
+++ code/branches/network/src/util/Bytestream.h	(revision 1669)
@@ -0,0 +1,74 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKBYTESTREAM_H
+#define NETWORKBYTESTREAM_H
+
+#define DATA_TYPE unsigned char
+
+#include <string>
+
+  
+/**
+	@author Oliver Scheuss <scheusso [at] ee.ethz.ch>
+*/
+class Bytestream{
+  public:
+    Bytestream();
+    Bytestream( unsigned int size );
+    Bytestream( DATA_TYPE *data, unsigned int size, bool empty=false );
+    ~Bytestream();
+    
+    template <class T> Bytestream& operator<< ( T& data )
+        { write(&data, sizeof(T)); return *this; }
+    template <class T> Bytestream& operator>> ( T& data )
+        { read(&data, sizeof(T)); return *this; }
+    void write(void *data, unsigned int length);
+    void read(void *data, unsigned int length);
+    void readString(std::string& s);
+    
+    // specialisations
+    template <std::string&> Bytestream& operator<< ( std::string& s ){ write( s.c_str(), s.length()+1); return *this; }
+    template <std::string&> Bytestream& operator>> ( std::string& s ){ readString(s); return *this; }
+    
+    DATA_TYPE *getData(){ return data_; }
+    unsigned int getSize(){ return writeIterator_; }
+    
+  private:
+    
+
+// Membervariables
+  
+  private:
+    DATA_TYPE *data_;
+    unsigned int writeIterator_;
+    unsigned int readIterator_;
+    unsigned int maxSize_;
+};
+
+
+#endif
Index: code/branches/network/src/util/CMakeLists.txt
===================================================================
--- code/branches/network/src/util/CMakeLists.txt	(revision 1589)
+++ code/branches/network/src/util/CMakeLists.txt	(revision 1669)
@@ -1,4 +1,5 @@
 SET(UTIL_SRC_FILES
   ArgReader.cc
+  Bytestream.cc
   Clipboard.cc
   ExprParser.cc
Index: code/branches/network/src/util/UtilPrereqs.h
===================================================================
--- code/branches/network/src/util/UtilPrereqs.h	(revision 1589)
+++ code/branches/network/src/util/UtilPrereqs.h	(revision 1669)
@@ -61,4 +61,5 @@
 //-----------------------------------------------------------------------
 class ArgReader;
+class Bytestream;
 class Convert;
 class MultiTypePrimitive;
@@ -68,4 +69,3 @@
 class String2Number;
 class SubString;
-
 #endif /* _UtilPrereqs_H__ */
