فهرست منبع

Switch streams to lowercase_naming

Daniele Bartolini 13 سال پیش
والد
کامیت
ec50a5b133

+ 1 - 1
src/Filesystem.cpp

@@ -251,7 +251,7 @@ Stream* Filesystem::OpenStream(const char* relativePath, StreamOpenMode openMode
 	{
 		Log::D("Filesystem::OpenStream: Found %s", info.osPath.c_str());
 
-		stream = new FileStream(openMode, info.osPath);
+		stream = new FileStream(openMode, info.osPath.c_str());
 
 		return stream;
 	}

+ 1 - 1
src/Font.cpp

@@ -63,7 +63,7 @@ void Font::LoadFromFile(const Str& filename)
 		TextReader textReader(fontDef);
 		char buf[1024];
 
-		while (textReader.ReadString(buf, 1024) != NULL)
+		while (textReader.read_string(buf, 1024) != NULL)
 		{
 			int32_t ch;
 			float a, b, c, d, e, f, g, h;

+ 25 - 18
src/core/streams/File.cpp

@@ -30,38 +30,44 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
+//-----------------------------------------------------------------------------
 File::File() :
-	mFileHandle(0), mMode(FOM_READ)
+	m_file_handle(0), m_mode(FOM_READ)
 {
 }
 
+//-----------------------------------------------------------------------------
 File::~File()
 {
-	if (mFileHandle != 0)
+	if (m_file_handle != 0)
 	{
-		fclose(mFileHandle);
+		fclose(m_file_handle);
 	}
 }
 
-bool File::IsValid()
+//-----------------------------------------------------------------------------
+bool File::is_valid()
 {
-	return mFileHandle != 0;
+	return m_file_handle != 0;
 }
 
-FileOpenMode File::GetMode()
+//-----------------------------------------------------------------------------
+FileOpenMode File::mode()
 {
-	return mMode;
+	return m_mode;
 }
 
-FILE* File::GetHandle()
+//-----------------------------------------------------------------------------
+FILE* File::get_handle()
 {
-	return mFileHandle;
+	return m_file_handle;
 }
 
-File* File::Open(const char* path, FileOpenMode mode)
+//-----------------------------------------------------------------------------
+File* File::open(const char* path, FileOpenMode mode)
 {
 	File* f = new File();
-	f->mFileHandle = fopen(path, 
+	f->m_file_handle = fopen(path, 
 
 	/*
 		TestFlag(mode, FOM_READ) ?
@@ -72,23 +78,24 @@ File* File::Open(const char* path, FileOpenMode mode)
 	math::test_bitmask(mode, FOM_READ) ?
 		(math::test_bitmask(mode, FOM_WRITE) ? "rb+" : "rb") : (math::test_bitmask(mode, FOM_WRITE) ? "wb" : "rb")); 
 
-	if (f->mFileHandle == 0)
+	if (f->m_file_handle == NULL)
 	{
 		Log::E("File::Open: Could not open file %s", path);
 		return NULL;
 	}
 
-	f->mMode = mode;
+	f->m_mode = mode;
 
 	return f;
 }
 
-size_t File::GetSize()
+//-----------------------------------------------------------------------------
+size_t File::size()
 {
-	size_t pos = ftell(mFileHandle);
-	fseek(mFileHandle, 0, SEEK_END);
-	size_t size = ftell(mFileHandle);
-	fseek(mFileHandle, pos, SEEK_SET);
+	size_t pos = ftell(m_file_handle);
+	fseek(m_file_handle, 0, SEEK_END);
+	size_t size = ftell(m_file_handle);
+	fseek(m_file_handle, pos, SEEK_SET);
 
 	return size;
 }

+ 7 - 7
src/core/streams/File.h

@@ -50,18 +50,18 @@ public:
 
 	virtual				~File();
 
-	bool				IsValid();
+	bool				is_valid();
 
-	FileOpenMode		GetMode();
-	FILE*				GetHandle();
-	size_t				GetSize();
+	FileOpenMode		mode();
+	FILE*				get_handle();
+	size_t				size();
 
-	static File*		Open(const char* path, FileOpenMode mode);
+	static File*		open(const char* path, FileOpenMode mode);
 
 private:
 
-	FILE*				mFileHandle;
-	FileOpenMode		mMode;
+	FILE*				m_file_handle;
+	FileOpenMode		m_mode;
 
 						File();
 };

+ 97 - 69
src/core/streams/FileStream.cpp

@@ -31,68 +31,72 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-FileStream::FileStream(StreamOpenMode openMode, const Str& filename) :
-	Stream(openMode), mFile(0),
-	mLastWasRead(true)
+//-----------------------------------------------------------------------------
+FileStream::FileStream(StreamOpenMode mode, const char* filename) :
+	Stream(mode), m_file(NULL),
+	m_last_was_read(true)
 {
 	//Takes ownership
-	FileOpenMode fileOpenMode = (FileOpenMode)0;
+	FileOpenMode file_open_mode = (FileOpenMode)0;
 
-	if (math::test_bitmask(openMode, SOM_READ))
-		fileOpenMode = (FileOpenMode)(fileOpenMode | FOM_READ);
-	if (math::test_bitmask(openMode, SOM_WRITE))
-		fileOpenMode = (FileOpenMode)(fileOpenMode | FOM_WRITE);
+	if (math::test_bitmask(mode, SOM_READ))
+		file_open_mode = (FileOpenMode)(file_open_mode | FOM_READ);
+	if (math::test_bitmask(mode, SOM_WRITE))
+		file_open_mode = (FileOpenMode)(file_open_mode | FOM_WRITE);
 
-	mFile = File::Open(filename.c_str(), fileOpenMode);
+	m_file = File::open(filename, file_open_mode);
 }
 
+//-----------------------------------------------------------------------------
 FileStream::~FileStream()
 {
-	delete mFile;
-	mFile = 0;
+	delete m_file;
+
+	m_file = 0;
 }
 
-uint8_t FileStream::ReadByte()
+//-----------------------------------------------------------------------------
+uint8_t FileStream::read_byte()
 {
-	CheckValid();
+	check_valid();
 
-	if (!mLastWasRead)
+	if (!m_last_was_read)
 	{
-		mLastWasRead = true;
-		fseek(mFile->GetHandle(), 0, SEEK_CUR);
+		m_last_was_read = true;
+		fseek(m_file->get_handle(), 0, SEEK_CUR);
 	}
 
 	uint8_t buffer;
 
-	if (fread(&buffer, 1, 1, mFile->GetHandle()) != 1)
+	if (fread(&buffer, 1, 1, m_file->get_handle()) != 1)
 	{
 		Log::E("Could not read from file.");
-		throw FileIOException("Could not read from file.");
 	}
 
 	return buffer;
 }
 
-void FileStream::ReadDataBlock(void* buffer, size_t size)
+//-----------------------------------------------------------------------------
+void FileStream::read_data_block(void* buffer, size_t size)
 {
-	CheckValid();
+	check_valid();
 
-	if (!mLastWasRead)
+	if (!m_last_was_read)
 	{
-		mLastWasRead = true;
-		fseek(mFile->GetHandle(), 0, SEEK_CUR);
+		m_last_was_read = true;
+		fseek(m_file->get_handle(), 0, SEEK_CUR);
 	}
 
-	if (fread(buffer, size, 1, mFile->GetHandle()) != 1)
+	if (fread(buffer, size, 1, m_file->get_handle()) != 1)
 	{
 		Log::E("Could not read from file.");
-		throw FileIOException("Could not read from file.");
 	}
 }
 
-bool FileStream::CopyTo(Stream* stream, size_t size)
+//-----------------------------------------------------------------------------
+bool FileStream::copy_to(Stream* stream, size_t size)
 {
-	CheckValid();
+	check_valid();
 
 	if (stream == 0)
 		return false;
@@ -109,15 +113,15 @@ bool FileStream::CopyTo(Stream* stream, size_t size)
 	{
 		int32_t readBytes;
 		int32_t expectedReadBytes = math::min(size - totReadBytes, chunksize);
-		readBytes = fread(buff, 1, expectedReadBytes, mFile->GetHandle());
+		readBytes = fread(buff, 1, expectedReadBytes, m_file->get_handle());
 
 		if (readBytes < expectedReadBytes)
 		{
-			if (feof(mFile->GetHandle()))
+			if (feof(m_file->get_handle()))
 			{
 				if (readBytes != 0)
 				{
-					stream->WriteDataBlock(buff, readBytes);
+					stream->write_data_block(buff, readBytes);
 				}
 			}
 
@@ -126,7 +130,7 @@ bool FileStream::CopyTo(Stream* stream, size_t size)
 			return false;
 		}
 
-		stream->WriteDataBlock(buff, readBytes);
+		stream->write_data_block(buff, readBytes);
 		totReadBytes += readBytes;
 	}
 
@@ -134,88 +138,112 @@ bool FileStream::CopyTo(Stream* stream, size_t size)
 	return true;
 }
 
-bool FileStream::EndOfStream() const
+//-----------------------------------------------------------------------------
+bool FileStream::end_of_stream() const
+{
+	return position() == size();
+}
+
+//-----------------------------------------------------------------------------
+bool FileStream::is_valid() const
 {
-	return GetPosition() == GetSize();
+	{
+		if (!m_file)
+		{
+			return false;
+		}
+
+		return m_file->is_valid();
+	}
 }
 
-void FileStream::WriteByte(uint8_t val)
+//-----------------------------------------------------------------------------
+void FileStream::write_byte(uint8_t val)
 {
-	CheckValid();
+	check_valid();
 
-	if (mLastWasRead)
+	if (m_last_was_read)
 	{
-		mLastWasRead = false;
-		fseek(mFile->GetHandle(), 0, SEEK_CUR);
+		m_last_was_read = false;
+		fseek(m_file->get_handle(), 0, SEEK_CUR);
 	}
 
-	if (fputc(val, mFile->GetHandle()) == EOF)
+	if (fputc(val, m_file->get_handle()) == EOF)
 	{
 		Log::E("Could not write to file.");
-		throw FileIOException("Could not write to file.");
 	}
 }
 
-void FileStream::WriteDataBlock(const void* buffer, size_t size)
+//-----------------------------------------------------------------------------
+void FileStream::write_data_block(const void* buffer, size_t size)
 {
-	CheckValid();
+	check_valid();
 
-	if (mLastWasRead)
+	if (m_last_was_read)
 	{
-		mLastWasRead = false;
-		fseek(mFile->GetHandle(), 0, SEEK_CUR);
+		m_last_was_read = false;
+		fseek(m_file->get_handle(), 0, SEEK_CUR);
 	}
 
-	if (fwrite(buffer, size, 1, mFile->GetHandle()) != 1)
+	if (fwrite(buffer, size, 1, m_file->get_handle()) != 1)
 	{
 		Log::E("Could not write to file.");
-		throw FileIOException("Could not write to file.");
 	}
 }
 
-void FileStream::Flush()
+//-----------------------------------------------------------------------------
+void FileStream::flush()
 {
-	CheckValid();
-	fflush(mFile->GetHandle());
+	check_valid();
+	fflush(m_file->get_handle());
 }
 
-void FileStream::Seek(int32_t newPos, SeekMode mode)
+//-----------------------------------------------------------------------------
+void FileStream::seek(int32_t position, SeekMode mode)
 {
-	CheckValid();
+	check_valid();
 	//flush(); <<<---?
-	fseek(mFile->GetHandle(), newPos, (mode==SM_SeekFromBegin)?SEEK_SET:(mode==SM_SeekFromCurrent)?SEEK_CUR:SEEK_END);
+	fseek(m_file->get_handle(), position, (mode==SM_FROM_BEGIN)?SEEK_SET:(mode==SM_FROM_CURRENT)?SEEK_CUR:SEEK_END);
 }
 
-size_t FileStream::GetPosition() const
+//-----------------------------------------------------------------------------
+size_t FileStream::position() const
 {
-	CheckValid();
-	return ftell(mFile->GetHandle());
+	check_valid();
+	return ftell(m_file->get_handle());
 }
 
-size_t FileStream::GetSize() const
+//-----------------------------------------------------------------------------
+size_t FileStream::size() const
 {
-	size_t pos = GetPosition();
-	fseek(mFile->GetHandle(), 0, SEEK_END);
-	size_t size = GetPosition();
-	fseek(mFile->GetHandle(), pos, SEEK_SET);
+	size_t pos = position();
+	fseek(m_file->get_handle(), 0, SEEK_END);
+	size_t size = position();
+	fseek(m_file->get_handle(), pos, SEEK_SET);
 	return size;
 }
 
-bool FileStream::CanRead() const
+//-----------------------------------------------------------------------------
+bool FileStream::can_read() const
 {
-	CheckValid();
-	return Stream::CanRead();
+	check_valid();
+
+	return true;
 }
 
-bool FileStream::CanWrite() const
+//-----------------------------------------------------------------------------
+bool FileStream::can_write() const
 {
-	CheckValid();
-	return Stream::CanWrite();
+	check_valid();
+
+	return true;
 }
 
-bool FileStream::CanSeek() const
+//-----------------------------------------------------------------------------
+bool FileStream::can_seek() const
 {
 	return true;
 }
 
-}
+} // namespace crown
+

+ 22 - 35
src/core/streams/FileStream.h

@@ -26,9 +26,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Stream.h"
-#include "Exceptions.h"
 #include "File.h"
-#include "Str.h"
+#include <cassert>
 
 namespace crown
 {
@@ -49,62 +48,50 @@ public:
 					@param openMode
 						The mode of access
 					*/
-					FileStream(StreamOpenMode openMode, const Str& filename);
+					FileStream(StreamOpenMode mode, const char* filename);
 					/**
 						Destructor
 					*/
 	virtual			~FileStream();
 					/** @copydoc Stream::Seek() */
-	void			Seek(int32_t newPos, SeekMode mode);
+	void			seek(int32_t position, SeekMode mode);
 					/** @copydoc Stream::ReadByte() */
-	uint8_t			ReadByte();
+	uint8_t			read_byte();
 					/** @copydoc Stream::ReadDataBlock() */
-	void			ReadDataBlock(void* buffer, size_t size);
+	void			read_data_block(void* buffer, size_t size);
 					/** @copydoc Stream::CopyTo() */
-	bool			CopyTo(Stream* stream, size_t size = 0);
+	bool			copy_to(Stream* stream, size_t size = 0);
 					/** @copydoc Stream::WriteByte() */
-	void			WriteByte(uint8_t val);
+	void			write_byte(uint8_t val);
 					/** @copydoc Stream::WriteDataBlock() */
-	void			WriteDataBlock(const void* buffer, size_t size);
+	void			write_data_block(const void* buffer, size_t size);
 					/** @copydoc Stream::Flush() */
-	void			Flush();
+	void			flush();
 					/** @copydoc Stream::EndOfStream() */
-	bool			EndOfStream() const;
-					/** @copydoc Stream::IsValid() */
-	bool			IsValid() const
-					{
-						if (!mFile)
-						{
-							return false;
-						}
-
-						return mFile->IsValid();
-					}
-
+	bool			end_of_stream() const;
+					/** @copydoc Stream::is_valid() */
+	bool			is_valid() const;
 					/** @copydoc Stream::GetSize() */
-	size_t			GetSize() const;
+	size_t			size() const;
 					/** @copydoc Stream::GetPosition() */
-	size_t			GetPosition() const;
+	size_t			position() const;
 					/** @copydoc Stream::CanRead() */
-	bool			CanRead() const;
+	bool			can_read() const;
 					/** @copydoc Stream::CanWrite() */
-	bool			CanWrite() const;
+	bool			can_write() const;
 					/** @copydoc Stream::CanSeek() */
-	bool			CanSeek() const;
+	bool			can_seek() const;
 
 protected:
 
-	File*			mFile;
-	bool			mLastWasRead;
+	File*			m_file;
+	bool			m_last_was_read;
 
-	inline void CheckValid() const
+	inline void check_valid() const
 	{
-		if (!mFile)
-		{
-			throw InvalidOperationException("Can't operate on an invalid FileStream");
-		}
+		assert(m_file != NULL);
 	}
 };
 
-}
+} // namespace crown
 

+ 77 - 77
src/core/streams/MemoryStream.cpp

@@ -29,179 +29,179 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "MathUtils.h"
 #include "Log.h"
 #include "Types.h"
+#include "Allocator.h"
 
 namespace crown
 {
 
+//-----------------------------------------------------------------------------
 MemoryBuffer::MemoryBuffer()
 {
 }
 
+//-----------------------------------------------------------------------------
 MemoryBuffer::~MemoryBuffer()
 {
 }
 
-DynamicMemoryBuffer::DynamicMemoryBuffer(size_t initialCapacity)
+//-----------------------------------------------------------------------------
+DynamicMemoryBuffer::DynamicMemoryBuffer(Allocator& allocator, size_t initial_capacity) :
+	m_allocator(&allocator),
+	m_buffer(NULL)
 {
-	mBuff = 0;
-	Allocate(initialCapacity);
+	m_buffer = (uint8_t*)m_allocator->allocate(initial_capacity);
 }
 
+//-----------------------------------------------------------------------------
 DynamicMemoryBuffer::~DynamicMemoryBuffer()
 {
-	Release();
-}
-
-void DynamicMemoryBuffer::Allocate(size_t capacity)
-{
-	Release();
-	mBuff = new uint8_t[capacity];
-	this->mCapacity = capacity;
-	mSize = 0;
-}
-
-void DynamicMemoryBuffer::Release()
-{
-	if (mBuff != 0)
+	if (m_buffer)
 	{
-		delete[] mBuff;
-		mBuff = 0;
+		m_allocator->deallocate(m_buffer);
 	}
 }
 
-void DynamicMemoryBuffer::CheckSpace(size_t offset, size_t size)
+//-----------------------------------------------------------------------------
+void DynamicMemoryBuffer::check_space(size_t offset, size_t size)
 {
-	if (offset + size > mCapacity)
+	if (offset + size > m_capacity)
 	{
-		mCapacity = (size_t) ((offset + size) * 1.2f);
-		mBuff = (uint8_t*) realloc(mBuff, mCapacity);
+		m_capacity = (size_t) ((offset + size) * 1.2f);
+		// FIXME FIXME FIXME
+		m_buffer = (uint8_t*) realloc(m_buffer, m_capacity);
 	}
 }
 
-void DynamicMemoryBuffer::Write(uint8_t* src, size_t offset, size_t size)
+//-----------------------------------------------------------------------------
+void DynamicMemoryBuffer::write(uint8_t* src, size_t offset, size_t size)
 {
-	CheckSpace(offset, size);
+	check_space(offset, size);
 
-	for (size_t i=0; i<size; i++)
+	for (size_t i = 0; i < size; i++)
 	{
-		mBuff[offset+i] = src[i];
+		m_buffer[offset + i] = src[i];
 	}
 
 	//If the writing goes beyond the end of buffer
-	if (offset + size > this->mSize)
+	if (offset + size > this->m_size)
 	{
-		this->mSize = offset + size;
+		this->m_size = offset + size;
 	}
 }
 
-MemoryStream::MemoryStream(MemoryBuffer* f, StreamOpenMode openMode) :
-	Stream(openMode)
+//-----------------------------------------------------------------------------
+MemoryStream::MemoryStream(MemoryBuffer* buffer, StreamOpenMode mode) :
+	Stream(mode),
+	m_memory(buffer),
+	m_memory_offset(0)
 {
-	mMem = f;
-	mMemOffset = 0;
 }
 
+//-----------------------------------------------------------------------------
 MemoryStream::~MemoryStream()
 {
-	if (mMem)
-	{
-		delete mMem;
-		mMem = 0;
-	}
 }
 
-void MemoryStream::Seek(int32_t newPos, SeekMode mode)
+//-----------------------------------------------------------------------------
+void MemoryStream::seek(int32_t position, SeekMode mode)
 {
-	CheckValid();
+	check_valid();
 	
 	switch (mode)
 	{
-		case SM_SeekFromBegin:
-			mMemOffset = newPos;
+		case SM_FROM_BEGIN:
+			m_memory_offset = position;
 			break;
-		case SM_SeekFromCurrent:
-			mMemOffset += newPos;
+		case SM_FROM_CURRENT:
+			m_memory_offset += position;
 			break;
-		case SM_SeekFromEnd:
-			mMemOffset = mMem->GetSize()-1;
+		case SM_FROM_END:
+			m_memory_offset = m_memory->size()-1;
 			break;
 	}
 
-	//Allow seek to mMem->getSize() position, that means end of stream, reading not allowed but you can write if it's dynamic
-	if (mMemOffset > mMem->GetSize())
+	//Allow seek to m_memory->getSize() position, that means end of stream, reading not allowed but you can write if it's dynamic
+	if (m_memory_offset > m_memory->size())
 	{
 		Log::E("Seek beyond the end of stream.");
-		throw InvalidOperationException("Seek beyond the end of stream.");
 	}
 }
 
-uint8_t MemoryStream::ReadByte()
+//-----------------------------------------------------------------------------
+uint8_t MemoryStream::read_byte()
 {
-	CheckValid();
+	check_valid();
 
-	if (mMemOffset >= mMem->GetSize())
+	if (m_memory_offset >= m_memory->size())
 	{
 		Log::E("Trying to read beyond the end of stream.");
-		throw InvalidOperationException("Trying to read beyond the end of stream.");
 	}
 
-	return mMem->GetData()[mMemOffset++];
+	return m_memory->data()[m_memory_offset++];
 }
 
-void MemoryStream::ReadDataBlock(void* buffer, size_t size)
+//-----------------------------------------------------------------------------
+void MemoryStream::read_data_block(void* buffer, size_t size)
 {
-	CheckValid();
-	uint8_t* src = mMem->GetData();
+	check_valid();
+	uint8_t* src = m_memory->data();
 	uint8_t* dest = (uint8_t*) buffer;
 
-	if (mMemOffset + size > mMem->GetSize())
+	if (m_memory_offset + size > m_memory->size())
 	{
 		Log::E("Trying to read beyond the end of stream.");
-		throw InvalidOperationException("Trying to read beyond the end of stream.");
 	}
 
 	for (size_t i = 0; i < size; i++)
 	{
-		dest[i] = src[mMemOffset+i];
+		dest[i] = src[m_memory_offset+i];
 	}
 
-	mMemOffset += size;
+	m_memory_offset += size;
 }
 
-bool MemoryStream::CopyTo(Stream* stream, size_t size)
+//-----------------------------------------------------------------------------
+bool MemoryStream::copy_to(Stream* stream, size_t size)
 {
-	CheckValid();
-	stream->WriteDataBlock(&(mMem->GetData()[mMemOffset]), math::min(mMem->GetSize()-mMemOffset, size));
+	check_valid();
+
+	stream->write_data_block(&(m_memory->data()[m_memory_offset]), math::min(m_memory->size()-m_memory_offset, size));
+
 	return true;
 }
 
-void MemoryStream::WriteByte(uint8_t val)
+//-----------------------------------------------------------------------------
+void MemoryStream::write_byte(uint8_t val)
 {
-	CheckValid();
-	mMem->Write(&val, mMemOffset, 1);
-	mMemOffset++;
+	check_valid();
+	m_memory->write(&val, m_memory_offset, 1);
+	m_memory_offset++;
 }
 
-void MemoryStream::WriteDataBlock(const void* buffer, size_t size)
+//-----------------------------------------------------------------------------
+void MemoryStream::write_data_block(const void* buffer, size_t size)
 {
-	CheckValid();
-	mMem->Write((uint8_t*)buffer, mMemOffset, size);
-	mMemOffset += size;
+	check_valid();
+	m_memory->write((uint8_t*)buffer, m_memory_offset, size);
+	m_memory_offset += size;
 }
 
-void MemoryStream::Flush()
+//-----------------------------------------------------------------------------
+void MemoryStream::flush()
 {
 	return;
 }
 
-void MemoryStream::Dump()
+//-----------------------------------------------------------------------------
+void MemoryStream::dump()
 {
-	uint8_t* buff = mMem->GetData();
+	uint8_t* buff = m_memory->data();
 
-	for (size_t i=0; i<mMem->GetSize(); i++)
+	for (size_t i = 0; i < m_memory->size(); i++)
 	{
 		printf("%3i ", buff[i]);
 	}
 }
 
-}
+} // namespace crown
+

+ 41 - 45
src/core/streams/MemoryStream.h

@@ -27,7 +27,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Stream.h"
-#include "Exceptions.h"
+#include "Allocator.h"
+#include <cassert>
 
 namespace crown
 {
@@ -40,14 +41,14 @@ public:
 						MemoryBuffer();
 	virtual				~MemoryBuffer();
 
-	virtual void		Release() = 0;
-	virtual void		Allocate(size_t size) = 0;
+	virtual void		release() = 0;
+	virtual void		allocate(size_t size) = 0;
 
-	virtual bool		IsValid() = 0;
-	virtual size_t		GetSize() = 0;
-	virtual uint8_t*		GetData() = 0;
+	virtual bool		is_valid() = 0;
+	virtual size_t		size() = 0;
+	virtual uint8_t*	data() = 0;
 
-	virtual void		Write(uint8_t* src, size_t offset, size_t size) = 0;
+	virtual void		write(uint8_t* src, size_t offset, size_t size) = 0;
 };
 
 class DynamicMemoryBuffer: public MemoryBuffer
@@ -55,27 +56,28 @@ class DynamicMemoryBuffer: public MemoryBuffer
 
 public:
 
-					DynamicMemoryBuffer(size_t initialCapacity);
-	virtual			~DynamicMemoryBuffer();
+						DynamicMemoryBuffer(Allocator& allocator, size_t initial_capacity);
+	virtual				~DynamicMemoryBuffer();
 
-	void			Release();
-	void			Allocate(size_t capacity);
+	void				release();
+	void				allocate(size_t capacity);
 
-	inline bool		IsValid() { return mBuff != 0; }
+	inline bool			is_valid() { return m_buffer != 0; }
 
-	void			CheckSpace(size_t offset, size_t space);
-	void			Write(uint8_t* src, size_t offset, size_t size);
+	void				check_space(size_t offset, size_t space);
+	void				write(uint8_t* src, size_t offset, size_t size);
 
-	inline size_t	GetSize() { return mSize; }
-	inline size_t	GetCapacity() { return mCapacity; }
+	inline size_t		size() { return m_size; }
+	inline size_t		capacity() { return m_capacity; }
 
-	inline uint8_t*	GetData() { return mBuff; }
+	inline uint8_t*		data() { return m_buffer; }
 
 protected:
 
-	uint8_t*			mBuff;
-	size_t			mCapacity;
-	size_t			mSize;
+	Allocator*			m_allocator;
+	uint8_t*			m_buffer;
+	size_t				m_capacity;
+	size_t				m_size;
 };
 
 /**
@@ -88,43 +90,37 @@ class MemoryStream: public Stream
 
 public:
 
-						MemoryStream(MemoryBuffer* f, StreamOpenMode openMode);
+						MemoryStream(MemoryBuffer* buffer, StreamOpenMode mode);
 	virtual				~MemoryStream();
 
-	void				Seek(int32_t newPos, SeekMode mode);
+	void				seek(int32_t position, SeekMode mode);
 
-	uint8_t				ReadByte();
-	void				ReadDataBlock(void* buffer, size_t size);
-	bool				CopyTo(Stream* stream, size_t size = 0);
+	uint8_t				read_byte();
+	void				read_data_block(void* buffer, size_t size);
+	bool				copy_to(Stream* stream, size_t size = 0);
 
-	void				WriteByte(uint8_t val);
-	void				WriteDataBlock(const void* buffer, size_t size);
-	void				Flush();
+	void				write_byte(uint8_t val);
+	void				write_data_block(const void* buffer, size_t size);
+	void				flush();
 
-	bool				EndOfStream() const { return GetSize() == mMemOffset; }
-	bool				IsValid() const { CheckValid(); return mMem->IsValid(); }
+	bool				end_of_stream() const { return size() == m_memory_offset; }
+	bool				is_valid() const { assert(m_memory != NULL); return m_memory->is_valid(); }
 
-	size_t				GetSize() const { CheckValid(); return mMem->GetSize(); }
-	size_t				GetPosition() const { return mMemOffset; }
+	size_t				size() const { assert(m_memory != NULL); return m_memory->size(); }
+	size_t				position() const { return m_memory_offset; }
 
-	bool				CanRead() const { return Stream::CanRead(); }
-	bool				CanWrite() const { return Stream::CanWrite(); }
-	bool				CanSeek() const { return true; }
+	bool				can_read() const { return true; }
+	bool				can_write() const { return true; }
+	bool				can_seek() const { return true; }
 
-	void				Dump();
+	void				dump();
 
 protected:
 
-	MemoryBuffer*		mMem;
-	size_t				mMemOffset;
+	inline void check_valid() { assert(m_memory != NULL); }
 
-	inline void			CheckValid() const
-						{
-							if (!mMem)
-							{
-								throw InvalidOperationException("Can't operate on an invalid MemoryStream");
-							}
-						}
+	MemoryBuffer*		m_memory;
+	size_t				m_memory_offset;
 };
 
 }

+ 16 - 15
src/core/streams/NullStream.h

@@ -41,23 +41,24 @@ class NullStream: public Stream
 public:
 
 				/** @copydoc Stream::Stream() */
