Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simplest solution is to plainly use a special buffering class and overload the output operators needed:</p> <pre><code>struct buffer_class { // The data needed... }; inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const std::string&amp; s) { // Code to add the string to the buffer return buffer; } inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const uint8_t ub) { // Code to add the value to the buffer return buffer; } inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const int8_t sb) { // Code to add the value to the buffer return buffer; } </code></pre> <p>Add more operator overloads for the all the data needed.</p> <hr> <p>For example, it could be like this:</p> <pre><code>struct buffer_class { std::vector&lt;int8_t&gt; data; }; inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const std::string&amp; s) { for (const auto&amp; ch : s) buffer.data.push_back(static_cast&lt;unt8_t&gt;(ch)); return buffer; } inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const uint8_t ub) { buffer.data.push_back(static_cast&lt;int8_t&gt;(ub)); return buffer; } inline buffer_class&amp; operator&lt;&lt;(buffer_class&amp; buffer, const int8_t sb) { buffer.data.push_back(sb); return buffer; } </code></pre> <p>Then you could use it like:</p> <pre><code>buffer_class my_buffer; buffer &lt;&lt; std::string("Hello") &lt;&lt; 123: // The raw data can now be accessed by `my_buffer.data.data()` </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload