#include <common.h>
Public Types | |
typedef container_traits< typename intern_t::physical_buf_t > | cont_trts |
typedef cont_trts::insertion_iterator | iterator |
Public Member Functions | |
obuf_slice_unbounded () | |
obuf_slice_unbounded (range_type *aRng, seqnum_t seqNum) | |
obuf_slice_unbounded (const obuf_slice_unbounded &aSR) | |
iterator | begout (void) |
result_t::seq_out_iterator | flush (void) |
~obuf_slice_unbounded () | |
seqnum_t | sequence_number (void) const |
void | set_number (seqnum_t seqNum) |
Used for an in-place chop. | |
Private Types | |
typedef RangeOutp | range_type |
typedef range_type::result_t | result_t |
typedef result_t::internal_buffer | intern_t |
Private Member Functions | |
assert_declare (bool, _BeforeBegin) | |
obuf_slice_unbounded & | operator= (const obuf_slice_unbounded &aSR) |
Private Attributes | |
range_type * | _Rng |
intern_t | _SliceBufNolimit |
seqnum_t | _SeqNum |
typedef container_traits< typename intern_t::physical_buf_t > rpa::obuf_slice_unbounded< RangeOutp >::cont_trts |
We do not need to pick up the type of the physical buffer, because 'internal_buffer' has the same container properties.
typedef result_t::internal_buffer rpa::obuf_slice_unbounded< RangeOutp >::intern_t [private] |
typedef cont_trts::insertion_iterator rpa::obuf_slice_unbounded< RangeOutp >::iterator |
For simplicity, we use for slices - which are sequentially executed - plain 'back_insert_iterator'. For plain STL iterators, this is equivalent to a std::back_insert_iterator. For C-style arrays, it is a pointer.
typedef RangeOutp rpa::obuf_slice_unbounded< RangeOutp >::range_type [private] |
typedef range_type::result_t rpa::obuf_slice_unbounded< RangeOutp >::result_t [private] |
Depending on the 'obuf_stream', we will have to allocate a buffer, or the slice will have a reference pointing to a pre-allocated buffer : To get a new buffer, we will use the buffer iterator maybe contained in the 'obuf_iterator'. It is a pointer because there are some copies of slices, in range_step::chop_noguard.
rpa::obuf_slice_unbounded< RangeOutp >::obuf_slice_unbounded | ( | ) | [inline] |
Needed for 'range_step' which uses operator=. The default ctor for the buffer must be very cheap. We must have a single buffer per thread. TODO: It would be fine to get rid of this default constructor !
rpa::obuf_slice_unbounded< RangeOutp >::obuf_slice_unbounded | ( | range_type * | aRng, | |
seqnum_t | seqNum | |||
) | [inline, explicit] |
This MUST be called only once per range and per thread, because buffers are expensive. If a range needs to create a slice, it must use the reuse form of 'chop'. Unwinds the buffer, so 'begin' starts from the beginning.
This copies to the internal buffer, the formatting attributes of the output iterator, and maybe the delimiter. At the same time, internally, the buffer (For example, a stream buffer), may be allocated.
This is done only once the buffer is allocated. Of course, if the buffer is not allocated, we may consider that it is empty.
rpa::obuf_slice_unbounded< RangeOutp >::obuf_slice_unbounded | ( | const obuf_slice_unbounded< RangeOutp > & | aSR | ) | [inline] |
The compiler-generated copy constructor and operator= are allowed : Please note that for the buffer, these operators do NOTHING. This constructor is explicitely added just for adding asserts.
rpa::obuf_slice_unbounded< RangeOutp >::~obuf_slice_unbounded | ( | ) | [inline] |
This flushes the temporary buffer into the output container. We must be sure that only one 'splice' occurs at a time. If the output buffer has a limited size like here, this happens each time the buffer is flushed, except the last time. NOTE: This is also true for 'range_jump', but NOT for 'range_step !
The buffer must be empty. We flush it explicitely because we want to control the flushing order of all the buffers, and this may not be the order of destruction. The buffer must be empty, i.e. flushed or never used.
rpa::obuf_slice_unbounded< RangeOutp >::assert_declare | ( | bool | , | |
_BeforeBegin | ||||
) | [private] |
iterator rpa::obuf_slice_unbounded< RangeOutp >::begout | ( | void | ) | [inline] |
We assume that this object was properly built. Note that the buffer content is not copied. We simply ensure that the buffer is big enough. It should be the case if the slice was properly built. Used only in 'chop_again', which in fact just need to copy the input slice. Therefore this operator does not do anything. This operator is called when calling 'chop()' and 'chop_noguard()', which returns a single, a pair or a triplet of slices. The operator of the tuple1,2,3 calls this operator. Works, whether the buffer is local, or if it is a reference. For unlimited buffers.
We do not check whether '_BeforeBegin' is true. because the method 'begin' can be safely called several times.
result_t::seq_out_iterator rpa::obuf_slice_unbounded< RangeOutp >::flush | ( | void | ) | [inline] |
This flushes the temporary buffer into the output container. We must be sure that only one 'splice' occurs at a time. Specifically for 'range_size', there is only one slice, and they are created and destroyed by the main thread. Therefore, there is no need to lock anything when flushing the temporary buffers into the output container. NOTE: This is also true for 'range_jump', but NOT for 'range_step ! The unlimited buffers will be flushed only once per thread.
The method 'begin' must have been called at least once : Otherwise, calling 'flush' is meaningless.
obuf_slice_unbounded& rpa::obuf_slice_unbounded< RangeOutp >::operator= | ( | const obuf_slice_unbounded< RangeOutp > & | aSR | ) | [private] |
seqnum_t rpa::obuf_slice_unbounded< RangeOutp >::sequence_number | ( | void | ) | const [inline] |
void rpa::obuf_slice_unbounded< RangeOutp >::set_number | ( | seqnum_t | seqNum | ) | [inline] |
Used for an in-place chop.
range_type* rpa::obuf_slice_unbounded< RangeOutp >::_Rng [private] |
seqnum_t rpa::obuf_slice_unbounded< RangeOutp >::_SeqNum [private] |
intern_t rpa::obuf_slice_unbounded< RangeOutp >::_SliceBufNolimit [private] |