-				NullStream(StreamOpenMode openMode) : Stream(openMode) {}
+				NullStream(StreamOpenMode mode) : Stream(mode) {}
 				/** @copydoc Stream::~Stream() */
 	virtual		~NullStream() {}
+
 				/** @copydoc Stream::Seek() */
-	void		Seek(int32_t /*newPos*/, uint8_t /*mode*/) {}
+	void		seek(int32_t /*position*/, uint8_t /*mode*/) {}
 				/**
 				@copydoc Stream::ReadByte()
 				@note
 					Returns always zero
 				*/
-	uint8_t		ReadByte() { return 0; }
+	uint8_t		read_byte() { return 0; }
 				/**
 				@copydoc Stream::ReadDataBlock()
 				@note
 					Fills buffer with zeroes
 				*/
-	void		ReadDataBlock(void* buffer, size_t size)
+	void		read_data_block(void* buffer, size_t size)
 				{
 					for (size_t i = 0; i < size; i++)
 					{
@@ -69,55 +70,55 @@ public:
 				@note
 					Returns always false
 				*/
-	bool		CopyTo(Stream* /*stream*/, size_t /*size = 0*/) { return false; }
+	bool		copy_to(Stream* /*stream*/, size_t /*size = 0*/) { return false; }
 				/** @copydoc Stream::WriteByte() */
-	void		WriteByte(uint8_t /*val*/) {};
+	void		write_byte(uint8_t /*val*/) {};
 				/** @copydoc Stream::WriteDataBlock() */
-	void		WriteDataBlock(const void* /*buffer*/, size_t /*size*/) {};
+	void		write_data_block(const void* /*buffer*/, size_t /*size*/) {};
 				/** @copydoc Stream::Flush() */
-	void		Flush() {};
+	void		flush() {};
 				/**
 				@copydoc Stream::IsValid()
 				@note
 					Returns always true
 				*/
-	bool		IsValid() { return true; }
+	bool		is_valid() { return true; }
 				/**
 				@copydoc Stream::EndOfStream()
 				@note
 					Returns always false
 				*/
-	bool		EndOfStream() { return false; }
+	bool		end_of_stream() { return false; }
 				/**
 				@copydoc Stream::GetSize()
 				@note
 					Returns always 0xFFFFFFFF
 				*/
-	size_t		GetSize() { return ~0; }
+	size_t		size() { return ~0; }
 				/**
 				@copydoc Stream::GetPosition()
 				@note
 					Returns always zero
 				*/
-	size_t		GetPosition() { return 0; }
+	size_t		position() { return 0; }
 				/**
 				@copydoc Stream::CanRead()
 				@note
 					Returns always true
 				*/
-	bool		CanRead() { return true; }
+	bool		can_read() { return true; }
 				/**
 				@copydoc Stream::CanWrite()
 				@note
 					Returns always true
 				*/
-	bool		CanWrite() { return true; }
+	bool		can_write() { return true; }
 				/**
 				@copydoc Stream::CanSeek()
 				@note
 					Returns always true
 				*/
-	bool		CanSeek() { return true; }
+	bool		can_seek() { return true; }
 };
 
 } // namespace crown

+ 91 - 60
src/core/streams/Stream.cpp

@@ -31,7 +31,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-bool Stream::ZipTo(Stream* stream, size_t size, size_t& zippedSize)
+//-----------------------------------------------------------------------------
+bool Stream::zip_to(Stream* stream, size_t size, size_t& zipped_size)
 {
 	const size_t CHUNK_SIZE = 16384;
 	int32_t ret, flush;
@@ -51,7 +52,7 @@ bool Stream::ZipTo(Stream* stream, size_t size, size_t& zippedSize)
 	do
 	{
 		size_t this_step_bytes = math::min(CHUNK_SIZE, size - bytes_read);
-		ReadDataBlock(in, this_step_bytes);
+		read_data_block(in, this_step_bytes);
 
 		strm.avail_in = this_step_bytes;
 		strm.next_in = in;
@@ -68,7 +69,7 @@ bool Stream::ZipTo(Stream* stream, size_t size, size_t& zippedSize)
 
 			have = CHUNK_SIZE - strm.avail_out;
 			if (have > 0)
-				stream->WriteDataBlock(out, have);
+				stream->write_data_block(out, have);
 			
 		} while (strm.avail_out == 0);
 		assert(strm.avail_in == 0);     /* all input will be used */
@@ -80,11 +81,14 @@ bool Stream::ZipTo(Stream* stream, size_t size, size_t& zippedSize)
 
 	/* clean up and return */
 	(void)deflateEnd(&strm);
-	zippedSize = strm.total_out;
+
+	zipped_size = strm.total_out;
+
 	return true;
 }
 
-bool Stream::UnzipTo(Stream* stream, size_t& /*unzippedSize*/)
+//-----------------------------------------------------------------------------
+bool Stream::unzip_to(Stream* stream, size_t& /*unzipped_size*/)
 {
 	const size_t CHUNK_SIZE = 16384;
 	int32_t ret;
@@ -103,14 +107,14 @@ bool Stream::UnzipTo(Stream* stream, size_t& /*unzippedSize*/)
 	if (ret != Z_OK)
 			return false;
 
-	size_t size = GetSize();
+	size_t size = this->size();
 	size_t bytes_read = 0;
 
 	/* decompress until deflate stream ends or end of file */
 	do
 	{
 		size_t this_step_bytes = math::min(CHUNK_SIZE, size - bytes_read);
-		ReadDataBlock(in, this_step_bytes);
+		read_data_block(in, this_step_bytes);
 
 		strm.avail_in = this_step_bytes;
 		strm.next_in = in;
@@ -133,7 +137,7 @@ bool Stream::UnzipTo(Stream* stream, size_t& /*unzippedSize*/)
 				}
 				have = CHUNK_SIZE - strm.avail_out;
 				if (have > 0)
-					stream->WriteDataBlock(out, have);
+					stream->write_data_block(out, have);
 		} while (strm.avail_out == 0);
 
 		bytes_read += this_step_bytes;
@@ -145,156 +149,180 @@ bool Stream::UnzipTo(Stream* stream, size_t& /*unzippedSize*/)
 	return ret == Z_STREAM_END;
 }
 
+//-----------------------------------------------------------------------------
 BinaryReader::BinaryReader(Stream* s)
 {
 	//BinaryReader takes the ownership of the stream.
-	mStream = s;
+	m_stream = s;
 }
 
+//-----------------------------------------------------------------------------
 BinaryReader::~BinaryReader()
 {
 }
 
-int8_t BinaryReader::ReadByte()
+//-----------------------------------------------------------------------------
+int8_t BinaryReader::read_byte()
 {
 	int8_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(int8_t));
+	m_stream->read_data_block(&buffer, sizeof(int8_t));
 	return buffer;
 }
 
-int16_t BinaryReader::ReadInt16()
+//-----------------------------------------------------------------------------
+int16_t BinaryReader::read_int16()
 {
 	int16_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(int16_t));
+	m_stream->read_data_block(&buffer, sizeof(int16_t));
 	return buffer;
 }
 
-uint16_t BinaryReader::ReadUint16()
+//-----------------------------------------------------------------------------
+uint16_t BinaryReader::read_uint16()
 {
 	uint16_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(uint16_t));
+	m_stream->read_data_block(&buffer, sizeof(uint16_t));
 	return buffer;
 }
 
-int32_t BinaryReader::ReadInt32()
+//-----------------------------------------------------------------------------
+int32_t BinaryReader::read_int32()
 {
 	int32_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(int32_t));
+	m_stream->read_data_block(&buffer, sizeof(int32_t));
 	return buffer;
 }
 
-uint32_t BinaryReader::ReadUint32()
+//-----------------------------------------------------------------------------
+uint32_t BinaryReader::read_uint32()
 {
 	uint32_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(uint32_t));
+	m_stream->read_data_block(&buffer, sizeof(uint32_t));
 	return buffer;
 }
 
-int64_t BinaryReader::ReadInt64()
+//-----------------------------------------------------------------------------
+int64_t BinaryReader::read_int64()
 {
 	int64_t buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(int64_t));
+	m_stream->read_data_block(&buffer, sizeof(int64_t));
 	return buffer;
 }
 
-double BinaryReader::ReadDouble()
+//-----------------------------------------------------------------------------
+double BinaryReader::read_double()
 {
 	double buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(double));
+	m_stream->read_data_block(&buffer, sizeof(double));
 	return buffer;
 }
 
-float BinaryReader::ReadFloat()
+float BinaryReader::read_float()
 {
 	float buffer;
-	mStream->ReadDataBlock(&buffer, sizeof(float));
+	m_stream->read_data_block(&buffer, sizeof(float));
 	return buffer;
 }
 
+//-----------------------------------------------------------------------------
 BinaryWriter::BinaryWriter(Stream* s)
 {
 	//BinaryWriter takes the ownership of the stream.
-	mStream = s;
+	m_stream = s;
 }
 
+//-----------------------------------------------------------------------------
 BinaryWriter::~BinaryWriter()
 {
 }
 
-void BinaryWriter::WriteByte(int8_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_byte(int8_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(int8_t));
+	m_stream->write_data_block(&buffer, sizeof(int8_t));
 }
 
-void BinaryWriter::WriteInt16(int16_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_int16(int16_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(int16_t));
+	m_stream->write_data_block(&buffer, sizeof(int16_t));
 }
 
-void BinaryWriter::WriteUint16(uint16_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_uint16(uint16_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(uint16_t));
+	m_stream->write_data_block(&buffer, sizeof(uint16_t));
 }
 
-void BinaryWriter::WriteInt32(int32_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_int32(int32_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(int32_t));
+	m_stream->write_data_block(&buffer, sizeof(int32_t));
 }
 
-void BinaryWriter::WriteUint32(uint32_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_uint32(uint32_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(uint32_t));
+	m_stream->write_data_block(&buffer, sizeof(uint32_t));
 }
 
-void BinaryWriter::WriteInt64(int64_t buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_int64(int64_t buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(int64_t));
+	m_stream->write_data_block(&buffer, sizeof(int64_t));
 }
 
-void BinaryWriter::WriteDouble(double buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_double(double buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(double));
+	m_stream->write_data_block(&buffer, sizeof(double));
 }
 
-void BinaryWriter::WriteFloat(float buffer)
+//-----------------------------------------------------------------------------
+void BinaryWriter::write_float(float buffer)
 {
-	mStream->WriteDataBlock(&buffer, sizeof(float));
+	m_stream->write_data_block(&buffer, sizeof(float));
 }
 
-void BinaryWriter::InsertByte(int8_t val, size_t offset)
+//-----------------------------------------------------------------------------
+void BinaryWriter::insert_byte(int8_t val, size_t offset)
 {
-	size_t tmpSize = mStream->GetSize() - offset;
+	size_t tmpSize = m_stream->size() - offset;
 	int8_t* tmp = new int8_t[tmpSize];
-	mStream->Seek(offset, SM_SeekFromBegin);
-	mStream->ReadDataBlock(tmp, tmpSize);
-	mStream->Seek(offset, SM_SeekFromBegin);
-	mStream->WriteByte(val);
-	mStream->WriteDataBlock(tmp, tmpSize);
+	m_stream->seek(offset, SM_FROM_BEGIN);
+	m_stream->read_data_block(tmp, tmpSize);
+	m_stream->seek(offset, SM_FROM_BEGIN);
+	m_stream->write_byte(val);
+	m_stream->write_data_block(tmp, tmpSize);
 	delete[] tmp;
 }
 
+//-----------------------------------------------------------------------------
 TextReader::TextReader(Stream* s)
 {
-	mStream = s;
+	m_stream = s;
 }
 
+//-----------------------------------------------------------------------------
 TextReader::~TextReader()
 {
 }
 
-char TextReader::ReadChar()
+//-----------------------------------------------------------------------------
+char TextReader::read_char()
 {
-	return mStream->ReadByte();
+	return m_stream->read_byte();
 }
 
-char* TextReader::ReadString(char* string, int32_t count)
+//-----------------------------------------------------------------------------
+char* TextReader::read_string(char* string, uint32_t count)
 {
 	char currentChar;
 	int32_t i = 0;
 
-	while(!mStream->EndOfStream() && i < count - 1)
+	while(!m_stream->end_of_stream() && i < count - 1)
 	{
-		currentChar = mStream->ReadByte();
+		currentChar = m_stream->read_byte();
 		string[i] = currentChar;
 
 		i++;
@@ -315,27 +343,30 @@ char* TextReader::ReadString(char* string, int32_t count)
 	return string;
 }
 
+//-----------------------------------------------------------------------------
 TextWriter::TextWriter(Stream* s)
 {
-	mStream = s;
+	m_stream = s;
 }
 
+//-----------------------------------------------------------------------------
 TextWriter::~TextWriter()
 {
 }
 
-void TextWriter::WriteChar(char c)
+void TextWriter::write_char(char c)
 {
-	mStream->WriteByte(c);
+	m_stream->write_byte(c);
 }
 
-void TextWriter::WriteString(const char* string)
+//-----------------------------------------------------------------------------
+void TextWriter::write_string(const char* string)
 {
 	size_t count = 0;
 
 	while(string[count] != '\0')
 	{
-		mStream->WriteByte(string[count]);
+		m_stream->write_byte(string[count]);
 		count++;
 	}
 }

+ 59 - 109
src/core/streams/Stream.h

@@ -26,22 +26,21 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "MathUtils.h"
 
 namespace crown
 {
 
 enum SeekMode
 {
-	SM_SeekFromBegin	= 0,
-	SM_SeekFromCurrent	= 1,
-	SM_SeekFromEnd		= 2
+	SM_FROM_BEGIN	= 0,
+	SM_FROM_CURRENT	= 1,
+	SM_FROM_END		= 2
 };
 
 enum StreamOpenMode
 {
-	SOM_READ	= 1,
-	SOM_WRITE	= 2
+	SOM_READ		= 1,
+	SOM_WRITE		= 2
 };
 
 /**
@@ -49,89 +48,54 @@ enum StreamOpenMode
 
 	It represents a flow of data attached to a 'file' which can be an archived file,
 	a regular file, a location in memory or anything that can be read or wrote.
-	A Stream is an abstraction to int32_teract with these in an uniform way; every stream
+	A Stream is an abstraction to interact with these in an uniform way; every stream
 	comes with a convenient set of methods to facilitate reading from it, writing to
 	it and so on.
 */
 class Stream
 {
-
 public:
 
 						/**
 							Constructor.
-						@param openMode
-							Whether to open for writing or reading
 						*/
-						Stream(StreamOpenMode openMode) : mOpenMode(openMode) {}
+						Stream(StreamOpenMode mode) : m_open_mode(mode) {}
 						/**
 							Destructor.
 						*/
 	virtual				~Stream() {};
 						/**
-							Sets the position indicator of the stream to a new position.
-						@param newPos
-							The new position
-						@param mode
-							Position from where to move
+							Sets the position indicator of the stream to position.
 						*/
-	virtual void		Seek(int32_t newPos, SeekMode mode) = 0;
+	virtual void		seek(int32_t position, SeekMode mode) = 0;
 						/**
 							Reads a byte from the stream starting at current position.
-						@return
-							The byte read
 						*/
-	virtual uint8_t		ReadByte() = 0;
+	virtual uint8_t		read_byte() = 0;
 						/**
 							Reads a block of data from the stream.
-						@param buffer
-							Point32_ter to a block of memory of size 'size'
-						@param size
-							The number of bytes to read
 						*/
-	virtual void		ReadDataBlock(void* buffer, size_t size) = 0;
+	virtual void		read_data_block(void* buffer, size_t size) = 0;
 						/**
 							Copies a chunk of 'size' bytes of data from this to another stream.
-						@param stream
-							The output stream
-						@param size
-							The number of bytes to copy
-						@return
-							True if success, false otherwise
 						*/
-	virtual bool		CopyTo(Stream* stream, size_t size = 0) = 0;
+	virtual bool		copy_to(Stream* stream, size_t size = 0) = 0;
 						/**
 							Zips a chunk of 'size' bytes of data from this to another stream. A default implementation is given
-						@param stream
-							The output stream
-						@param size
-							The number of bytes to zip
-						@return
-							True if success, false otherwise
 						*/
-	virtual bool		ZipTo(Stream* stream, size_t size, size_t& zippedSize);
+	virtual bool		zip_to(Stream* stream, size_t size, size_t& zipped_size);
 						/**
 							Unzip a zipped stream of data from this to another stream. A default implementation is given
-						@param stream
-							The output stream
-						@return
-							True if success, false otherwise
 						*/
-	virtual bool		UnzipTo(Stream* stream, size_t& unzippedSize);
+	virtual bool		unzip_to(Stream* stream, size_t& unzipped_size);
 						/**
 							Writes a byte to the stream starting at current position.
-						@param val
-							The byte to write
 						*/
-	virtual void		WriteByte(uint8_t val) = 0;
+	virtual void		write_byte(uint8_t val) = 0;
 						/**
 							Writes a block of data to the stream.
-						@param buffer
-							Pointter to a block of memory of size 'size'
-						@param size
-							The number of bytes to write
 						*/
-	virtual void		WriteDataBlock(const void* buffer, size_t size) = 0;
+	virtual void		write_data_block(const void* buffer, size_t size) = 0;
 						/**
 							Forces the previouses write operations to complete.
 							Generally, when a Stream is attached to a file,
@@ -140,58 +104,44 @@ public:
 							the file. This method forces all the pending output operations
 							to be written to the stream.
 						*/
-	virtual void		Flush() = 0;
+	virtual void		flush() = 0;
 						/**
 							Returns whether the stream is valid.
 							A stream is valid when the buffer where it operates
 							exists. (i.e. a file descriptor is attached to the stream, 
 							a memory area is attached to the stream etc.)
-						@return
-							True if valid, false otherwise
 						*/
-	virtual bool		IsValid() const = 0;
+	virtual bool		is_valid() const = 0;
 						/**
 							Returns whether the position is at end of stream.
-						@return
-							True if at end of stream, false otherwise
 						*/
-	virtual bool		EndOfStream() const = 0;
+	virtual bool		end_of_stream() const = 0;
 						/**
 							Returns the size of stream in bytes.
-						@return
-							The size in bytes
 						*/
-	virtual size_t		GetSize() const = 0;
+	virtual size_t		size() const = 0;
 						/**
 							Returns the current position in stream.
 							Generally, for binary data, it means the number of bytes
 							from the beginning of the stream.
-						@return
-							The current position
 						*/
-	virtual size_t		GetPosition() const = 0;
+	virtual size_t		position() const = 0;
 						/**
 							Returns whether the stream can be read.
-						@return
-							True if readable, false otherwise
 						*/
-	virtual inline bool	CanRead() const { return math::test_bitmask(mOpenMode, SOM_READ); }
+	virtual bool		can_read() const = 0;
 						/**
 							Returns whether the stream can be wrote.
-						@return
-							True if writeable, false otherwise
 						*/
-	virtual inline bool	CanWrite() const { return math::test_bitmask(mOpenMode, SOM_WRITE); }
+	virtual bool		can_write() const = 0;
 						/**
 							Returns whether the stream can be sought.
-						@returns
-							True is seekable, false otherwise
 						*/
-	virtual bool		CanSeek() const = 0;
+	virtual bool		can_seek() const = 0;
 
 protected:
 
-	StreamOpenMode		mOpenMode;
+	StreamOpenMode		m_open_mode;
 };
 
 //! A reader that offers a convenient way to read from a stream
@@ -203,21 +153,21 @@ public:
 						BinaryReader(Stream* s);
 	virtual				~BinaryReader();
 
-	int8_t				ReadByte();
-	int16_t				ReadInt16();
-	uint16_t			ReadUint16();
-	int32_t				ReadInt32();
-	uint32_t			ReadUint32();
-	int64_t				ReadInt64();
-	double				ReadDouble();
-	float				ReadFloat();
+	int8_t				read_byte();
+	int16_t				read_int16();
+	uint16_t			read_uint16();
+	int32_t				read_int32();
+	uint32_t			read_uint32();
+	int64_t				read_int64();
+	double				read_double();
+	float				read_float();
 
-	inline Stream*		GetStream() { return mStream; }
-	inline void			SetStream(Stream* stream) { mStream = stream; }
+	inline Stream*		get_stream() { return m_stream; }
+	inline void			set_stream(Stream* stream) { m_stream = stream; }
 
 private:
 
-	Stream*				mStream;
+	Stream*				m_stream;
 };
 
 //! A writer that offers a convenient way to write to a stream
@@ -229,23 +179,23 @@ public:
 						BinaryWriter(Stream* s);
 	virtual				~BinaryWriter();
 
-	void				WriteByte(int8_t);
-	void				WriteInt16(int16_t);
-	void				WriteUint16(uint16_t);
-	void				WriteInt32(int32_t);
-	void				WriteUint32(uint32_t);
-	void				WriteInt64(int64_t);
-	void				WriteDouble(double);
-	void				WriteFloat(float);
+	void				write_byte(int8_t);
+	void				write_int16(int16_t);
+	void				write_uint16(uint16_t);
+	void				write_int32(int32_t);
+	void				write_uint32(uint32_t);
+	void				write_int64(int64_t);
+	void				write_double(double);
+	void				write_float(float);
 
-	void				InsertByte(int8_t val, size_t offset);
+	void				insert_byte(int8_t val, size_t offset);
 
-	inline Stream*		GetStream() { return mStream; }
-	inline void			SetStream(Stream* stream) { mStream = stream; }
+	inline Stream*		get_stream() { return m_stream; }
+	inline void			set_stream(Stream* stream) { m_stream = stream; }
 
 private:
 
-	Stream*				mStream;
+	Stream*				m_stream;
 };
 
 //! A reader that offers a convenient way to read text to a stream
