From 47d019098c148a0fefa6254784534c658ec42628 Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Wed, 17 Feb 2010 14:43:09 +0000 Subject: [PATCH] Changed the parameter of LoadFromMemory functions to be a const void* instead of a const char* git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1409 4e206d99-4929-0410-ac5d-dfc041789085 --- CSFML/include/SFML/Audio/Music.h | 2 +- CSFML/include/SFML/Audio/SoundBuffer.h | 2 +- CSFML/include/SFML/Graphics/Font.h | 2 +- CSFML/include/SFML/Graphics/Image.h | 2 +- CSFML/src/SFML/Audio/Music.cpp | 2 +- CSFML/src/SFML/Audio/SoundBuffer.cpp | 2 +- CSFML/src/SFML/Graphics/Font.cpp | 2 +- CSFML/src/SFML/Graphics/Image.cpp | 2 +- include/SFML/Audio/Music.hpp | 2 +- include/SFML/Audio/SoundBuffer.hpp | 2 +- include/SFML/Graphics/Font.hpp | 2 +- include/SFML/Graphics/Image.hpp | 2 +- include/SFML/Network/SocketTCP.hpp | 6 +++--- include/SFML/Network/SocketUDP.hpp | 10 +++++----- src/SFML/Audio/Music.cpp | 2 +- src/SFML/Audio/SoundBuffer.cpp | 2 +- src/SFML/Audio/SoundFile.cpp | 8 ++++---- src/SFML/Audio/SoundFile.hpp | 4 ++-- src/SFML/Graphics/Font.cpp | 2 +- src/SFML/Graphics/Image.cpp | 2 +- src/SFML/Graphics/ImageLoader.cpp | 2 +- src/SFML/Graphics/ImageLoader.hpp | 2 +- src/SFML/Network/SocketTCP.cpp | 6 +++--- src/SFML/Network/SocketUDP.cpp | 6 +++--- 24 files changed, 38 insertions(+), 38 deletions(-) diff --git a/CSFML/include/SFML/Audio/Music.h b/CSFML/include/SFML/Audio/Music.h index 41d809e7..30f48ad0 100644 --- a/CSFML/include/SFML/Audio/Music.h +++ b/CSFML/include/SFML/Audio/Music.h @@ -52,7 +52,7 @@ CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename); /// \return A new sfMusic object (NULL if failed) /// //////////////////////////////////////////////////////////// -CSFML_API sfMusic* sfMusic_CreateFromMemory(const char* data, size_t sizeInBytes); +CSFML_API sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Destroy an existing music diff --git a/CSFML/include/SFML/Audio/SoundBuffer.h b/CSFML/include/SFML/Audio/SoundBuffer.h index f8ee8e11..e72920b5 100644 --- a/CSFML/include/SFML/Audio/SoundBuffer.h +++ b/CSFML/include/SFML/Audio/SoundBuffer.h @@ -51,7 +51,7 @@ CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename); /// \return A new sfSoundBuffer object (NULL if failed) /// //////////////////////////////////////////////////////////// -CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const char* data, size_t sizeInBytes); +CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from an array of diff --git a/CSFML/include/SFML/Graphics/Font.h b/CSFML/include/SFML/Graphics/Font.h index 7e64d0b9..840c7d05 100644 --- a/CSFML/include/SFML/Graphics/Font.h +++ b/CSFML/include/SFML/Graphics/Font.h @@ -51,7 +51,7 @@ CSFML_API sfFont* sfFont_CreateFromFile(const char* filename); /// \return A new sfFont object, or NULL if it failed /// //////////////////////////////////////////////////////////// -CSFML_API sfFont* sfFont_CreateFromMemory(const char* data, size_t sizeInBytes); +CSFML_API sfFont* sfFont_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Copy an existing font diff --git a/CSFML/include/SFML/Graphics/Image.h b/CSFML/include/SFML/Graphics/Image.h index 8575049c..e098944f 100644 --- a/CSFML/include/SFML/Graphics/Image.h +++ b/CSFML/include/SFML/Graphics/Image.h @@ -85,7 +85,7 @@ CSFML_API sfImage* sfImage_CreateFromFile(const char* filename); /// \return A new sfImage object, or NULL if it failed /// //////////////////////////////////////////////////////////// -CSFML_API sfImage* sfImage_CreateFromMemory(const char* data, size_t sizeInBytes); +CSFML_API sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Copy an existing image diff --git a/CSFML/src/SFML/Audio/Music.cpp b/CSFML/src/SFML/Audio/Music.cpp index 1d47618d..9f513716 100644 --- a/CSFML/src/SFML/Audio/Music.cpp +++ b/CSFML/src/SFML/Audio/Music.cpp @@ -50,7 +50,7 @@ sfMusic* sfMusic_CreateFromFile(const char* filename) //////////////////////////////////////////////////////////// /// Create a new music and load it from a file in memory //////////////////////////////////////////////////////////// -sfMusic* sfMusic_CreateFromMemory(const char* data, size_t sizeInBytes) +sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes) { sfMusic* music = new sfMusic; diff --git a/CSFML/src/SFML/Audio/SoundBuffer.cpp b/CSFML/src/SFML/Audio/SoundBuffer.cpp index fe452a59..c5348e5d 100644 --- a/CSFML/src/SFML/Audio/SoundBuffer.cpp +++ b/CSFML/src/SFML/Audio/SoundBuffer.cpp @@ -50,7 +50,7 @@ sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename) //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from a file in memory //////////////////////////////////////////////////////////// -sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const char* data, size_t sizeInBytes) +sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes) { sfSoundBuffer* buffer = new sfSoundBuffer; diff --git a/CSFML/src/SFML/Graphics/Font.cpp b/CSFML/src/SFML/Graphics/Font.cpp index ef6e9a11..1514a18f 100644 --- a/CSFML/src/SFML/Graphics/Font.cpp +++ b/CSFML/src/SFML/Graphics/Font.cpp @@ -49,7 +49,7 @@ sfFont* sfFont_CreateFromFile(const char* filename) //////////////////////////////////////////////////////////// /// Create a new font from a file in memory //////////////////////////////////////////////////////////// -sfFont* sfFont_CreateFromMemory(const char* data, size_t sizeInBytes) +sfFont* sfFont_CreateFromMemory(const void* data, size_t sizeInBytes) { sfFont* font = new sfFont; if (!font->This.LoadFromMemory(data, sizeInBytes)) diff --git a/CSFML/src/SFML/Graphics/Image.cpp b/CSFML/src/SFML/Graphics/Image.cpp index e04cd7bb..1b37f1e2 100644 --- a/CSFML/src/SFML/Graphics/Image.cpp +++ b/CSFML/src/SFML/Graphics/Image.cpp @@ -94,7 +94,7 @@ sfImage* sfImage_CreateFromFile(const char* filename) //////////////////////////////////////////////////////////// /// Create a new image from a file in memory //////////////////////////////////////////////////////////// -sfImage* sfImage_CreateFromMemory(const char* data, size_t sizeInBytes) +sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes) { sfImage* image = new sfImage; diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index d0cb64ce..0bbb98ec 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -96,7 +96,7 @@ public : /// \see OpenFromFile /// //////////////////////////////////////////////////////////// - bool OpenFromMemory(const char* data, std::size_t sizeInBytes); + bool OpenFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief Get the total duration of the music diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index af9a2c65..1a060183 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -98,7 +98,7 @@ public : /// \see LoadFromFile, LoadFromSamples, SaveToFile /// //////////////////////////////////////////////////////////// - bool LoadFromMemory(const char* data, std::size_t sizeInBytes); + bool LoadFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief Load the sound buffer from an array of audio samples diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index 28ecf0ca..a1611b65 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -108,7 +108,7 @@ public : /// \see LoadFromFile /// //////////////////////////////////////////////////////////// - bool LoadFromMemory(const char* data, std::size_t sizeInBytes); + bool LoadFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief Retrieve a glyph of the font diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 17d7257d..a696db81 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -87,7 +87,7 @@ public : /// \return True if loading was successful /// //////////////////////////////////////////////////////////// - bool LoadFromMemory(const char* data, std::size_t sizeInBytes); + bool LoadFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Load the image directly from an array of pixels diff --git a/include/SFML/Network/SocketTCP.hpp b/include/SFML/Network/SocketTCP.hpp index 4d5afa6b..dcc5a245 100644 --- a/include/SFML/Network/SocketTCP.hpp +++ b/include/SFML/Network/SocketTCP.hpp @@ -98,13 +98,13 @@ public : //////////////////////////////////////////////////////////// /// Send an array of bytes to the host (must be connected first) /// - /// \param data : Pointer to the bytes to send - /// \param size : Number of bytes to send + /// \param data : Pointer to the bytes to send + /// \param sizeInBytes : Number of bytes to send /// /// \return Status code /// //////////////////////////////////////////////////////////// - Socket::Status Send(const char* data, std::size_t size); + Socket::Status Send(const char* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Receive an array of bytes from the host (must be connected first). diff --git a/include/SFML/Network/SocketUDP.hpp b/include/SFML/Network/SocketUDP.hpp index 785e7a9f..3c9b965a 100644 --- a/include/SFML/Network/SocketUDP.hpp +++ b/include/SFML/Network/SocketUDP.hpp @@ -82,15 +82,15 @@ public : //////////////////////////////////////////////////////////// /// Send an array of bytes /// - /// \param data : Pointer to the bytes to send - /// \param size : Number of bytes to send - /// \param address : Address of the computer to send the packet to - /// \param port : Port to send the data to + /// \param data : Pointer to the bytes to send + /// \param sizeInBytes : Number of bytes to send + /// \param address : Address of the computer to send the packet to + /// \param port : Port to send the data to /// /// \return Status code /// //////////////////////////////////////////////////////////// - Socket::Status Send(const char* data, std::size_t size, const IPAddress& address, unsigned short port); + Socket::Status Send(const char* data, std::size_t sizeInBytes, const IPAddress& address, unsigned short port); //////////////////////////////////////////////////////////// /// Receive an array of bytes. diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index b73be31b..9b71a8af 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -81,7 +81,7 @@ bool Music::OpenFromFile(const std::string& filename) //////////////////////////////////////////////////////////// -bool Music::OpenFromMemory(const char* data, std::size_t sizeInBytes) +bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes) { // First stop the music if it was already running Stop(); diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index d5b56c7f..d2415dcd 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -108,7 +108,7 @@ bool SoundBuffer::LoadFromFile(const std::string& filename) //////////////////////////////////////////////////////////// -bool SoundBuffer::LoadFromMemory(const char* data, std::size_t sizeInBytes) +bool SoundBuffer::LoadFromMemory(const void* data, std::size_t sizeInBytes) { // Open the sound file priv::SoundFile file; diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp index 7271460c..5b1b462a 100644 --- a/src/SFML/Audio/SoundFile.cpp +++ b/src/SFML/Audio/SoundFile.cpp @@ -100,7 +100,7 @@ bool SoundFile::OpenRead(const std::string& filename) //////////////////////////////////////////////////////////// -bool SoundFile::OpenRead(const char* data, std::size_t sizeInBytes) +bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes) { // If the file is already opened, first close it if (myFile) @@ -246,7 +246,7 @@ int SoundFile::GetFormatFromFilename(const std::string& filename) //////////////////////////////////////////////////////////// -SF_VIRTUAL_IO SoundFile::MemoryIO::Prepare(const char* data, std::size_t sizeInBytes) +SF_VIRTUAL_IO SoundFile::MemoryIO::Prepare(const void* data, std::size_t sizeInBytes) { // Setup the I/O functions SF_VIRTUAL_IO io; @@ -257,8 +257,8 @@ SF_VIRTUAL_IO SoundFile::MemoryIO::Prepare(const char* data, std::size_t sizeInB io.write = &SoundFile::MemoryIO::Write; // Initialize the memory data - myDataStart = data; - myDataPtr = data; + myDataStart = static_cast(data); + myDataPtr = myDataStart; myTotalSize = sizeInBytes; return io; diff --git a/src/SFML/Audio/SoundFile.hpp b/src/SFML/Audio/SoundFile.hpp index 2fa50d3b..b30891d1 100644 --- a/src/SFML/Audio/SoundFile.hpp +++ b/src/SFML/Audio/SoundFile.hpp @@ -100,7 +100,7 @@ public : /// \return True if the file was successfully opened /// //////////////////////////////////////////////////////////// - bool OpenRead(const char* data, std::size_t sizeInBytes); + bool OpenRead(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief a the sound file for writing @@ -163,7 +163,7 @@ private : { public : - SF_VIRTUAL_IO Prepare(const char* data, std::size_t sizeInBytes); + SF_VIRTUAL_IO Prepare(const void* data, std::size_t sizeInBytes); private : diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index c2aa941b..6441b891 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -112,7 +112,7 @@ bool Font::LoadFromFile(const std::string& filename) //////////////////////////////////////////////////////////// -bool Font::LoadFromMemory(const char* data, std::size_t sizeInBytes) +bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes) { // Cleanup the previous resources Cleanup(); diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index eb588301..81983420 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -116,7 +116,7 @@ bool Image::LoadFromFile(const std::string& filename) //////////////////////////////////////////////////////////// /// Load the image from a file in memory //////////////////////////////////////////////////////////// -bool Image::LoadFromMemory(const char* data, std::size_t sizeInBytes) +bool Image::LoadFromMemory(const void* data, std::size_t sizeInBytes) { // Check parameters if (!data || (sizeInBytes == 0)) diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp index 07adac30..d0d49c7e 100644 --- a/src/SFML/Graphics/ImageLoader.cpp +++ b/src/SFML/Graphics/ImageLoader.cpp @@ -122,7 +122,7 @@ bool ImageLoader::LoadImageFromFile(const std::string& filename, std::vector& pixels, unsigned int& width, unsigned int& height) +bool ImageLoader::LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector& pixels, unsigned int& width, unsigned int& height) { // Clear the array (just in case) pixels.clear(); diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp index dc08a771..3cd3e0bc 100644 --- a/src/SFML/Graphics/ImageLoader.hpp +++ b/src/SFML/Graphics/ImageLoader.hpp @@ -79,7 +79,7 @@ public : /// \return True if loading was successful /// //////////////////////////////////////////////////////////// - bool LoadImageFromMemory(const char* data, std::size_t sizeInBytes, std::vector& pixels, unsigned int& width, unsigned int& height); + bool LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector& pixels, unsigned int& width, unsigned int& height); //////////////////////////////////////////////////////////// /// Save pixels to an image file diff --git a/src/SFML/Network/SocketTCP.cpp b/src/SFML/Network/SocketTCP.cpp index 13ed552a..e40c9244 100644 --- a/src/SFML/Network/SocketTCP.cpp +++ b/src/SFML/Network/SocketTCP.cpp @@ -232,18 +232,18 @@ Socket::Status SocketTCP::Accept(SocketTCP& connected, IPAddress* address) //////////////////////////////////////////////////////////// /// Send an array of bytes to the host (must be connected first) //////////////////////////////////////////////////////////// -Socket::Status SocketTCP::Send(const char* data, std::size_t size) +Socket::Status SocketTCP::Send(const char* data, std::size_t sizeInBytes) { // First check that socket is valid if (!IsValid()) return Socket::Error; // Check parameters - if (data && size) + if (data && sizeInBytes) { // Loop until every byte has been sent int sent = 0; - int sizeToSend = static_cast(size); + int sizeToSend = static_cast(sizeInBytes); for (int length = 0; length < sizeToSend; length += sent) { // Send a chunk of data diff --git a/src/SFML/Network/SocketUDP.cpp b/src/SFML/Network/SocketUDP.cpp index ee99ac30..51f7b682 100644 --- a/src/SFML/Network/SocketUDP.cpp +++ b/src/SFML/Network/SocketUDP.cpp @@ -115,14 +115,14 @@ bool SocketUDP::Unbind() //////////////////////////////////////////////////////////// /// Send an array of bytes //////////////////////////////////////////////////////////// -Socket::Status SocketUDP::Send(const char* data, std::size_t size, const IPAddress& address, unsigned short port) +Socket::Status SocketUDP::Send(const char* data, std::size_t sizeInBytes, const IPAddress& address, unsigned short port) { // Make sure the socket is valid if (!IsValid()) Create(); // Check parameters - if (data && size) + if (data && sizeInBytes) { // Build the target address sockaddr_in sockAddr; @@ -133,7 +133,7 @@ Socket::Status SocketUDP::Send(const char* data, std::size_t size, const IPAddre // Loop until every byte has been sent int sent = 0; - int sizeToSend = static_cast(size); + int sizeToSend = static_cast(sizeInBytes); for (int length = 0; length < sizeToSend; length += sent) { // Send a chunk of data