\section{TPProto::Buffer Class Reference}
\label{classTPProto_1_1Buffer}\index{TPProto::Buffer@{TPProto::Buffer}}
\doxyref{Buffer}{p.}{classTPProto_1_1Buffer} for packing and unpacking Frames.  


{\tt \#include $<$buffer.h$>$}

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Buffer} ()\label{classTPProto_1_1Buffer_d2f664b363172f04c9abcf828d103f3f}

\begin{CompactList}\small\item\em Default constructor. \item\end{CompactList}\item 
{\bf $\sim$Buffer} ()\label{classTPProto_1_1Buffer_219a1df1bb8613555607b848497837e1}

\begin{CompactList}\small\item\em Default destructor. \item\end{CompactList}\item 
void {\bf pack\-Int} (uint32\_\-t val)
\begin{CompactList}\small\item\em Packs a 32 bit int into the buffer. \item\end{CompactList}\item 
void {\bf pack\-Int64} (uint64\_\-t val)
\begin{CompactList}\small\item\em Packs a 64 bit int into the buffer. \item\end{CompactList}\item 
void {\bf pack\-String} (const std::string \&val)
\begin{CompactList}\small\item\em Packs a string into the buffer. \item\end{CompactList}\item 
uint32\_\-t {\bf unpack\-Int} ()
\begin{CompactList}\small\item\em Unpacks a 32 bit int from the buffer. \item\end{CompactList}\item 
uint64\_\-t {\bf unpack\-Int64} ()
\begin{CompactList}\small\item\em Unpacks a 64 bit int from the buffer. \item\end{CompactList}\item 
std::string {\bf unpack\-String} ()
\begin{CompactList}\small\item\em Unpacks a string from the buffer. \item\end{CompactList}\item 
uint32\_\-t {\bf peek\-Int} (uint32\_\-t offset)
\begin{CompactList}\small\item\em Peeks at the value of the 32 bit int at an offset into the buffer. \item\end{CompactList}\item 
void {\bf create\-Header} (uint32\_\-t ver, uint32\_\-t seqnum, uint32\_\-t type, uint32\_\-t len, uint32\_\-t fver=0)
\begin{CompactList}\small\item\em Creates a header for the given parameters. \item\end{CompactList}\item 
bool {\bf read\-Header} (uint32\_\-t \&ver, uint32\_\-t \&seqnum, uint32\_\-t \&type, uint32\_\-t \&len, uint32\_\-t \&fver)
\begin{CompactList}\small\item\em Reads a header, passing back the parameters. \item\end{CompactList}\item 
void {\bf set\-Data} (char $\ast$buff, uint32\_\-t len)
\begin{CompactList}\small\item\em Sets the buffer with the given data. \item\end{CompactList}\item 
char $\ast$ {\bf get\-Data} ()
\begin{CompactList}\small\item\em Gets the data in the buffer. \item\end{CompactList}\item 
uint32\_\-t {\bf get\-Length} ()
\begin{CompactList}\small\item\em Gets the current length of the data in the buffer. \item\end{CompactList}\item 
void {\bf set\-String\-Padding} (bool nsp)
\begin{CompactList}\small\item\em Sets if String Padding is turned on. \item\end{CompactList}\item 
bool {\bf get\-String\-Padding} () const
\begin{CompactList}\small\item\em Checks if String Padding is turned on. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
\doxyref{Buffer}{p.}{classTPProto_1_1Buffer} for packing and unpacking Frames. 

Supports unpacking and packing various base types and creating and reading the frame header. 



\subsection{Member Function Documentation}
\index{TPProto::Buffer@{TPProto::Buffer}!packInt@{packInt}}
\index{packInt@{packInt}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::pack\-Int (uint32\_\-t {\em val})}\label{classTPProto_1_1Buffer_bfe4d7e728707ad97a2445f565786922}


Packs a 32 bit int into the buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The value to be packed. \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!packInt64@{packInt64}}
\index{packInt64@{packInt64}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::pack\-Int64 (uint64\_\-t {\em val})}\label{classTPProto_1_1Buffer_63a318601b1c5a55b9a7f25dfbee6930}


Packs a 64 bit int into the buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The value to be packed. \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!packString@{packString}}
\index{packString@{packString}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::pack\-String (const std::string \& {\em val})}\label{classTPProto_1_1Buffer_0ff9e547a9336067b801f6cd91d461e7}


Packs a string into the buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The string to be packed. \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!unpackInt@{unpackInt}}
\index{unpackInt@{unpackInt}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TPProto::Buffer::unpack\-Int ()}\label{classTPProto_1_1Buffer_279512926ed408db0fe2e2d189d05a43}


Unpacks a 32 bit int from the buffer. 

\begin{Desc}
\item[Returns:]The value unpacked. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!unpackInt64@{unpackInt64}}
\index{unpackInt64@{unpackInt64}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}uint64\_\-t TPProto::Buffer::unpack\-Int64 ()}\label{classTPProto_1_1Buffer_142ad17a1deb99ca297df418af8a1e27}


