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
This commit is contained in:
parent
b60fda48d9
commit
47d019098c
@ -52,7 +52,7 @@ CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename);
|
|||||||
/// \return A new sfMusic object (NULL if failed)
|
/// \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
|
/// Destroy an existing music
|
||||||
|
@ -51,7 +51,7 @@ CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename);
|
|||||||
/// \return A new sfSoundBuffer object (NULL if failed)
|
/// \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
|
/// Create a new sound buffer and load it from an array of
|
||||||
|
@ -51,7 +51,7 @@ CSFML_API sfFont* sfFont_CreateFromFile(const char* filename);
|
|||||||
/// \return A new sfFont object, or NULL if it failed
|
/// \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
|
/// Copy an existing font
|
||||||
|
@ -85,7 +85,7 @@ CSFML_API sfImage* sfImage_CreateFromFile(const char* filename);
|
|||||||
/// \return A new sfImage object, or NULL if it failed
|
/// \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
|
/// Copy an existing image
|
||||||
|
@ -50,7 +50,7 @@ sfMusic* sfMusic_CreateFromFile(const char* filename)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Create a new music and load it from a file in memory
|
/// 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;
|
sfMusic* music = new sfMusic;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Create a new sound buffer and load it from a file in memory
|
/// 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;
|
sfSoundBuffer* buffer = new sfSoundBuffer;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ sfFont* sfFont_CreateFromFile(const char* filename)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Create a new font from a file in memory
|
/// 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;
|
sfFont* font = new sfFont;
|
||||||
if (!font->This.LoadFromMemory(data, sizeInBytes))
|
if (!font->This.LoadFromMemory(data, sizeInBytes))
|
||||||
|
@ -94,7 +94,7 @@ sfImage* sfImage_CreateFromFile(const char* filename)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Create a new image from a file in memory
|
/// 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;
|
sfImage* image = new sfImage;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public :
|
|||||||
/// \see OpenFromFile
|
/// \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
|
/// \brief Get the total duration of the music
|
||||||
|
@ -98,7 +98,7 @@ public :
|
|||||||
/// \see LoadFromFile, LoadFromSamples, SaveToFile
|
/// \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
|
/// \brief Load the sound buffer from an array of audio samples
|
||||||
|
@ -108,7 +108,7 @@ public :
|
|||||||
/// \see LoadFromFile
|
/// \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
|
/// \brief Retrieve a glyph of the font
|
||||||
|
@ -87,7 +87,7 @@ public :
|
|||||||
/// \return True if loading was successful
|
/// \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
|
/// Load the image directly from an array of pixels
|
||||||
|
@ -99,12 +99,12 @@ public :
|
|||||||
/// Send an array of bytes to the host (must be connected first)
|
/// Send an array of bytes to the host (must be connected first)
|
||||||
///
|
///
|
||||||
/// \param data : Pointer to the bytes to send
|
/// \param data : Pointer to the bytes to send
|
||||||
/// \param size : Number of bytes to send
|
/// \param sizeInBytes : Number of bytes to send
|
||||||
///
|
///
|
||||||
/// \return Status code
|
/// \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).
|
/// Receive an array of bytes from the host (must be connected first).
|
||||||
|
@ -83,14 +83,14 @@ public :
|
|||||||
/// Send an array of bytes
|
/// Send an array of bytes
|
||||||
///
|
///
|
||||||
/// \param data : Pointer to the bytes to send
|
/// \param data : Pointer to the bytes to send
|
||||||
/// \param size : Number of bytes to send
|
/// \param sizeInBytes : Number of bytes to send
|
||||||
/// \param address : Address of the computer to send the packet to
|
/// \param address : Address of the computer to send the packet to
|
||||||
/// \param port : Port to send the data to
|
/// \param port : Port to send the data to
|
||||||
///
|
///
|
||||||
/// \return Status code
|
/// \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.
|
/// Receive an array of bytes.
|
||||||
|
@ -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
|
// First stop the music if it was already running
|
||||||
Stop();
|
Stop();
|
||||||
|
@ -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
|
// Open the sound file
|
||||||
priv::SoundFile file;
|
priv::SoundFile file;
|
||||||
|
@ -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 the file is already opened, first close it
|
||||||
if (myFile)
|
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
|
// Setup the I/O functions
|
||||||
SF_VIRTUAL_IO io;
|
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;
|
io.write = &SoundFile::MemoryIO::Write;
|
||||||
|
|
||||||
// Initialize the memory data
|
// Initialize the memory data
|
||||||
myDataStart = data;
|
myDataStart = static_cast<const char*>(data);
|
||||||
myDataPtr = data;
|
myDataPtr = myDataStart;
|
||||||
myTotalSize = sizeInBytes;
|
myTotalSize = sizeInBytes;
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
|
@ -100,7 +100,7 @@ public :
|
|||||||
/// \return True if the file was successfully opened
|
/// \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
|
/// \brief a the sound file for writing
|
||||||
@ -163,7 +163,7 @@ private :
|
|||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
SF_VIRTUAL_IO Prepare(const char* data, std::size_t sizeInBytes);
|
SF_VIRTUAL_IO Prepare(const void* data, std::size_t sizeInBytes);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
@ -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 the previous resources
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
@ -116,7 +116,7 @@ bool Image::LoadFromFile(const std::string& filename)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Load the image from a file in memory
|
/// 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
|
// Check parameters
|
||||||
if (!data || (sizeInBytes == 0))
|
if (!data || (sizeInBytes == 0))
|
||||||
|
@ -122,7 +122,7 @@ bool ImageLoader::LoadImageFromFile(const std::string& filename, std::vector<Col
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Load pixels from an image file in memory
|
/// Load pixels from an image file in memory
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool ImageLoader::LoadImageFromMemory(const char* data, std::size_t sizeInBytes, std::vector<Color>& pixels, unsigned int& width, unsigned int& height)
|
bool ImageLoader::LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector<Color>& pixels, unsigned int& width, unsigned int& height)
|
||||||
{
|
{
|
||||||
// Clear the array (just in case)
|
// Clear the array (just in case)
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
|
@ -79,7 +79,7 @@ public :
|
|||||||
/// \return True if loading was successful
|
/// \return True if loading was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool LoadImageFromMemory(const char* data, std::size_t sizeInBytes, std::vector<Color>& pixels, unsigned int& width, unsigned int& height);
|
bool LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector<Color>& pixels, unsigned int& width, unsigned int& height);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Save pixels to an image file
|
/// Save pixels to an image file
|
||||||
|
@ -232,18 +232,18 @@ Socket::Status SocketTCP::Accept(SocketTCP& connected, IPAddress* address)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Send an array of bytes to the host (must be connected first)
|
/// 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
|
// First check that socket is valid
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return Socket::Error;
|
return Socket::Error;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (data && size)
|
if (data && sizeInBytes)
|
||||||
{
|
{
|
||||||
// Loop until every byte has been sent
|
// Loop until every byte has been sent
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
int sizeToSend = static_cast<int>(size);
|
int sizeToSend = static_cast<int>(sizeInBytes);
|
||||||
for (int length = 0; length < sizeToSend; length += sent)
|
for (int length = 0; length < sizeToSend; length += sent)
|
||||||
{
|
{
|
||||||
// Send a chunk of data
|
// Send a chunk of data
|
||||||
|
@ -115,14 +115,14 @@ bool SocketUDP::Unbind()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Send an array of bytes
|
/// 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
|
// Make sure the socket is valid
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
Create();
|
Create();
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (data && size)
|
if (data && sizeInBytes)
|
||||||
{
|
{
|
||||||
// Build the target address
|
// Build the target address
|
||||||
sockaddr_in sockAddr;
|
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
|
// Loop until every byte has been sent
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
int sizeToSend = static_cast<int>(size);
|
int sizeToSend = static_cast<int>(sizeInBytes);
|
||||||
for (int length = 0; length < sizeToSend; length += sent)
|
for (int length = 0; length < sizeToSend; length += sent)
|
||||||
{
|
{
|
||||||
// Send a chunk of data
|
// Send a chunk of data
|
||||||
|
Loading…
Reference in New Issue
Block a user