DynamicBuffer: dos2unix

This commit is contained in:
Ingo Weinhold
2014-07-03 17:39:57 +02:00
parent 739f15e144
commit 7616c39db6
+63 -63
View File
@@ -1,63 +1,63 @@
/* /*
* Copyright 2009-2014, Haiku, Inc. All Rights Reserved. * Copyright 2009-2014, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Bruno Albuquerque, [email protected] * Bruno Albuquerque, [email protected]
*/ */
#ifndef _DYNAMIC_BUFFER_H #ifndef _DYNAMIC_BUFFER_H
#define _DYNAMIC_BUFFER_H #define _DYNAMIC_BUFFER_H
#include <DataIO.h> #include <DataIO.h>
#include <SupportDefs.h> #include <SupportDefs.h>
class DynamicBuffer : public BDataIO { class DynamicBuffer : public BDataIO {
public: public:
DynamicBuffer(size_t initialSize = 0); DynamicBuffer(size_t initialSize = 0);
~DynamicBuffer(); ~DynamicBuffer();
DynamicBuffer(const DynamicBuffer& buffer); DynamicBuffer(const DynamicBuffer& buffer);
// InitCheck() should be called to guarantee the object initialization // InitCheck() should be called to guarantee the object initialization
// didn't fail. If it does not return B_OK, the initialization failed. // didn't fail. If it does not return B_OK, the initialization failed.
status_t InitCheck() const; status_t InitCheck() const;
// Insert data at the end of the buffer. The buffer will be increased to // Insert data at the end of the buffer. The buffer will be increased to
// accomodate the data if needed. // accomodate the data if needed.
status_t Write(const void* data, size_t size); status_t Write(const void* data, size_t size);
// Remove data from the start of the buffer. Move the buffer start // Remove data from the start of the buffer. Move the buffer start
// pointer to point to the data following it. // pointer to point to the data following it.
ssize_t Read(void* data, size_t size); ssize_t Read(void* data, size_t size);
// Return a pointer to the underlying buffer. Note this will not // Return a pointer to the underlying buffer. Note this will not
// necessarily be a pointer to the start of the allocated memory as the // necessarily be a pointer to the start of the allocated memory as the
// initial data may be positioned at an offset inside the buffer. In other // initial data may be positioned at an offset inside the buffer. In other
// words, this returns a pointer to the start of data inside the buffer. // words, this returns a pointer to the start of data inside the buffer.
unsigned char* Data() const; unsigned char* Data() const;
// Returns the actual buffer size. This is the amount of memory allocated // Returns the actual buffer size. This is the amount of memory allocated
// for the buffer. // for the buffer.
size_t Size() const; size_t Size() const;
// Number of bytes of data still present in the buffer that can be // Number of bytes of data still present in the buffer that can be
// extracted through calls to Remove(). // extracted through calls to Remove().
size_t BytesRemaining() const; size_t BytesRemaining() const;
// Dump some buffer statistics to stdout. // Dump some buffer statistics to stdout.
void PrintToStream(); void PrintToStream();
private: private:
status_t _GrowToFit(size_t size, bool exact = false); status_t _GrowToFit(size_t size, bool exact = false);
unsigned char* fBuffer; unsigned char* fBuffer;
size_t fBufferSize; size_t fBufferSize;
size_t fDataStart; size_t fDataStart;
size_t fDataEnd; size_t fDataEnd;
status_t fInit; status_t fInit;
}; };
#endif // _DYNAMIC_BUFFER_H #endif // _DYNAMIC_BUFFER_H