16 #ifndef INCLUDE_NN_NLIB_REALLOCOUTPUTSTREAM_H_ 17 #define INCLUDE_NN_NLIB_REALLOCOUTPUTSTREAM_H_ 28 typedef void* (*ReallocFunc)(
void* ptr,
size_t n)NLIB_NOEXCEPT_FUNCPTR;
30 explicit ReallocDeleter(ReallocFunc reallocfunc)
NLIB_NOEXCEPT : realloc_(reallocfunc) {}
32 ReallocFunc GetFunc() const
NLIB_NOEXCEPT {
return realloc_; }
42 typedef void* (*ReallocFunc)(
void* ptr,
size_t n)NLIB_NOEXCEPT_FUNCPTR;
59 if (this->ExpandOrShrink(this->
Pos()) == 0) {
65 #ifdef __cpp_rvalue_references 71 #ifdef __cpp_rvalue_references 77 return (newcap > capacity_) ? this->ExpandOrShrink(newcap) : 0;
87 ReallocFunc realloc_func_;
94 #endif // INCLUDE_NN_NLIB_REALLOCOUTPUTSTREAM_H_ #define NLIB_OVERRIDE
Defines override if it is available for use. If not, holds an empty string.
ReallocOutputStream() noexcept
Instantiates the object with default parameters (default constructor). Configures the object to expan...
UniquePtr< char[], ReallocDeleter > CharPtrType
The typedefed UniquePtr to a char array.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
The class for output streams written to memory expanded using nlib_realloc or another realloc functio...
size_t Pos() const noexcept
Returns the current position in the stream.
In the C++11 environment (which supports alias templates), std::unique_ptr is made an alias template...
Defines that class that is corresponding to std::unique_ptr.
void ShrinkToFit() noexcept
Makes the buffer size fit to the current write position.
const uint8_t * Data() const noexcept
The const decoration version of the above function.
UniquePtr< uint8_t[], ReallocDeleter > UniquePtrType
The typedefed UniquePtr to a uint8_t array.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
ReallocOutputStream(ReallocFunc func) noexcept
Specifies a realloc function and instantiates an object.
void ResetBuffer(void *p, size_t nbytes) noexcept
Sets the buffer held by OutputStream.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#define NLIB_STATIC_ASSERT(exp)
Defines a static assertion. Uses static_assert if it is available for use.
bool Reserve(size_t n) noexcept
Allocates a buffer of the specified size for writing to.
Defines the base class for output streams.
The base class for output streams. This class cannot be instantiated.