OverSim
BinaryValue Class Reference

#include <BinaryValue.h>

Inheritance diagram for BinaryValue:
vector

Public Member Functions

 BinaryValue ()
 BinaryValue (size_t n)
 BinaryValue (const std::string &str)
 BinaryValue (const std::vector< char > &v)
 BinaryValue (const char *b, const size_t l)
 BinaryValue (const char *cStr)
 BinaryValue (cObject *obj)
virtual ~BinaryValue ()
bool operator< (const BinaryValue &rhs)
BinaryValueoperator+= (const BinaryValue &rhs)
virtual void netPack (cCommBuffer *b)
virtual void netUnpack (cCommBuffer *b)
void packObject (cObject *obj)
cObject * unpackObject ()
bool isUnspecified () const

Static Public Attributes

static const BinaryValue UNSPECIFIED_VALUE

Friends

std::ostream & operator<< (std::ostream &os, const BinaryValue &v)

Detailed Description

Definition at line 29 of file BinaryValue.h.

Constructor & Destructor Documentation

BinaryValue::BinaryValue ( )

Definition at line 34 of file BinaryValue.cc.

Referenced by BinaryValue().

{
};
BinaryValue::BinaryValue ( size_t  n)

Definition at line 38 of file BinaryValue.cc.

{
};
BinaryValue::BinaryValue ( const std::string &  str)

Definition at line 42 of file BinaryValue.cc.

: vector<char>(str.begin(), str.end())
{
};
BinaryValue::BinaryValue ( const std::vector< char > &  v)

Definition at line 46 of file BinaryValue.cc.

{
};
BinaryValue::BinaryValue ( const char *  b,
const size_t  l 
)

Definition at line 55 of file BinaryValue.cc.

: vector<char>(b, b+l)
{
};
BinaryValue::BinaryValue ( const char *  cStr)

Definition at line 50 of file BinaryValue.cc.

{
*this = BinaryValue(cStr, strlen(cStr));
};
BinaryValue::BinaryValue ( cObject *  obj)

Definition at line 59 of file BinaryValue.cc.

{
packObject(obj);
};
virtual BinaryValue::~BinaryValue ( )
inlinevirtual

Definition at line 40 of file BinaryValue.h.

{};

Member Function Documentation

bool BinaryValue::isUnspecified ( ) const

Definition at line 70 of file BinaryValue.cc.

Referenced by CBRDHT::handleGetRequest().

{
return empty();
}
void BinaryValue::netPack ( cCommBuffer *  b)
virtual

Definition at line 95 of file BinaryValue.cc.

Referenced by doPacking().

{
doPacking(b,(uint16_t)size());
doPacking(b, data(), size());
}
void BinaryValue::netUnpack ( cCommBuffer *  b)
virtual

Definition at line 101 of file BinaryValue.cc.

Referenced by doUnpacking().

{
uint16_t size;
doUnpacking(b, size);
resize(size);
doUnpacking(b, data(), size);
}
BinaryValue & BinaryValue::operator+= ( const BinaryValue rhs)

Definition at line 64 of file BinaryValue.cc.

{
insert(end(), rhs.begin(), rhs.end());
return *this;
}
bool BinaryValue::operator< ( const BinaryValue rhs)

Definition at line 81 of file BinaryValue.cc.

{
size_type minSize = min(this->size(), rhs.size());
for (size_type i=0; i<minSize; i++) {
if ((*this)[i] < rhs[i]) {
return true;
} else if ((*this)[i] > rhs[i]) {
return false;
}
}
return (this->size() < rhs.size()) ? true : false;
}
void BinaryValue::packObject ( cObject *  obj)

Definition at line 109 of file BinaryValue.cc.

Referenced by BinaryValue().

{
b->reset();
b->packObject(obj);
resize(b->getMessageSize());
memcpy(data(), b->getBuffer(), b->getMessageSize());
delete b;
}
cObject * BinaryValue::unpackObject ( )

Definition at line 119 of file BinaryValue.cc.

{
cObject* obj;
b->reset();
b->allocateAtLeast(size());
memcpy(b->getBuffer(), data(), size());
b->setMessageSize(size());
obj = b->unpackObject();
delete b;
return obj;
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const BinaryValue v 
)
friend

Definition at line 76 of file BinaryValue.cc.

{
copy(v.begin(), v.end(), ostream_iterator<char>(os, ""));
return os; // To allow (cout << a) << b;
}

Member Data Documentation


The documentation for this class was generated from the following files: