mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
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)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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).
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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<const char*>(data);
|
||||
myDataPtr = myDataStart;
|
||||
myTotalSize = sizeInBytes;
|
||||
|
||||
return io;
|
||||
|
@ -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 :
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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))
|
||||
|
@ -122,7 +122,7 @@ bool ImageLoader::LoadImageFromFile(const std::string& filename, std::vector<Col
|
||||
////////////////////////////////////////////////////////////
|
||||
/// 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)
|
||||
pixels.clear();
|
||||
|
@ -79,7 +79,7 @@ public :
|
||||
/// \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
|
||||
|
@ -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<int>(size);
|
||||
int sizeToSend = static_cast<int>(sizeInBytes);
|
||||
for (int length = 0; length < sizeToSend; length += sent)
|
||||
{
|
||||
// Send a chunk of data
|
||||
|
@ -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<int>(size);
|
||||
int sizeToSend = static_cast<int>(sizeInBytes);
|
||||
for (int length = 0; length < sizeToSend; length += sent)
|
||||
{
|
||||
// Send a chunk of data
|
||||
|
Loading…
Reference in New Issue
Block a user