@@ -257,10 +207,10 @@ public:
 						TextReader(Stream* s);
 	virtual				~TextReader();
 
-	char				ReadChar();
+	char				read_char();
 						/**
 							Reads characters from stream and stores them as a C string
-							int32_to string until (count-1) characters have been read or
+							into string until (count-1) characters have been read or
 							either a newline or the End-of-Stream is reached, whichever
 							comes first.
 							A newline character makes fgets stop reading, but it is considered
@@ -268,14 +218,14 @@ public:
 							A null character is automatically appended in str after the characters read to
 							signal the end of the C string.
 						*/
-	char*				ReadString(char* string, int32_t count);
+	char*				read_string(char* string, uint32_t count);
 
-	inline Stream*		GetStream() { return mStream; }
-	inline void			SetStream(Stream* stream) { mStream = stream; }
+	inline Stream*		get_stream() { return m_stream; }
+	inline void			set_stream(Stream* stream) { m_stream = stream; }
 
 private:
 
-	Stream*				mStream;
+	Stream*				m_stream;
 };
 
 //! A reader that offers a convenient way to write text to a stream
@@ -287,21 +237,21 @@ public:
 						TextWriter(Stream* s);
 	virtual				~TextWriter();
 
-	void				WriteChar(char c);
+	void				write_char(char c);
 						/**
 							Writes the string point32_ted by string to the stream.
 							The function begins copying from the address specified (string)
 							until it reaches the terminating null character ('\0').
 							This final null character is not copied to the stream.
 						*/
-	void				WriteString(const char* string);
+	void				write_string(const char* string);
 
-	inline Stream*		GetStream() { return mStream; }
-	inline void			SetStream(Stream* stream) { mStream = stream; }
+	inline Stream*		get_stream() { return m_stream; }
+	inline void			set_stream(Stream* stream) { m_stream = stream; }
 
 private:
 
-	Stream*				mStream;
+	Stream*				m_stream;
 };
 
 } // namespace crown

+ 8 - 8
src/loaders/BMPImageLoader.cpp

@@ -92,7 +92,7 @@ Image* BMPImageLoader::LoadFile(const char* relativePath)
 		return NULL;
 	}
 
-	fileStream->ReadDataBlock(&magicNumber, 2);
+	fileStream->read_data_block(&magicNumber, 2);
 
 	if (magicNumber != 19778)
 	{
@@ -102,9 +102,9 @@ Image* BMPImageLoader::LoadFile(const char* relativePath)
 		return NULL;
 	}
 
-	fileStream->Seek(0, SM_SeekFromBegin);
-	fileStream->ReadDataBlock(&bfh, sizeof(BitmapFileHeader));
-	fileStream->ReadDataBlock(&bih, sizeof(BitmapInfoHeader));
+	fileStream->seek(0, SM_FROM_BEGIN);
+	fileStream->read_data_block(&bfh, sizeof(BitmapFileHeader));
+	fileStream->read_data_block(&bih, sizeof(BitmapInfoHeader));
 
 	int32_t bpp = (bih.biBitCount/8);
 
@@ -132,7 +132,7 @@ Image* BMPImageLoader::LoadFile(const char* relativePath)
 
 		for (int32_t i=0; i<bih.biHeight ; i++)
 		{
-			fileStream->ReadDataBlock(tmpdata, bih.biWidth*3);
+			fileStream->read_data_block(tmpdata, bih.biWidth*3);
 
 			int32_t offset = bih.biWidth * 4 * i;
 
@@ -146,7 +146,7 @@ Image* BMPImageLoader::LoadFile(const char* relativePath)
 
 			if (padSize)
 			{
-				fileStream->Seek(padSize, SM_SeekFromCurrent);
+				fileStream->seek(padSize, SM_FROM_CURRENT);
 			}
 		}
 
@@ -158,11 +158,11 @@ Image* BMPImageLoader::LoadFile(const char* relativePath)
 		{
 			int32_t offset = bih.biWidth * 4 * i;
 
-			fileStream->ReadDataBlock(&data[offset], bih.biWidth*4);
+			fileStream->read_data_block(&data[offset], bih.biWidth*4);
 
 			if (padSize)
 			{
-				fileStream->Seek(padSize, SM_SeekFromCurrent);
+				fileStream->seek(padSize, SM_FROM_CURRENT);
 			}
 		}
 	}

+ 9 - 9
src/loaders/TGAImageLoader.cpp

@@ -52,9 +52,9 @@ Image* TGAImageLoader::LoadFile(const char* relativePath)
 		return NULL;
 	}
 
-	fileStream->ReadDataBlock(&mTGAHeader, sizeof(mTGAHeader));
+	fileStream->read_data_block(&mTGAHeader, sizeof(mTGAHeader));
 	// Skip ID
-	fileStream->Seek(mTGAHeader.id_length, SM_SeekFromCurrent);
+	fileStream->seek(mTGAHeader.id_length, SM_FROM_CURRENT);
 
 	Image* image = NULL;
 
@@ -97,7 +97,7 @@ Image* TGAImageLoader::LoadUncompressedData(Stream* fp)
 		for (uint64_t i = 0; i < size * channels; i++)
 		{
 			uint16_t pixel_data;
-			fp->ReadDataBlock(&pixel_data, sizeof(pixel_data));
+			fp->read_data_block(&pixel_data, sizeof(pixel_data));
 			data[j] = (pixel_data & 0x7c) >> 10;
 			data[j+1] = (pixel_data & 0x3e) >> 5;
 			data[j+2] = (pixel_data & 0x1f);
@@ -107,7 +107,7 @@ Image* TGAImageLoader::LoadUncompressedData(Stream* fp)
 	else
 	{
 		data = new uint8_t[(uint32_t)(size * channels)];
-		fp->ReadDataBlock(data, (size_t)(size * channels));
+		fp->read_data_block(data, (size_t)(size * channels));
 		SwapRedBlue(data, size * channels, channels);
 	}
 
@@ -140,12 +140,12 @@ Image* TGAImageLoader::LoadCompressedData(Stream* fp)
 
 	while (i < size)
 	{
-		fp->ReadDataBlock(&rle_id, sizeof(uint8_t));
+		fp->read_data_block(&rle_id, sizeof(uint8_t));
 
 		if (rle_id & 0x80)   // Se il bit più significativo è ad 1
 		{
 			rle_id -= 127;
-			fp->ReadDataBlock(colors, channels);
+			fp->read_data_block(colors, channels);
 
 			while (rle_id)
 			{
@@ -169,7 +169,7 @@ Image* TGAImageLoader::LoadCompressedData(Stream* fp)
 
 			while (rle_id)
 			{
-				fp->ReadDataBlock(colors, channels);
+				fp->read_data_block(colors, channels);
 				data[colors_read] = colors[2];
 				data[colors_read+1] = colors[1];
 				data[colors_read+2] = colors[0];
@@ -230,8 +230,8 @@ void TGAImageLoader::SaveFile(const Image* image, const char* relativePath)
 
 	if (fileStream)
 	{
-		fileStream->WriteDataBlock(&header, sizeof(header));
-		fileStream->WriteDataBlock(image->GetBuffer(), image->GetWidth() * image->GetHeight() * image->GetBytesPerPixel());
+		fileStream->write_data_block(&header, sizeof(header));
+		fileStream->write_data_block(image->GetBuffer(), image->GetWidth() * image->GetHeight() * image->GetBytesPerPixel());
 
 		GetFilesystem()->Close(fileStream);
 	}