Unpacks a 64 bit int from the buffer. 

\begin{Desc}
\item[Returns:]The value unpacked. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!unpackString@{unpackString}}
\index{unpackString@{unpackString}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}std::string TPProto::Buffer::unpack\-String ()}\label{classTPProto_1_1Buffer_ed8d42b12afab11f4f73e7b38ac207f8}


Unpacks a string from the buffer. 

\begin{Desc}
\item[Returns:]The string unpacked. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!peekInt@{peekInt}}
\index{peekInt@{peekInt}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TPProto::Buffer::peek\-Int (uint32\_\-t {\em offset})}\label{classTPProto_1_1Buffer_a5d2030c6ec434aa8eaa6fb49152bb35}


Peeks at the value of the 32 bit int at an offset into the buffer. 

This operation does not change the r/w position. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em offset}]The offset into the buffer. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The 32 bit int value at the offset. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!createHeader@{createHeader}}
\index{createHeader@{createHeader}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::create\-Header (uint32\_\-t {\em ver}, uint32\_\-t {\em seqnum}, uint32\_\-t {\em type}, uint32\_\-t {\em len}, uint32\_\-t {\em fver} = {\tt 0})}\label{classTPProto_1_1Buffer_aaa170f94230a60a598194a0ae9d51ca}


Creates a header for the given parameters. 

The buffer is set to the header. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ver}]The version of the protocol. \item[{\em seqnum}]The sequence number. \item[{\em type}]The type number. \item[{\em len}]The length of the data of the frame in bytes. \item[{\em fver}]The frame type version, defaults to 0 \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!readHeader@{readHeader}}
\index{readHeader@{readHeader}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool TPProto::Buffer::read\-Header (uint32\_\-t \& {\em ver}, uint32\_\-t \& {\em seqnum}, uint32\_\-t \& {\em type}, uint32\_\-t \& {\em len}, uint32\_\-t \& {\em fver})}\label{classTPProto_1_1Buffer_447b990aca6598c0ad6f870017f0c29f}


Reads a header, passing back the parameters. 

Some checks are performed to check that the buffer is a valid header. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ver}]A reference to where the version number of the protocol will be stored. \item[{\em seqnum}]A reference to where the sequence number will be stored. \item[{\em type}]A reference to where the type number will be stored. \item[{\em len}]A reference to where the length of the data of the frame in bytes should be stored. \item[{\em fver}]A reference to where the frame type version will be stored. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]True if the header is valid. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!setData@{setData}}
\index{setData@{setData}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::set\-Data (char $\ast$ {\em buff}, uint32\_\-t {\em len})}\label{classTPProto_1_1Buffer_bbddc85642a51872814c598a82399b79}


Sets the buffer with the given data. 

Should not be called in general, used by \doxyref{Frame\-Codec}{p.}{classTPProto_1_1FrameCodec} to set the data received from the network. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buff}]The char array of data to be copied as the buffer. \item[{\em len}]The length of the array of data for the buffer. \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!getData@{getData}}
\index{getData@{getData}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}char $\ast$ TPProto::Buffer::get\-Data ()}\label{classTPProto_1_1Buffer_b757b5b032202f8fcd234323faf1f76b}


Gets the data in the buffer. 

Should not be called in general, used by \doxyref{Frame\-Codec}{p.}{classTPProto_1_1FrameCodec} to send the data on the network. \begin{Desc}
\item[Returns:]Data in the buffer. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!getLength@{getLength}}
\index{getLength@{getLength}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TPProto::Buffer::get\-Length ()}\label{classTPProto_1_1Buffer_31bf8565baf88c3affcdb6616808b8da}


Gets the current length of the data in the buffer. 

\begin{Desc}
\item[Returns:]The length of the buffer in bytes. \end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!setStringPadding@{setStringPadding}}
\index{setStringPadding@{setStringPadding}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void TPProto::Buffer::set\-String\-Padding (bool {\em nsp})}\label{classTPProto_1_1Buffer_4b8210bddf494653893fa44fcc0bc899}


Sets if String Padding is turned on. 

Should only be called by \doxyref{Frame\-Codec}{p.}{classTPProto_1_1FrameCodec} for use in the String Padding filter. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nsp}]The new bool value for String Padding. \end{description}
\end{Desc}
\index{TPProto::Buffer@{TPProto::Buffer}!getStringPadding@{getStringPadding}}
\index{getStringPadding@{getStringPadding}!TPProto::Buffer@{TPProto::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool TPProto::Buffer::get\-String\-Padding () const}\label{classTPProto_1_1Buffer_4abf626619fe2f9eb0f28dd7fcba0849}


Checks if String Padding is turned on. 

\begin{Desc}
\item[Returns:]True if string padding is no, false otherwise. \end{Desc}


The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
tpproto/{\bf buffer.h}\item 
tpproto/buffer.cpp\end{CompactItemize}
