• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ibrdtn/ibrdtn/data/BundleString.cpp

Go to the documentation of this file.
00001 /*
00002  * BundleString.cpp
00003  *
00004  *  Created on: 11.09.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #include "ibrdtn/config.h"
00009 #include "ibrdtn/data/BundleString.h"
00010 #include "ibrdtn/data/SDNV.h"
00011 
00012 namespace dtn
00013 {
00014         namespace data
00015         {
00016                 BundleString::BundleString(std::string value)
00017                  : std::string(value)
00018                 {
00019                 }
00020 
00021                 BundleString::BundleString()
00022                 {
00023                 }
00024 
00025                 BundleString::~BundleString()
00026                 {
00027                 }
00028 
00029                 size_t BundleString::getLength() const
00030                 {
00031                         dtn::data::SDNV sdnv(length());
00032                         return sdnv.getLength() + length();
00033                 }
00034 
00035                 std::ostream &operator<<(std::ostream &stream, const BundleString &bstring)
00036                 {
00037                         std::string data = (std::string)bstring;
00038                         dtn::data::SDNV sdnv(data.length());
00039                         stream << sdnv << data;
00040                         return stream;
00041                 }
00042 
00043                 std::istream &operator>>(std::istream &stream, BundleString &bstring)
00044                 {
00045                         dtn::data::SDNV length;
00046                         stream >> length;
00047                         size_t data_len = length.getValue();
00048 
00049                         char data[data_len];
00050                         stream.read(data, data_len);
00051                         bstring.assign(data, data_len);
00052 
00053                         return stream;
00054                 }
00055         }
00056 }

Generated on Wed Mar 30 2011 11:11:49 for IBR-DTNSuite by  doxygen 1.7.1