Thrill  0.1
FixedBufferBuilder< Capacity > Class Template Reference

Detailed Description

template<size_t Capacity>
class thrill::net::FixedBufferBuilder< Capacity >

Represents a FIXED length area of memory, which can be modified by appending integral data types via Put() and other basic operations.

Definition at line 38 of file fixed_buffer_builder.hpp.

+ Inheritance diagram for FixedBufferBuilder< Capacity >:
+ Collaboration diagram for FixedBufferBuilder< Capacity >:

#include <fixed_buffer_builder.hpp>

Public Member Functions

Data, Size, and Capacity Accessors
const Bytedata () const
 Return a pointer to the currently kept memory area. More...
 
Bytedata ()
 Return a writeable pointer to the currently kept memory area. More...
 
size_t size () const
 Return the currently used length in bytes. More...
 
size_t capacity () const
 Return the currently allocated buffer capacity. More...
 
Buffer Growing, Clearing, and other Management
FixedBufferBuilderClear ()
 Clears the memory contents, does not deallocate the memory. More...
 
FixedBufferBuilderset_size (size_t n)
 
std::string ToString () const
 Explicit conversion to std::string (copies memory of course). More...
 
Appending Write Functions
FixedBufferBuilderAppend (const void *data, size_t len)
 Append a memory range to the buffer. More...
 
FixedBufferBuilderAppendString (const std::string &s)
 
template<typename Type >
FixedBufferBuilderPut (const Type &item)
 
FixedBufferBuilderPutByte (Byte data)
 Put a single byte to the buffer (used via CRTP from ItemWriterToolsBase) More...
 
template<typename Type >
FixedBufferBuilderPutRaw (const Type &item)
 
Access
iterator begin ()
 return mutable iterator to first element More...
 
const_iterator begin () const
 return constant iterator to first element More...
 
iterator end ()
 return mutable iterator beyond last element More...
 
const_iterator end () const
 return constant iterator beyond last element More...
 
reference operator[] (size_t i)
 return the i-th position of the vector More...
 
- Public Member Functions inherited from ItemWriterToolsBase< FixedBufferBuilder< Capacity > >
FixedBufferBuilder< Capacity > & PutString (const char *data, size_t len)
 Put a string by saving it's length followed by the data itself. More...
 
FixedBufferBuilder< Capacity > & PutString (const uint8_t *data, size_t len)
 Put a string by saving it's length followed by the data itself. More...
 
FixedBufferBuilder< Capacity > & PutString (const std::string &str)
 Put a string by saving it's length followed by the data itself. More...
 
FixedBufferBuilder< Capacity > & PutVarint (uint64_t v)
 Append a varint to the writer. More...
 
FixedBufferBuilder< Capacity > & PutVarint32 (uint32_t v)
 Append a varint to the writer. More...
 

Private Types

using Byte = unsigned char
 type used to store the bytes More...
 
using const_iterator = const Byte *
 simple pointer iterators More...
 
using const_reference = const Byte &
 simple pointer references More...
 
using iterator = Byte *
 simple pointer iterators More...
 
using reference = Byte &
 simple pointer references More...
 

Private Attributes

std::array< Byte, Capacity > data_
 Allocated buffer. More...
 
size_t size_ = 0
 Size of valid data. More...
 

Member Typedef Documentation

◆ Byte

using Byte = unsigned char
private

type used to store the bytes

Definition at line 43 of file fixed_buffer_builder.hpp.

◆ const_iterator

using const_iterator = const Byte *
private

simple pointer iterators

Definition at line 48 of file fixed_buffer_builder.hpp.

◆ const_reference

using const_reference = const Byte&
private

simple pointer references

Definition at line 52 of file fixed_buffer_builder.hpp.

◆ iterator

using iterator = Byte *
private

simple pointer iterators

Definition at line 46 of file fixed_buffer_builder.hpp.

◆ reference

using reference = Byte&
private

simple pointer references

Definition at line 50 of file fixed_buffer_builder.hpp.

Member Function Documentation

◆ Append()

FixedBufferBuilder& Append ( const void *  data,
size_t  len 
)
inline

Append a memory range to the buffer.

Definition at line 115 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::data(), and FixedBufferBuilder< Capacity >::size_.

Referenced by FixedBufferBuilder< Capacity >::AppendString().

◆ AppendString()

FixedBufferBuilder& AppendString ( const std::string &  s)
inline

Append to contents of a std::string, excluding the null (which isn't contained in the string size anyway).

Definition at line 127 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::Append().

◆ begin() [1/2]

iterator begin ( )
inline

return mutable iterator to first element

Definition at line 164 of file fixed_buffer_builder.hpp.

Referenced by FixedBufferBuilder< Capacity >::operator[]().

◆ begin() [2/2]

const_iterator begin ( ) const
inline

return constant iterator to first element

Definition at line 167 of file fixed_buffer_builder.hpp.

◆ capacity()

size_t capacity ( ) const
inline

Return the currently allocated buffer capacity.

Definition at line 80 of file fixed_buffer_builder.hpp.

◆ Clear()

FixedBufferBuilder& Clear ( )
inline

Clears the memory contents, does not deallocate the memory.

Definition at line 90 of file fixed_buffer_builder.hpp.

◆ data() [1/2]

const Byte* data ( ) const
inline

Return a pointer to the currently kept memory area.

Definition at line 65 of file fixed_buffer_builder.hpp.

Referenced by FixedBufferBuilder< Capacity >::Append(), and FixedBufferBuilder< Capacity >::PutByte().

◆ data() [2/2]

Byte* data ( )
inline

Return a writeable pointer to the currently kept memory area.

Definition at line 70 of file fixed_buffer_builder.hpp.

◆ end() [1/2]

iterator end ( )
inline

return mutable iterator beyond last element

Definition at line 171 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::size_.

◆ end() [2/2]

const_iterator end ( ) const
inline

return constant iterator beyond last element

Definition at line 174 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::size_.

◆ operator[]()

reference operator[] ( size_t  i)
inline

return the i-th position of the vector

Definition at line 178 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::begin().

◆ Put()

FixedBufferBuilder& Put ( const Type &  item)
inline

Put (append) a single item of the template type T to the buffer. Be careful with implicit type conversions!

Definition at line 134 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::size_, and gen_data::value.

◆ PutByte()

FixedBufferBuilder& PutByte ( Byte  data)
inline

Put a single byte to the buffer (used via CRTP from ItemWriterToolsBase)

Definition at line 147 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::data().

◆ PutRaw()

FixedBufferBuilder& PutRaw ( const Type &  item)
inline

Put (append) a single item of the template type T to the buffer. Be careful with implicit type conversions!

Definition at line 154 of file fixed_buffer_builder.hpp.

◆ set_size()

FixedBufferBuilder& set_size ( size_t  n)
inline

Set the valid bytes in the buffer, use if the buffer is filled directly.

Definition at line 97 of file fixed_buffer_builder.hpp.

◆ size()

size_t size ( ) const
inline

Return the currently used length in bytes.

Definition at line 75 of file fixed_buffer_builder.hpp.

References FixedBufferBuilder< Capacity >::size_.

◆ ToString()

std::string ToString ( ) const
inline

Explicit conversion to std::string (copies memory of course).

Definition at line 105 of file fixed_buffer_builder.hpp.

Member Data Documentation

◆ data_

std::array<Byte, Capacity> data_
private

Allocated buffer.

Definition at line 55 of file fixed_buffer_builder.hpp.

◆ size_


The documentation for this class was generated from the following file: