Public Member Functions | Static Public Attributes | Friends

BinaryValue Class Reference

#include <BinaryValue.h>

List of all members.

Public Member Functions

 BinaryValue (const char *s="")
 BinaryValue (const std::string &str)
 BinaryValue (const std::vector< char > &v)
 BinaryValue (size_t n)
 BinaryValue (const char *b, const char *e)
bool operator< (const BinaryValue &rhs)
BinaryValueoperator+= (const BinaryValue &rhs)
virtual ~BinaryValue ()
virtual void netPack (cCommBuffer *b)
virtual void netUnpack (cCommBuffer *b)
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 ( const char *  s = ""  ) 

Definition at line 33 of file BinaryValue.cc.

Referenced by BinaryValue().

                                     : vector<char>(strlen(s))
{
    copy(s, s+strlen(s), begin());  // Inherits vector<char>::begin()
}

BinaryValue::BinaryValue ( const std::string &  str  ) 

Definition at line 42 of file BinaryValue.cc.

{
    *this = BinaryValue(str.c_str());
}

BinaryValue::BinaryValue ( const std::vector< char > &  v  ) 

Definition at line 47 of file BinaryValue.cc.

                                                 : vector<char>(v)
{
};

BinaryValue::BinaryValue ( size_t  n  ) 

Definition at line 38 of file BinaryValue.cc.

                                : vector<char>(n)
{
}

BinaryValue::BinaryValue ( const char *  b,
const char *  e 
)

Definition at line 51 of file BinaryValue.cc.

                                                     : vector<char>(b, e)
{
};

virtual BinaryValue::~BinaryValue (  )  [inline, virtual]

Definition at line 41 of file BinaryValue.h.

{};


Member Function Documentation

bool BinaryValue::isUnspecified (  )  const

Definition at line 61 of file BinaryValue.cc.

Referenced by CBRDHT::handleGetRequest().

{
    return empty();
}

void BinaryValue::netPack ( cCommBuffer *  b  )  [virtual]

Definition at line 86 of file BinaryValue.cc.

Referenced by doPacking().

{
    doPacking(b,(uint16_t)size());
    doPacking(b, (const char*)(&(*begin())), size());
}

void BinaryValue::netUnpack ( cCommBuffer *  b  )  [virtual]

Definition at line 92 of file BinaryValue.cc.

Referenced by doUnpacking().

{
    uint16_t size;
    doUnpacking(b, size);
    resize(size);
    doUnpacking(b, (char*)(&(*begin())), size);
}

BinaryValue & BinaryValue::operator+= ( const BinaryValue rhs  ) 

Definition at line 55 of file BinaryValue.cc.

{
    insert(end(), rhs.begin(), rhs.end());
    return *this;
}

bool BinaryValue::operator< ( const BinaryValue rhs  ) 

Definition at line 72 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;
}


Friends And Related Function Documentation

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

Definition at line 67 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: