#ifndef __JNET__JCONTROLHOSTPREFIX__ #define __JNET__JCONTROLHOSTPREFIX__ #include #include #include #include #include "JLang/JException.hh" #include "JNet/JTag.hh" /** * \author mdejong */ namespace JNET {} namespace JPP { using namespace JNET; } namespace JNET { /** * ControlHost prefix. * * The ControlHost prefix is a light-weight data structure which * consists of a tag and a length. * The length is converted to network byte order and vice versa, * using methods setSize() and getSize(), respectively. */ class JPrefix : public JTag { public: /** * Default constructor. */ JPrefix() : JTag(), size(0) {} /** * Constructor. * * \param tag tag * \param length number of bytes */ JPrefix(const JTag& tag, const long long int length) { setTag (tag); setSize(length); } /** * Get size. * * \return number of bytes */ int getSize() const { return ntohl(size); } /** * Set size. * * \param length number of bytes */ void setSize(const long long int length) { size = htonl(length); } /** * Set prefix. * * \param tag tag * \param length number of bytes */ void set(const JTag& tag, const long long int length) { setTag (tag); setSize(length); } protected: long long int size; }; } #endif