mirror of
https://github.com/oatpp/oatpp.git
synced 2025-01-18 16:43:57 +08:00
Refactor. More consistent integer types.
This commit is contained in:
parent
6ba549c99a
commit
5ef313004b
@ -62,12 +62,12 @@ p_word32 CRC32::generateTable(v_word32 poly) {
|
||||
|
||||
}
|
||||
|
||||
v_word32 CRC32::calc(const void *buffer, v_int32 size, v_word32 crc, v_word32 initValue, v_word32 xorOut, p_word32 table) {
|
||||
v_word32 CRC32::calc(const void *buffer, v_buff_size size, v_word32 crc, v_word32 initValue, v_word32 xorOut, p_word32 table) {
|
||||
|
||||
p_word8 data = (p_word8) buffer;
|
||||
crc = crc ^ initValue;
|
||||
|
||||
for(v_int32 i = 0; i < size; i++) {
|
||||
for(v_buff_size i = 0; i < size; i++) {
|
||||
crc = table[(crc & 0xFF) ^ data[i]] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
* @param table
|
||||
* @return - CRC32 value (v_word32)
|
||||
*/
|
||||
static v_word32 calc(const void *buffer, v_int32 size, v_word32 crc = 0, v_word32 initValue = 0xFFFFFFFF, v_word32 xorOut = 0xFFFFFFFF, p_word32 table = TABLE_04C11DB7);
|
||||
static v_word32 calc(const void *buffer, v_buff_size size, v_word32 crc = 0, v_word32 initValue = 0xFFFFFFFF, v_word32 xorOut = 0xFFFFFFFF, p_word32 table = TABLE_04C11DB7);
|
||||
|
||||
};
|
||||
|
||||
|
@ -70,9 +70,15 @@ typedef v_float32* p_float32;
|
||||
typedef std::atomic_int_fast64_t v_atomicCounter;
|
||||
typedef v_int64 v_counter;
|
||||
|
||||
/**
|
||||
* This type is the integer type capable of storing a pointer. Thus is capable of storing size of allocated memory. <br>
|
||||
* Use this type to define a size for the buffer.
|
||||
*/
|
||||
typedef intptr_t v_buff_size;
|
||||
|
||||
namespace oatpp { namespace base{
|
||||
typedef v_buff_size* p_buff_size;
|
||||
|
||||
namespace oatpp { namespace base {
|
||||
|
||||
/**
|
||||
* Interface for system-wide Logger.<br>
|
||||
|
@ -143,7 +143,7 @@ ThreadDistributedMemoryPool::ThreadDistributedMemoryPool(const std::string& name
|
||||
, m_deleted(false)
|
||||
{
|
||||
for(v_int64 i = 0; i < m_shardsCount; i++){
|
||||
m_shards[i] = new MemoryPool(name + "_" + oatpp::utils::conversion::int32ToStdStr(i), entrySize, chunkSize);
|
||||
m_shards[i] = new MemoryPool(name + "_" + oatpp::utils::conversion::int64ToStdStr(i), entrySize, chunkSize);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
namespace oatpp { namespace data{ namespace buffer {
|
||||
|
||||
FIFOBuffer::FIFOBuffer(void* buffer, v_io_size bufferSize,
|
||||
data::v_io_size readPosition, data::v_io_size writePosition,
|
||||
FIFOBuffer::FIFOBuffer(void* buffer, v_buff_size bufferSize,
|
||||
v_buff_size readPosition, v_buff_size writePosition,
|
||||
bool canRead)
|
||||
: m_buffer((p_char8)buffer)
|
||||
, m_bufferSize(bufferSize)
|
||||
@ -37,7 +37,7 @@ FIFOBuffer::FIFOBuffer(void* buffer, v_io_size bufferSize,
|
||||
, m_canRead(canRead)
|
||||
{}
|
||||
|
||||
void FIFOBuffer::setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead) {
|
||||
void FIFOBuffer::setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead) {
|
||||
m_readPosition = readPosition;
|
||||
m_writePosition = writePosition;
|
||||
m_canRead = canRead;
|
||||
@ -63,7 +63,7 @@ data::v_io_size FIFOBuffer::availableToWrite() const {
|
||||
return (m_bufferSize - m_writePosition + m_readPosition);
|
||||
}
|
||||
|
||||
data::v_io_size FIFOBuffer::getBufferSize() const {
|
||||
v_buff_size FIFOBuffer::getBufferSize() const {
|
||||
return m_bufferSize;
|
||||
}
|
||||
|
||||
@ -435,13 +435,13 @@ async::CoroutineStarter FIFOBuffer::flushToStreamAsync(const std::shared_ptr<dat
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SynchronizedFIFOBuffer
|
||||
|
||||
SynchronizedFIFOBuffer::SynchronizedFIFOBuffer(void* buffer, v_io_size bufferSize,
|
||||
data::v_io_size readPosition, data::v_io_size writePosition,
|
||||
SynchronizedFIFOBuffer::SynchronizedFIFOBuffer(void* buffer, v_buff_size bufferSize,
|
||||
v_buff_size readPosition, v_buff_size writePosition,
|
||||
bool canRead)
|
||||
: m_fifo(buffer, bufferSize, readPosition, writePosition, canRead)
|
||||
{}
|
||||
|
||||
void SynchronizedFIFOBuffer::setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead) {
|
||||
void SynchronizedFIFOBuffer::setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead) {
|
||||
std::lock_guard<oatpp::concurrency::SpinLock> lock(m_lock);
|
||||
m_fifo.setBufferPosition(readPosition, writePosition, canRead);
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
* @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then
|
||||
* &l:FIFOBuffer::availableToRead (); returns buffer size, and &l:FIFOBuffer::availableToWrite (); returns 0.
|
||||
*/
|
||||
FIFOBuffer(void* buffer, v_io_size bufferSize,
|
||||
data::v_io_size readPosition = 0, data::v_io_size writePosition = 0,
|
||||
FIFOBuffer(void* buffer, v_buff_size bufferSize,
|
||||
v_buff_size readPosition = 0, v_buff_size writePosition = 0,
|
||||
bool canRead = false);
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public:
|
||||
* @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then
|
||||
* &l:FIFOBuffer::availableToRead (); returns buffer size, and &l:FIFOBuffer::availableToWrite (); returns 0.
|
||||
*/
|
||||
void setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead);
|
||||
void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead);
|
||||
|
||||
/**
|
||||
* Amount of bytes currently available to read from buffer.
|
||||
@ -83,7 +83,7 @@ public:
|
||||
* Get FIFOBuffer size.
|
||||
* @return - FIFOBuffer size.
|
||||
*/
|
||||
data::v_io_size getBufferSize() const;
|
||||
v_buff_size getBufferSize() const;
|
||||
|
||||
/**
|
||||
* read up to count bytes from the buffer to data
|
||||
@ -167,8 +167,8 @@ public:
|
||||
* @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then
|
||||
* &l:SynchronizedFIFOBuffer::availableToRead (); returns buffer size, and &l:SynchronizedFIFOBuffer::availableToWrite (); returns 0.
|
||||
*/
|
||||
SynchronizedFIFOBuffer(void* buffer, v_io_size bufferSize,
|
||||
data::v_io_size readPosition = 0, data::v_io_size writePosition = 0,
|
||||
SynchronizedFIFOBuffer(void* buffer, v_buff_size bufferSize,
|
||||
v_buff_size readPosition = 0, v_buff_size writePosition = 0,
|
||||
bool canRead = false);
|
||||
|
||||
/**
|
||||
@ -178,7 +178,7 @@ public:
|
||||
* @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then
|
||||
* &l:SynchronizedFIFOBuffer::availableToRead (); returns buffer size, and &l:SynchronizedFIFOBuffer::availableToWrite (); returns 0.
|
||||
*/
|
||||
void setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead);
|
||||
void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead);
|
||||
|
||||
/**
|
||||
* Amount of bytes currently available to read from buffer.
|
||||
|
@ -42,7 +42,7 @@ void* IOBuffer::getData(){
|
||||
return m_entry;
|
||||
}
|
||||
|
||||
v_int32 IOBuffer::getSize(){
|
||||
v_buff_size IOBuffer::getSize(){
|
||||
return BUFFER_SIZE;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
/**
|
||||
* Buffer size constant.
|
||||
*/
|
||||
static constexpr v_int32 BUFFER_SIZE = 4096;
|
||||
static constexpr v_buff_size BUFFER_SIZE = 4096;
|
||||
private:
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getBufferPool(){
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool("IOBuffer_Buffer_Pool", BUFFER_SIZE, 16);
|
||||
@ -78,7 +78,7 @@ public:
|
||||
* Get buffer size.
|
||||
* @return - should always return &l:IOBuffer::BUFFER_SIZE;.
|
||||
*/
|
||||
v_int32 getSize();
|
||||
v_buff_size getSize();
|
||||
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace oatpp { namespace data{ namespace stream {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BufferOutputStream
|
||||
|
||||
BufferOutputStream::BufferOutputStream(v_io_size initialCapacity, v_io_size growBytes)
|
||||
BufferOutputStream::BufferOutputStream(v_buff_size initialCapacity, v_buff_size growBytes)
|
||||
: m_data(new v_char8[initialCapacity])
|
||||
, m_capacity(initialCapacity)
|
||||
, m_position(0)
|
||||
@ -60,7 +60,7 @@ IOMode BufferOutputStream::getOutputStreamIOMode() {
|
||||
return m_ioMode;
|
||||
}
|
||||
|
||||
void BufferOutputStream::reserveBytesUpfront(v_io_size count) {
|
||||
void BufferOutputStream::reserveBytesUpfront(v_buff_size count) {
|
||||
|
||||
if(m_position + count > m_capacity) {
|
||||
|
||||
@ -68,14 +68,14 @@ void BufferOutputStream::reserveBytesUpfront(v_io_size count) {
|
||||
throw std::runtime_error("[oatpp::data::stream::BufferOutputStream::reserveBytesUpfront()]: Error. Buffer was not allowed to grow.");
|
||||
}
|
||||
|
||||
data::v_io_size extraNeeded = m_position + count - m_capacity;
|
||||
data::v_io_size extraChunks = extraNeeded / m_growBytes;
|
||||
v_buff_size extraNeeded = m_position + count - m_capacity;
|
||||
v_buff_size extraChunks = extraNeeded / m_growBytes;
|
||||
|
||||
if(extraChunks * m_growBytes < extraNeeded) {
|
||||
extraChunks ++;
|
||||
}
|
||||
|
||||
data::v_io_size newCapacity = m_capacity + extraChunks * m_growBytes;
|
||||
v_buff_size newCapacity = m_capacity + extraChunks * m_growBytes;
|
||||
p_char8 newData = new v_char8[newCapacity];
|
||||
|
||||
std::memcpy(newData, m_data, m_position);
|
||||
@ -92,17 +92,17 @@ p_char8 BufferOutputStream::getData() {
|
||||
}
|
||||
|
||||
|
||||
v_io_size BufferOutputStream::getCapacity() {
|
||||
v_buff_size BufferOutputStream::getCapacity() {
|
||||
return m_capacity;
|
||||
}
|
||||
|
||||
|
||||
v_io_size BufferOutputStream::getCurrentPosition() {
|
||||
v_buff_size BufferOutputStream::getCurrentPosition() {
|
||||
return m_position;
|
||||
}
|
||||
|
||||
|
||||
void BufferOutputStream::setCurrentPosition(v_io_size position) {
|
||||
void BufferOutputStream::setCurrentPosition(v_buff_size position) {
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ oatpp::String BufferOutputStream::toString() {
|
||||
return oatpp::String((const char*)m_data, m_position, true);
|
||||
}
|
||||
|
||||
oatpp::String BufferOutputStream::getSubstring(data::v_io_size pos, v_buff_size count) {
|
||||
oatpp::String BufferOutputStream::getSubstring(v_buff_size pos, v_buff_size count) {
|
||||
if(pos + count <= m_position) {
|
||||
return oatpp::String((const char *) (m_data + pos), count, true);
|
||||
} else {
|
||||
@ -155,7 +155,7 @@ oatpp::async::CoroutineStarter BufferOutputStream::flushToStreamAsync(const std:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BufferInputStream
|
||||
|
||||
BufferInputStream::BufferInputStream(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size)
|
||||
BufferInputStream::BufferInputStream(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_buff_size size)
|
||||
: m_memoryHandle(memoryHandle)
|
||||
, m_data(data)
|
||||
, m_size(size)
|
||||
@ -167,7 +167,7 @@ BufferInputStream::BufferInputStream(const oatpp::String& data)
|
||||
: BufferInputStream(data.getPtr(), data->getData(), data->getSize())
|
||||
{}
|
||||
|
||||
void BufferInputStream::reset(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size) {
|
||||
void BufferInputStream::reset(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_buff_size size) {
|
||||
m_memoryHandle = memoryHandle;
|
||||
m_data = data;
|
||||
m_size = size;
|
||||
@ -182,7 +182,7 @@ void BufferInputStream::reset() {
|
||||
}
|
||||
|
||||
data::v_io_size BufferInputStream::read(void *data, v_buff_size count) {
|
||||
data::v_io_size desiredAmount = count;
|
||||
v_buff_size desiredAmount = count;
|
||||
if(desiredAmount > m_size - m_position) {
|
||||
desiredAmount = m_size - m_position;
|
||||
}
|
||||
@ -223,15 +223,15 @@ p_char8 BufferInputStream::getData() {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
v_io_size BufferInputStream::getDataSize() {
|
||||
v_buff_size BufferInputStream::getDataSize() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
v_io_size BufferInputStream::getCurrentPosition() {
|
||||
v_buff_size BufferInputStream::getCurrentPosition() {
|
||||
return m_position;
|
||||
}
|
||||
|
||||
void BufferInputStream::setCurrentPosition(v_io_size position) {
|
||||
void BufferInputStream::setCurrentPosition(v_buff_size position) {
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ namespace oatpp { namespace data{ namespace stream {
|
||||
class BufferOutputStream : public ConsistentOutputStream {
|
||||
private:
|
||||
p_char8 m_data;
|
||||
v_io_size m_capacity;
|
||||
v_io_size m_position;
|
||||
v_io_size m_growBytes;
|
||||
v_buff_size m_capacity;
|
||||
v_buff_size m_position;
|
||||
v_buff_size m_growBytes;
|
||||
IOMode m_ioMode;
|
||||
public:
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
* Constructor.
|
||||
* @param growBytes
|
||||
*/
|
||||
BufferOutputStream(v_io_size initialCapacity = 2048, v_io_size growBytes = 2048);
|
||||
BufferOutputStream(v_buff_size initialCapacity = 2048, v_buff_size growBytes = 2048);
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* Reserve bytes for future writes.
|
||||
*/
|
||||
void reserveBytesUpfront(v_io_size count);
|
||||
void reserveBytesUpfront(v_buff_size count);
|
||||
|
||||
/**
|
||||
* Get pointer to data.
|
||||
@ -88,19 +88,19 @@ public:
|
||||
* Capacity may change.
|
||||
* @return
|
||||
*/
|
||||
v_io_size getCapacity();
|
||||
v_buff_size getCapacity();
|
||||
|
||||
/**
|
||||
* Get current data write position.
|
||||
* @return - current data write position.
|
||||
*/
|
||||
v_io_size getCurrentPosition();
|
||||
v_buff_size getCurrentPosition();
|
||||
|
||||
/**
|
||||
* Set current data write position.
|
||||
* @param position - data write position.
|
||||
*/
|
||||
void setCurrentPosition(v_io_size position);
|
||||
void setCurrentPosition(v_buff_size position);
|
||||
|
||||
/**
|
||||
* Copy data to &id:oatpp::String;.
|
||||
@ -114,7 +114,7 @@ public:
|
||||
* @param count - size of bytes to write to substring.
|
||||
* @return - &id:oatpp::String;
|
||||
*/
|
||||
oatpp::String getSubstring(data::v_io_size pos, v_buff_size count);
|
||||
oatpp::String getSubstring(v_buff_size pos, v_buff_size count);
|
||||
|
||||
/**
|
||||
* Write all bytes from buffer to stream.
|
||||
@ -140,8 +140,8 @@ class BufferInputStream : public InputStream {
|
||||
private:
|
||||
std::shared_ptr<base::StrBuffer> m_memoryHandle;
|
||||
p_char8 m_data;
|
||||
v_io_size m_size;
|
||||
v_io_size m_position;
|
||||
v_buff_size m_size;
|
||||
v_buff_size m_position;
|
||||
IOMode m_ioMode;
|
||||
public:
|
||||
|
||||
@ -151,7 +151,7 @@ public:
|
||||
* @param data - pointer to buffer data.
|
||||
* @param size - size of the buffer.
|
||||
*/
|
||||
BufferInputStream(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size);
|
||||
BufferInputStream(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_buff_size size);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -165,7 +165,7 @@ public:
|
||||
* @param data - pointer to buffer data.
|
||||
* @param size - size of the buffer.
|
||||
*/
|
||||
void reset(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size);
|
||||
void reset(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_buff_size size);
|
||||
|
||||
|
||||
/**
|
||||
@ -219,19 +219,19 @@ public:
|
||||
* Get data size.
|
||||
* @return - data size.
|
||||
*/
|
||||
v_io_size getDataSize();
|
||||
v_buff_size getDataSize();
|
||||
|
||||
/**
|
||||
* Get current data read position.
|
||||
* @return - current data read position.
|
||||
*/
|
||||
v_io_size getCurrentPosition();
|
||||
v_buff_size getCurrentPosition();
|
||||
|
||||
/**
|
||||
* Set current data read position.
|
||||
* @param position - data read position.
|
||||
*/
|
||||
void setCurrentPosition(v_io_size position);
|
||||
void setCurrentPosition(v_buff_size position);
|
||||
|
||||
|
||||
};
|
||||
|
@ -30,10 +30,10 @@ const char* ChunkedBuffer::ERROR_ASYNC_FAILED_TO_WRITE_ALL_DATA = "ERROR_ASYNC_F
|
||||
|
||||
const char* const ChunkedBuffer::CHUNK_POOL_NAME = "ChunkedBuffer_Chunk_Pool";
|
||||
|
||||
const data::v_io_size ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT = 11;
|
||||
const data::v_io_size ChunkedBuffer::CHUNK_ENTRY_SIZE =
|
||||
const v_buff_size ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT = 11;
|
||||
const v_buff_size ChunkedBuffer::CHUNK_ENTRY_SIZE =
|
||||
(1 << ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT);
|
||||
const data::v_io_size ChunkedBuffer::CHUNK_CHUNK_SIZE = 32;
|
||||
const v_buff_size ChunkedBuffer::CHUNK_CHUNK_SIZE = 32;
|
||||
|
||||
ChunkedBuffer::ChunkedBuffer()
|
||||
: m_size(0)
|
||||
|
@ -45,14 +45,12 @@ public:
|
||||
|
||||
static const char* const CHUNK_POOL_NAME;
|
||||
|
||||
static const data::v_io_size CHUNK_ENTRY_SIZE_INDEX_SHIFT;
|
||||
static const data::v_io_size CHUNK_ENTRY_SIZE;
|
||||
static const data::v_io_size CHUNK_CHUNK_SIZE;
|
||||
static const v_buff_size CHUNK_ENTRY_SIZE_INDEX_SHIFT;
|
||||
static const v_buff_size CHUNK_ENTRY_SIZE;
|
||||
static const v_buff_size CHUNK_CHUNK_SIZE;
|
||||
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getSegemntPool(){
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool(CHUNK_POOL_NAME,
|
||||
(v_int32) CHUNK_ENTRY_SIZE,
|
||||
(v_int32) CHUNK_CHUNK_SIZE);
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool(CHUNK_POOL_NAME, CHUNK_ENTRY_SIZE, CHUNK_CHUNK_SIZE);
|
||||
return pool;
|
||||
}
|
||||
|
||||
@ -84,7 +82,7 @@ public:
|
||||
SHARED_OBJECT_POOL(Shared_ChunkedBuffer_Chunk_Pool, Chunk, 32)
|
||||
public:
|
||||
|
||||
Chunk(void* pData, data::v_io_size pSize)
|
||||
Chunk(void* pData, v_buff_size pSize)
|
||||
: data(pData)
|
||||
, size(pSize)
|
||||
{}
|
||||
@ -94,7 +92,7 @@ public:
|
||||
}
|
||||
|
||||
const void* data;
|
||||
const data::v_io_size size;
|
||||
const v_buff_size size;
|
||||
|
||||
};
|
||||
|
||||
|
@ -36,8 +36,6 @@ class OutputStreamBufferedProxy : public oatpp::base::Countable, public OutputSt
|
||||
public:
|
||||
OBJECT_POOL(OutputStreamBufferedProxy_Pool, OutputStreamBufferedProxy, 32)
|
||||
SHARED_OBJECT_POOL(Shared_OutputStreamBufferedProxy_Pool, OutputStreamBufferedProxy, 32)
|
||||
public:
|
||||
typedef v_int32 v_bufferSize;
|
||||
private:
|
||||
std::shared_ptr<OutputStream> m_outputStream;
|
||||
oatpp::data::share::MemoryLabel m_memoryLabel;
|
||||
@ -84,8 +82,6 @@ class InputStreamBufferedProxy : public oatpp::base::Countable, public InputStre
|
||||
public:
|
||||
OBJECT_POOL(InputStreamBufferedProxy_Pool, InputStreamBufferedProxy, 32)
|
||||
SHARED_OBJECT_POOL(Shared_InputStreamBufferedProxy_Pool, InputStreamBufferedProxy, 32)
|
||||
public:
|
||||
typedef v_int32 v_bufferSize;
|
||||
protected:
|
||||
std::shared_ptr<InputStream> m_inputStream;
|
||||
oatpp::data::share::MemoryLabel m_memoryLabel;
|
||||
|
@ -33,7 +33,7 @@ namespace oatpp { namespace utils { namespace random {
|
||||
oatpp::concurrency::SpinLock Random::RANDOM_LOCK;
|
||||
#endif
|
||||
|
||||
void Random::randomBytes(p_char8 buffer, v_int32 bufferSize) {
|
||||
void Random::randomBytes(p_char8 buffer, v_buff_size bufferSize) {
|
||||
|
||||
#if defined(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
|
||||
std::lock_guard<oatpp::concurrency::SpinLock> randomLock(RANDOM_LOCK);
|
||||
@ -41,7 +41,7 @@ void Random::randomBytes(p_char8 buffer, v_int32 bufferSize) {
|
||||
|
||||
std::uniform_int_distribution<size_t> distribution(0, 255);
|
||||
|
||||
for(v_int32 i = 0; i < bufferSize; i ++) {
|
||||
for(v_buff_size i = 0; i < bufferSize; i ++) {
|
||||
buffer[i] = (v_char8) distribution(RANDOM_GENERATOR);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
* @param buffer - pointer to buffer.
|
||||
* @param bufferSize - size of the buffer.
|
||||
*/
|
||||
static void randomBytes(p_char8 buffer, v_int32 bufferSize);
|
||||
static void randomBytes(p_char8 buffer, v_buff_size bufferSize);
|
||||
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace oatpp { namespace web { namespace mime { namespace multipart {
|
||||
Part::Part(const Headers &headers,
|
||||
const std::shared_ptr<data::stream::InputStream> &inputStream,
|
||||
const oatpp::String inMemoryData,
|
||||
data::v_io_size knownSize)
|
||||
v_int64 knownSize)
|
||||
: m_headers(headers)
|
||||
, m_inputStream(inputStream)
|
||||
, m_inMemoryData(inMemoryData)
|
||||
@ -59,7 +59,7 @@ Part::Part(const Headers& headers) : Part(headers, nullptr, nullptr, -1) {}
|
||||
|
||||
void Part::setDataInfo(const std::shared_ptr<data::stream::InputStream>& inputStream,
|
||||
const oatpp::String inMemoryData,
|
||||
data::v_io_size knownSize)
|
||||
v_int64 knownSize)
|
||||
{
|
||||
m_inputStream = inputStream;
|
||||
m_inMemoryData = inMemoryData;
|
||||
@ -106,7 +106,7 @@ oatpp::String Part::getInMemoryData() const {
|
||||
return m_inMemoryData;
|
||||
}
|
||||
|
||||
data::v_io_size Part::getKnownSize() const {
|
||||
v_int64 Part::getKnownSize() const {
|
||||
return m_knownSize;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
Headers m_headers;
|
||||
std::shared_ptr<data::stream::InputStream> m_inputStream;
|
||||
oatpp::String m_inMemoryData;
|
||||
data::v_io_size m_knownSize;
|
||||
v_int64 m_knownSize;
|
||||
private:
|
||||
const char* m_tagName;
|
||||
std::shared_ptr<oatpp::base::Countable> m_tagObject;
|
||||
@ -62,7 +62,7 @@ public:
|
||||
Part(const Headers& headers,
|
||||
const std::shared_ptr<data::stream::InputStream>& inputStream,
|
||||
const oatpp::String inMemoryData,
|
||||
data::v_io_size knownSize);
|
||||
v_int64 knownSize);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -78,7 +78,7 @@ public:
|
||||
*/
|
||||
void setDataInfo(const std::shared_ptr<data::stream::InputStream>& inputStream,
|
||||
const oatpp::String inMemoryData,
|
||||
data::v_io_size knownSize);
|
||||
v_int64 knownSize);
|
||||
|
||||
/**
|
||||
* Same as `setDataInfo(inputStream, nullptr, -1);.`
|
||||
@ -144,7 +144,7 @@ public:
|
||||
* Return known size of the part data.
|
||||
* @return - known size of the part data. `-1` - if size is unknown.
|
||||
*/
|
||||
data::v_io_size getKnownSize() const;
|
||||
v_int64 getKnownSize() const;
|
||||
|
||||
/**
|
||||
* Tag-object - object used to associate some data with the Part. <br>
|
||||
|
@ -164,9 +164,9 @@ Range Range::parse(oatpp::parser::Caret& caret) {
|
||||
auto endLabel = caret.putLabel();
|
||||
caret.findRN();
|
||||
endLabel.end();
|
||||
|
||||
oatpp::data::v_io_size start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData());
|
||||
oatpp::data::v_io_size end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData());
|
||||
|
||||
auto start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData());
|
||||
auto end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData());
|
||||
return Range(unitsLabel.toString(true), start, end);
|
||||
|
||||
}
|
||||
@ -225,9 +225,9 @@ ContentRange ContentRange::parse(oatpp::parser::Caret& caret) {
|
||||
caret.findRN();
|
||||
sizeLabel.end();
|
||||
|
||||
oatpp::data::v_io_size start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData());
|
||||
oatpp::data::v_io_size end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData());
|
||||
oatpp::data::v_io_size size = 0;
|
||||
v_int64 start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData());
|
||||
v_int64 end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData());
|
||||
v_int64 size = 0;
|
||||
bool isSizeKnown = false;
|
||||
if(sizeLabel.getData()[0] != '*') {
|
||||
isSizeKnown = true;
|
||||
|
@ -46,8 +46,8 @@ namespace {
|
||||
private:
|
||||
std::shared_ptr<Pipe> m_pipe;
|
||||
v_int64 m_chunksToTransfer;
|
||||
data::v_io_size m_position = 0;
|
||||
data::v_io_size m_transferedBytes = 0;
|
||||
v_buff_size m_position = 0;
|
||||
v_buff_size m_transferedBytes = 0;
|
||||
public:
|
||||
|
||||
WriterTask(const std::shared_ptr<Pipe>& pipe, v_int64 chunksToTransfer)
|
||||
|
@ -65,9 +65,9 @@ namespace {
|
||||
|
||||
oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->getData(), text->getSize());
|
||||
std::unique_ptr<v_char8> buffer(new v_char8[step]);
|
||||
v_int64 size;
|
||||
data::v_io_size size;
|
||||
while((size = stream.read(buffer.get(), step)) != 0) {
|
||||
parser.parseNext(buffer.get(), size);
|
||||
parser.parseNext(buffer.get(), (v_buff_size) size);
|
||||
}
|
||||
OATPP_ASSERT(parser.finished());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user