\hypertarget{struct_protobuf_c_buffer}{}\section{Protobuf\+C\+Buffer Struct Reference}
\label{struct_protobuf_c_buffer}\index{Protobuf\+C\+Buffer@{Protobuf\+C\+Buffer}}


{\ttfamily \#include $<$protobuf-\/c.\+h$>$}

\subsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
void($\ast$ \hyperlink{struct_protobuf_c_buffer_af767046cd308f5b52450cac9591d1b15}{append} )(\hyperlink{struct_protobuf_c_buffer}{Protobuf\+C\+Buffer} $\ast$buffer, size\+\_\+t len, const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$data)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
Structure for defining a virtual append-\/only buffer. Used by \hyperlink{group__api_gaa1cde08f1ad1408209ed427f9e0647bc}{protobuf\+\_\+c\+\_\+message\+\_\+pack\+\_\+to\+\_\+buffer()} to abstract the consumption of serialized bytes.

{\ttfamily \hyperlink{struct_protobuf_c_buffer}{Protobuf\+C\+Buffer}} \char`\"{}subclasses\char`\"{} may be defined on the stack. For example, to write to a {\ttfamily F\+I\+LE} object\+:


\begin{DoxyCode}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\{
        \hyperlink{struct_protobuf_c_buffer}{ProtobufCBuffer} base;
        FILE *fp;
\} BufferAppendToFile;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
my\_buffer\_file\_append(\hyperlink{struct_protobuf_c_buffer}{ProtobufCBuffer} *buffer,
                      \textcolor{keywordtype}{size\_t} len,
                      \textcolor{keyword}{const} \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\_t} *data)
\{
        BufferAppendToFile *file\_buf = (BufferAppendToFile *) buffer;
        fwrite(data, len, 1, file\_buf->fp); \textcolor{comment}{// XXX: No error handling!}
\}
\end{DoxyCode}


To use this new type of \hyperlink{struct_protobuf_c_buffer}{Protobuf\+C\+Buffer}, it could be called as follows\+:


\begin{DoxyCode}
...
BufferAppendToFile tmp = \{0\};
tmp.base.append = my\_buffer\_file\_append;
tmp.fp = fp;
\hyperlink{group__api_gaa1cde08f1ad1408209ed427f9e0647bc}{protobuf\_c\_message\_pack\_to\_buffer}(&message, &tmp);
...
\end{DoxyCode}
 

Definition at line 433 of file protobuf-\/c.\+h.



\subsection{Field Documentation}
\mbox{\Hypertarget{struct_protobuf_c_buffer_af767046cd308f5b52450cac9591d1b15}\label{struct_protobuf_c_buffer_af767046cd308f5b52450cac9591d1b15}} 
\index{Protobuf\+C\+Buffer@{Protobuf\+C\+Buffer}!append@{append}}
\index{append@{append}!Protobuf\+C\+Buffer@{Protobuf\+C\+Buffer}}
\subsubsection{\texorpdfstring{append}{append}}
{\footnotesize\ttfamily void($\ast$ append) (\hyperlink{struct_protobuf_c_buffer}{Protobuf\+C\+Buffer} $\ast$buffer, size\+\_\+t len, const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$data)}

Append function. Consumes the {\ttfamily len} bytes stored at {\ttfamily data}. 

Definition at line 435 of file protobuf-\/c.\+h.



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
src/protobuf-\/c/\hyperlink{protobuf-c_8h}{protobuf-\/c.\+h}\end{DoxyCompactItemize}
