[prev in list] [next in list] [prev in thread] [next in thread]
List: sptk-commits
Subject: r1640 - in trunk: sptk4 src/utils
From: alexey () mail ! total-knowledge ! com
Date: 2011-09-28 3:15:48
Message-ID: courier.000000004E829164.00001531 () mail ! total-knowledge ! com
[Download RAW message or body]
Author: alexey
Date: 2011-09-27 20:15:47 -0700 (Tue, 27 Sep 2011)
New Revision: 1640
Modified:
trunk/sptk4/CBuffer.h
trunk/sptk4/CMemoryMappedFile.h
trunk/src/utils/CBuffer.cpp
trunk/src/utils/CMemoryMappedFile.cpp
Log:
Compilation fixes on Windows :(
Modified: trunk/sptk4/CBuffer.h
===================================================================
--- trunk/sptk4/CBuffer.h 2011-09-27 23:36:31 UTC (rev 1639)
+++ trunk/sptk4/CBuffer.h 2011-09-28 03:15:47 UTC (rev 1640)
@@ -55,8 +55,8 @@
{
protected:
- uint64_t m_size; ///< Allocated size of the buffer
- uint64_t m_bytes; ///< Actual size of the data in buffer
+ uint32_t m_size; ///< Allocated size of the buffer
+ uint32_t m_bytes; ///< Actual size of the data in buffer
char* m_buffer; ///< The buffer itself
#if HAVE_ZLIB
@@ -64,23 +64,23 @@
///
/// The compressed data is appended to the end of outBuffer.
/// @param data const char*, input data to compress
- /// @param size uint64_t, size of input data
+ /// @param size uint32_t, size of input data
/// @param outBuffer CBuffer&, output buffer
/// @param level int, compression level, (1..9), where 1 is fastest and 9 is \
smallest
- static void zlib_compress(const char* data, uint64_t size, CBuffer& outBuffer, \
int level) throw (std::exception); + static void zlib_compress(const char* data, \
uint32_t size, CBuffer& outBuffer, int level) throw (std::exception);
/// @brief Decompresses buffer into another buffer using ZLib
///
/// The decompressed data is appended to the end of outBuffer.
/// @param data const char*, input data to decompress
- /// @param size uint64_t, size of input data
+ /// @param size uint32_t, size of input data
/// @param outBuffer CBuffer&, output buffer
- static void zlib_decompress(const char* data, uint64_t size, CBuffer& outBuffer) \
throw (std::exception); + static void zlib_decompress(const char* data, uint32_t \
size, CBuffer& outBuffer) throw (std::exception); #endif
/// @brief Resizes current buffer
- /// @param sz uint64_t, required memory size
- virtual void adjustSize(uint64_t sz) throw(CMemoryAllocationException);
+ /// @param sz uint32_t, required memory size
+ virtual void adjustSize(uint32_t sz) throw(CMemoryAllocationException);
public:
@@ -99,8 +99,8 @@
///
/// Creates an empty buffer.
/// The return of the bytes() method will be 0.
- /// @param sz uint64_t, buffer size to be pre-allocated
- CBuffer(uint64_t sz=16);
+ /// @param sz uint32_t, buffer size to be pre-allocated
+ CBuffer(uint32_t sz=16);
/// @brief Constructor
///
@@ -124,8 +124,8 @@
/// The data is copied inside the buffer.
/// The return of the bytes() method will be the input data size.
/// @param data void * data buffer
- /// @param sz uint64_t, data buffer size
- CBuffer(const void *data, uint64_t sz);
+ /// @param sz uint32_t, data buffer size
+ CBuffer(const void *data, uint32_t sz);
/// @brief Copy constructor
///
@@ -163,8 +163,8 @@
/// @brief Checks if the current buffer size is enough
///
/// Allocates memory if needed.
- /// @param sz uint64_t, required memory size
- void checkSize(uint64_t sz) throw(CMemoryAllocationException)
+ /// @param sz uint32_t, required memory size
+ void checkSize(uint32_t sz) throw(CMemoryAllocationException)
{
if (sz > m_size)
adjustSize(sz);
@@ -174,9 +174,9 @@
///
/// Allocates memory if needed.
/// @param data const char*, external data buffer
- /// @param sz uint64_t, required memory size
+ /// @param sz uint32_t, required memory size
/// @returns success (true) or failure (false)
- void set(const void* data,uint64_t sz) throw(CMemoryAllocationException)
+ void set(const void* data,uint32_t sz) throw(CMemoryAllocationException)
{
checkSize(sz + 1);
if (data) {
@@ -222,15 +222,15 @@
///
/// Allocates memory if needed.
/// @param data const void*, external data buffer
- /// @param sz uint64_t, required memory size
- void append(const void* data, uint64_t sz) throw(CMemoryAllocationException);
+ /// @param sz uint32_t, required memory size
+ void append(const void* data, uint32_t sz) throw(CMemoryAllocationException);
/// @brief Appends the external data of size sz to the current buffer.
///
/// Allocated memory isn't checked. Application should call checkSize() to make \
sure the required size is there /// @param data const void*, external data buffer
- /// @param sz uint64_t, required memory size
- void appendNoCheck(const void* data, uint64_t sz);
+ /// @param sz uint32_t, required memory size
+ void appendNoCheck(const void* data, uint32_t sz);
/// @brief Appends a zero-terminated string to the current buffer.
///
@@ -247,7 +247,7 @@
/// @param str std::string, string to append
void append(const std::string& str) throw(CMemoryAllocationException)
{
- return append(str.c_str(),(uint64_t)str.length());
+ return append(str.c_str(), str.length());
}
/// @brief Appends the string to the current buffer.
@@ -262,8 +262,8 @@
/// @brief Truncates the current buffer to the size sz.
///
/// Resizes memory if needed.
- /// @param sz uint64_t, the required data size in bytes
- void reset(uint64_t sz=0) throw(CMemoryAllocationException);
+ /// @param sz uint32_t, the required data size in bytes
+ void reset(uint32_t sz=0) throw(CMemoryAllocationException);
/// @brief Fills the bytes() characters in buffer with character ch.
/// @param ch the character to fill the buffer
@@ -271,21 +271,21 @@
/// @brief Returns the size of memory allocated for the data buffer
/// @returns buffer size
- uint64_t size() const
+ uint32_t size() const
{
return m_size;
}
/// @brief Returns the size of data in the data buffer
/// @returns data size
- uint64_t bytes() const
+ uint32_t bytes() const
{
return m_bytes;
}
/// @brief Returns the size of data in the data buffer
/// @returns data size
- uint64_t length() const
+ uint32_t length() const
{
return m_bytes;
}
@@ -294,22 +294,22 @@
///
/// Simply sets the number of bytes counter in the buffer.
/// Doesn't check or reallocate memory so use it with caution.
- /// @param b uint64_t, the new size of the buffer
- void bytes(uint64_t b)
+ /// @param b uint32_t, the new size of the buffer
+ void bytes(uint32_t b)
{
m_bytes = b;
}
/// @brief Access the chars by index
- /// @param index uint64_t, character index
- char& operator[](uint64_t index)
+ /// @param index uint32_t, character index
+ char& operator[](uint32_t index)
{
return m_buffer[index];
}
/// @brief Access the chars by index, const version
- /// @param index uint64_t, character index
- const char& operator[](uint64_t index) const
+ /// @param index uint32_t, character index
+ const char& operator[](uint32_t index) const
{
return m_buffer[index];
}
@@ -397,21 +397,21 @@
/// The compressed data is appended to the end of outBuffer.
/// Compression level is only used for ZLib compression.
/// @param data const char*, input data to compress
- /// @param size uint64_t, size of input data
+ /// @param size uint32_t, size of input data
/// @param outBuffer CBuffer&, output buffer
/// @param level int, compression level, (1..9), where 1 is fastest and 9 is \
smallest /// @param compressMethod CompressMethod, compress method
- static void compress(const char* data, uint64_t size, CBuffer& outBuffer, int \
level, CompressMethod compressMethod) throw (std::exception); + static void \
compress(const char* data, uint32_t size, CBuffer& outBuffer, int level, \
CompressMethod compressMethod) throw (std::exception);
/// @brief Decompresses buffer into another buffer
///
/// The decompressed data is appended to the end of outBuffer.
/// Compression method must be the same that used for compression of this data.
/// @param data const char*, input data to decompress
- /// @param size uint64_t, size of input data
+ /// @param size uint32_t, size of input data
/// @param outBuffer CBuffer&, output buffer
/// @param compressMethod CompressMethod, compression method
- static void decompress(const char* data, uint64_t size, CBuffer& outBuffer, \
CompressMethod compressMethod) throw (std::exception); + static void \
decompress(const char* data, uint32_t size, CBuffer& outBuffer, CompressMethod \
compressMethod) throw (std::exception);
/// @brief Compresses the buffer content
///
@@ -434,9 +434,9 @@
/// If the stream is in hex mode (stream << hex) then prints a hexadecimal dump \
into the stream. /// Otherwise, just prints buffer data a a string.
/// @param stream std::ostream&, stream to print into
- /// @param offset uint64_t, starting offset in the buffer
- /// @param bytes uint64_t, maximum number of bytes from the buffer
- void printState(std::ostream& stream, uint64_t offset, uint64_t bytes) const;
+ /// @param offset uint32_t, starting offset in the buffer
+ /// @param bytes uint32_t, maximum number of bytes from the buffer
+ void printState(std::ostream& stream, uint32_t offset, uint32_t bytes) const;
};
/// @brief Outputs the buffer into the stream
Modified: trunk/sptk4/CMemoryMappedFile.h
===================================================================
--- trunk/sptk4/CMemoryMappedFile.h 2011-09-27 23:36:31 UTC (rev 1639)
+++ trunk/sptk4/CMemoryMappedFile.h 2011-09-28 03:15:47 UTC (rev 1640)
@@ -63,16 +63,16 @@
protected:
/// @brief Resizes current buffer (blocked)
- /// @param sz uint64_t, required memory size
- virtual void adjustSize(uint64_t sz) throw (CMemoryAllocationException);
+ /// @param sz uint32_t, required memory size
+ virtual void adjustSize(uint32_t sz) throw (CMemoryAllocationException);
/// @brief Opens the file
/// @param fileName std::string, Memory-mapped file name
- /// @param size uint64_t, Memory-mapped file size
- void openFile(std::string fileName, uint64_t size) throw (std::exception);
+ /// @param size uint32_t, Memory-mapped file size
+ void openFile(std::string fileName, uint32_t size) throw (std::exception);
- /// @param size uint64_t, Memory-mapped file size
- void createFileMapping(uint64_t size) throw (std::exception);
+ /// @param size uint32_t, Memory-mapped file size
+ void createFileMapping(uint32_t size) throw (std::exception);
public:
/// @brief Constructor
@@ -86,8 +86,8 @@
/// If size is 0 and file already exists, then size would take the size of
/// the existing file.
/// @param fileName std::string, Memory-mapped file name
- /// @param size uint64_t, Memory-mapped file size
- virtual void open(std::string fileName, uint64_t size) throw (std::exception);
+ /// @param size uint32_t, Memory-mapped file size
+ virtual void open(std::string fileName, uint32_t size) throw (std::exception);
/// @brief Syncs memory-mapped file to disk
/// @param async bool, If true then sync starts but doesn't wait to complete
Modified: trunk/src/utils/CBuffer.cpp
===================================================================
--- trunk/src/utils/CBuffer.cpp 2011-09-27 23:36:31 UTC (rev 1639)
+++ trunk/src/utils/CBuffer.cpp 2011-09-28 03:15:47 UTC (rev 1640)
@@ -50,7 +50,7 @@
using namespace std;
using namespace sptk;
-CBuffer::CBuffer(uint64_t sz)
+CBuffer::CBuffer(uint32_t sz)
{
m_buffer = (char *) malloc(sz + 1);
if (m_buffer) {
@@ -61,7 +61,7 @@
m_bytes = 0;
}
-CBuffer::CBuffer(const void *data, uint64_t sz)
+CBuffer::CBuffer(const void *data, uint32_t sz)
{
m_buffer = (char *) malloc(sz + 1);
if (m_buffer) {
@@ -76,7 +76,7 @@
CBuffer::CBuffer(const char *str)
{
- uint64_t sz = (uint64_t) strlen(str) + 1;
+ uint32_t sz = strlen(str) + 1;
m_buffer = (char *) malloc(sz);
if (m_buffer) {
memcpy(m_buffer, str, sz);
@@ -90,7 +90,7 @@
CBuffer::CBuffer(const string& str)
{
- uint64_t sz = (uint64_t) str.length() + 1;
+ uint32_t sz = str.length() + 1;
m_buffer = (char *) malloc(sz);
if (m_buffer) {
if (sz > 1)
@@ -107,7 +107,7 @@
CBuffer::CBuffer(const CBuffer& buffer)
{
- uint64_t sz = buffer.bytes() + 1;
+ uint32_t sz = buffer.bytes() + 1;
m_buffer = (char *) malloc(sz);
if (m_buffer) {
memcpy(m_buffer, buffer.data(), sz);
@@ -119,9 +119,9 @@
}
}
-void CBuffer::adjustSize(uint64_t sz) throw (CMemoryAllocationException)
+void CBuffer::adjustSize(uint32_t sz) throw (CMemoryAllocationException)
{
- uint64_t newSize = sz / 2 * 3 + 16;
+ uint32_t newSize = sz / 2 * 3 + 16;
char *p = (char *) realloc(m_buffer, newSize);
if (!p)
throw CMemoryAllocationException("Can't reallocate a buffer");
@@ -136,7 +136,7 @@
m_bytes++;
}
-void CBuffer::append(const void* data, uint64_t sz) throw \
(CMemoryAllocationException) +void CBuffer::append(const void* data, uint32_t sz) \
throw (CMemoryAllocationException) {
checkSize(m_bytes + sz + 1);
memcpy(m_buffer + m_bytes, data, sz);
@@ -149,9 +149,9 @@
memset(m_buffer, c, m_size);
}
-void CBuffer::reset(uint64_t sz) throw (CMemoryAllocationException)
+void CBuffer::reset(uint32_t sz) throw (CMemoryAllocationException)
{
- uint64_t newSize = sz + 1;
+ uint32_t newSize = sz + 1;
if (newSize < 16)
newSize = 16;
@@ -179,7 +179,7 @@
reset(size + 1);
m_buffer[size] = 0;
- m_bytes = (uint64_t) fread(m_buffer, 1, size, f);
+ m_bytes = fread(m_buffer, 1, size, f);
fclose(f);
}
@@ -205,7 +205,7 @@
CBuffer& CBuffer::operator =(const string& str) throw (CMemoryAllocationException)
{
- uint64_t sz = (uint64_t) str.length();
+ uint32_t sz = str.length();
checkSize(sz + 1);
if (sz)
memcpy(m_buffer, str.c_str(), sz + 1);
@@ -215,7 +215,7 @@
CBuffer& CBuffer::operator =(const char *str) throw (CMemoryAllocationException)
{
- uint64_t sz = (uint64_t) strlen(str);
+ uint32_t sz = strlen(str);
checkSize(sz + 1);
if (sz)
memcpy(m_buffer, str, sz + 1);
@@ -225,13 +225,13 @@
string CBuffer::toHex() const
{
- uint64_t bytes(m_bytes * 2);
+ uint32_t bytes(m_bytes * 2);
string result;
result.resize(bytes);
char *ptr = (char*) result.c_str();
- for (uint64_t i = 0; i < m_bytes; i++) {
+ for (uint32_t i = 0; i < m_bytes; i++) {
#ifdef WIN32
_snprintf(ptr, 3, "%02X", int(m_buffer[i]));
#else
@@ -245,7 +245,7 @@
void CBuffer::fromHex(const string& hexData)
{
- uint64_t bytes = hexData.length() / 2;
+ uint32_t bytes = hexData.length() / 2;
const char *ptr = hexData.c_str();
checkSize(bytes);
char convertBuffer[3] = { 0, 0, 0 };
@@ -253,7 +253,7 @@
ptr += 2;
bytes -= 2;
}
- for (uint64_t i = 0; i < bytes; i++) {
+ for (uint32_t i = 0; i < bytes; i++) {
convertBuffer[0] = *ptr++;
convertBuffer[1] = *ptr++;
m_buffer[i] = (uint8_t) strtol(convertBuffer, NULL, 16);
@@ -261,14 +261,14 @@
m_bytes = bytes;
}
-void CBuffer::printState(ostream& stream, uint64_t _offset, uint64_t _bytes) const
+void CBuffer::printState(ostream& stream, uint32_t _offset, uint32_t _bytes) const
{
- uint64_t startOffset = _offset / 16 * 16;
+ uint32_t startOffset = _offset / 16 * 16;
_bytes += _offset - startOffset;
if (_bytes > bytes())
_bytes = bytes();
- for (uint64_t offset = startOffset; offset < _bytes; offset += 16) {
- uint64_t eob = offset + 16;
+ for (uint32_t offset = startOffset; offset < _bytes; offset += 16) {
+ uint32_t eob = offset + 16;
if (offset % 16 == 0) {
if (offset)
@@ -278,20 +278,20 @@
stream << right << offset << " ";
}
- for (uint64_t i = offset; i < eob; i++ ) {
+ for (uint32_t i = offset; i < eob; i++ ) {
if (i % 4 == 0)
stream << " ";
if (i < _bytes) {
stream.fill('0');
stream.width(2);
- stream << uint64_t((uint8_t)m_buffer[i]) << " ";
+ stream << uint32_t((uint8_t)m_buffer[i]) << " ";
} else
stream << " ";
}
stream << " ";
- for (uint64_t i = offset; i < eob; i++ ) {
+ for (uint32_t i = offset; i < eob; i++ ) {
if (i < _bytes) {
char pchar = m_buffer[i];
if (!isprint(pchar))
@@ -306,7 +306,7 @@
#define CHUNK 16384
-void CBuffer::zlib_compress(const char* data, uint64_t size, CBuffer& outBuffer, int \
level) throw (exception) +void CBuffer::zlib_compress(const char* data, uint32_t \
size, CBuffer& outBuffer, int level) throw (exception) {
int flush;
unsigned have;
@@ -324,10 +324,10 @@
throw CException("Can't init zlib deflate");
/* compress until end of buffer */
- uint64_t pos = 0;
- uint64_t total = size;
+ uint32_t pos = 0;
+ uint32_t total = size;
do {
- uint64_t chunk = total - pos;
+ uint32_t chunk = total - pos;
if (chunk > CHUNK)
chunk = CHUNK;
strm.avail_in = chunk;
@@ -353,7 +353,7 @@
deflateEnd(&strm);
}
-void CBuffer::zlib_decompress(const char* data, uint64_t size, CBuffer& outBuffer) \
throw (exception) +void CBuffer::zlib_decompress(const char* data, uint32_t size, \
CBuffer& outBuffer) throw (exception) {
int ret, flush;
unsigned have;
@@ -371,10 +371,10 @@
throw CException("Can't init zlib inflate");
/* compress until end of buffer */
- uint64_t pos = 0;
- uint64_t total = size;
+ uint32_t pos = 0;
+ uint32_t total = size;
do {
- uint64_t chunk = total - pos;
+ uint32_t chunk = total - pos;
if (chunk > CHUNK)
chunk = CHUNK;
strm.avail_in = chunk;
@@ -410,7 +410,7 @@
#endif
-void CBuffer::compress(const char* data, uint64_t size, CBuffer& outBuffer, int \
level, CompressMethod compressMethod) throw (std::exception) +void \
CBuffer::compress(const char* data, uint32_t size, CBuffer& outBuffer, int level, \
CompressMethod compressMethod) throw (std::exception) {
switch (compressMethod) {
case NOT_COMPRESSED:
@@ -430,7 +430,7 @@
}
}
-void CBuffer::decompress(const char* data, uint64_t size, CBuffer& outBuffer, \
CompressMethod compressMethod) throw (std::exception) +void CBuffer::decompress(const \
char* data, uint32_t size, CBuffer& outBuffer, CompressMethod compressMethod) throw \
(std::exception) {
switch (compressMethod) {
case NOT_COMPRESSED:
@@ -473,8 +473,8 @@
void CBuffer::swap(CBuffer& another)
{
- uint64_t tmp_size = m_size;
- uint64_t tmp_bytes = m_bytes;
+ uint32_t tmp_size = m_size;
+ uint32_t tmp_bytes = m_bytes;
char* tmp_buffer = m_buffer;
m_size = another.m_size;
Modified: trunk/src/utils/CMemoryMappedFile.cpp
===================================================================
--- trunk/src/utils/CMemoryMappedFile.cpp 2011-09-27 23:36:31 UTC (rev 1639)
+++ trunk/src/utils/CMemoryMappedFile.cpp 2011-09-28 03:15:47 UTC (rev 1640)
@@ -65,7 +65,7 @@
close();
}
-void CMemoryMappedFile::openFile(std::string fileName, uint64_t size) throw \
(exception) +void CMemoryMappedFile::openFile(std::string fileName, uint32_t size) \
throw (exception) {
if (m_file != INVALID_HANDLE_VALUE)
close();
@@ -99,7 +99,7 @@
SYSTEM_EXCEPTION("Can't open or create file " << fileName);
}
-void CMemoryMappedFile::createFileMapping(uint64_t size) throw (std::exception)
+void CMemoryMappedFile::createFileMapping(uint32_t size) throw (std::exception)
{
#ifndef WIN32
if (size == 0) {
@@ -130,7 +130,7 @@
}
-void CMemoryMappedFile::open(std::string fileName, uint64_t size) throw \
(std::exception) +void CMemoryMappedFile::open(std::string fileName, uint32_t size) \
throw (std::exception) {
try {
openFile(fileName, size);
@@ -148,7 +148,7 @@
return m_file != INVALID_HANDLE_VALUE;
}
-void CMemoryMappedFile::adjustSize(uint64_t size) throw (CMemoryAllocationException)
+void CMemoryMappedFile::adjustSize(uint32_t size) throw (CMemoryAllocationException)
{
size = size / 10 * 11; // Allocating 10% more than requested
if (size < 128)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic