Replaced C standard headers (<xxx.h>) with their C++ version (<cxxx>)

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1545 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-08-02 20:36:27 +00:00
parent 41b29f45f8
commit ff2c4f2ee7
20 changed files with 48 additions and 53 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file> <CodeBlocks_workspace_file>
<Workspace title="SFML workspace"> <Workspace title="SFML workspace">
<Project filename="sfml-system.cbp" /> <Project filename="sfml-system.cbp" active="1" />
<Project filename="sfml-window.cbp" /> <Project filename="sfml-window.cbp" />
<Project filename="sfml-network.cbp" /> <Project filename="sfml-network.cbp" />
<Project filename="sfml-graphics.cbp" active="1" /> <Project filename="sfml-graphics.cbp" />
<Project filename="sfml-audio.cbp" /> <Project filename="sfml-audio.cbp" />
<Project filename="sfml-main.cbp" /> <Project filename="sfml-main.cbp" />
<Project filename="..\..\samples\build\codeblocks\ftp.cbp" /> <Project filename="..\..\samples\build\codeblocks\ftp.cbp" />

View File

@ -31,7 +31,7 @@
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#include <SFML/System/Vector2.hpp> #include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/Rect.hpp> #include <SFML/Graphics/Rect.hpp>
#include <math.h> #include <cmath>
namespace sf namespace sf

View File

@ -108,8 +108,8 @@ inline Matrix3 Matrix3::Transformation(const Vector2f& origin, const Vector2f& t
{ {
// Combine the transformations // Combine the transformations
float angle = rotation * 3.141592654f / 180.f; float angle = rotation * 3.141592654f / 180.f;
float cosine = static_cast<float>(cos(angle)); float cosine = static_cast<float>(std::cos(angle));
float sine = static_cast<float>(sin(angle)); float sine = static_cast<float>(std::sin(angle));
float sxCos = scale.x * cosine; float sxCos = scale.x * cosine;
float syCos = scale.y * cosine; float syCos = scale.y * cosine;
float sxSin = scale.x * sine; float sxSin = scale.x * sine;
@ -129,8 +129,8 @@ inline Matrix3 Matrix3::Projection(const Vector2f& center, const Vector2f& size,
{ {
// Rotation components // Rotation components
float angle = rotation * 3.141592654f / 180.f; float angle = rotation * 3.141592654f / 180.f;
float cosine = static_cast<float>(cos(angle)); float cosine = static_cast<float>(std::cos(angle));
float sine = static_cast<float>(sin(angle)); float sine = static_cast<float>(std::sin(angle));
float tx = -center.x * cosine - center.y * sine + center.x; float tx = -center.x * cosine - center.y * sine + center.x;
float ty = center.x * sine - center.y * cosine + center.y; float ty = center.x * sine - center.y * cosine + center.y;

View File

@ -32,7 +32,7 @@
#include <algorithm> #include <algorithm>
#include <locale> #include <locale>
#include <string> #include <string>
#include <stdlib.h> #include <cstdlib>
namespace sf namespace sf

View File

@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Audio/SoundFile.hpp> #include <SFML/Audio/SoundFile.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <string.h> #include <cstring>
namespace sf namespace sf
@ -283,7 +283,7 @@ sf_count_t SoundFile::MemoryIO::Read(void* ptr, sf_count_t count, void* userData
if (position + count >= self->myTotalSize) if (position + count >= self->myTotalSize)
count = self->myTotalSize - position; count = self->myTotalSize - position;
memcpy(ptr, self->myDataPtr, static_cast<std::size_t>(count)); std::memcpy(ptr, self->myDataPtr, static_cast<std::size_t>(count));
self->myDataPtr += count; self->myDataPtr += count;

View File

@ -28,7 +28,7 @@
#include <SFML/Graphics/Drawable.hpp> #include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Renderer.hpp> #include <SFML/Graphics/Renderer.hpp>
#include <SFML/Graphics/RenderTarget.hpp> #include <SFML/Graphics/RenderTarget.hpp>
#include <math.h> #include <cmath>
namespace sf namespace sf
@ -153,7 +153,7 @@ void Drawable::SetOrigin(const Vector2f& origin)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetRotation(float angle) void Drawable::SetRotation(float angle)
{ {
myRotation = static_cast<float>(fmod(angle, 360)); myRotation = static_cast<float>(std::fmod(angle, 360));
if (myRotation < 0) if (myRotation < 0)
myRotation += 360.f; myRotation += 360.f;

View File

@ -33,7 +33,7 @@
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <string.h> #include <cstring>
namespace sf namespace sf
@ -144,7 +144,7 @@ bool Image::LoadFromPixels(unsigned int width, unsigned int height, const Uint8*
// Fill the pixel buffer with the specified raw data // Fill the pixel buffer with the specified raw data
myPixels.resize(width * height * 4); myPixels.resize(width * height * 4);
memcpy(&myPixels[0], data, myPixels.size()); std::memcpy(&myPixels[0], data, myPixels.size());
// We can create the texture // We can create the texture
if (CreateTexture()) if (CreateTexture())
@ -312,7 +312,7 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
// Optimized copy ignoring alpha values, row by row (faster) // Optimized copy ignoring alpha values, row by row (faster)
for (int i = 0; i < rows; ++i) for (int i = 0; i < rows; ++i)
{ {
memcpy(dstPixels, srcPixels, pitch); std::memcpy(dstPixels, srcPixels, pitch);
srcPixels += srcStride; srcPixels += srcStride;
dstPixels += dstStride; dstPixels += dstStride;
} }
@ -709,7 +709,7 @@ void Image::EnsureArrayUpdate() const
for (unsigned int i = 0; i < myHeight; ++i) for (unsigned int i = 0; i < myHeight; ++i)
{ {
memcpy(dst, src, dstPitch); std::memcpy(dst, src, dstPitch);
src += srcPitch; src += srcPitch;
dst += dstPitch; dst += dstPitch;
} }

View File

@ -35,18 +35,16 @@ extern "C"
#include <jpeglib.h> #include <jpeglib.h>
#include <jerror.h> #include <jerror.h>
} }
#include <ctype.h> #include <cctype>
namespace namespace
{ {
//////////////////////////////////////////////////////////// // Convert a string to lower case
std::string ToLower(const std::string& str) std::string ToLower(std::string str)
{ {
std::string lower = str; for (std::string::iterator i = str.begin(); i != str.end(); ++i)
for (std::string::iterator it = lower.begin(); it != lower.end(); ++it) *i = static_cast<char>(std::tolower(*i));
*it = static_cast<char>(tolower(*it));
return str; return str;
} }
} }

View File

@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Shape.hpp> #include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/Renderer.hpp> #include <SFML/Graphics/Renderer.hpp>
#include <math.h> #include <cmath>
namespace sf namespace sf
@ -221,7 +221,7 @@ Shape Shape::Circle(const Vector2f& center, float radius, const Color& color, fl
for (int i = 0; i < nbSegments; ++i) for (int i = 0; i < nbSegments; ++i)
{ {
float angle = i * 2 * 3.141592654f / nbSegments; float angle = i * 2 * 3.141592654f / nbSegments;
Vector2f offset(cos(angle), sin(angle)); Vector2f offset(std::cos(angle), std::sin(angle));
shape.AddPoint(center + offset * radius, color, outlineColor); shape.AddPoint(center + offset * radius, color, outlineColor);
} }
@ -366,7 +366,7 @@ bool Shape::ComputeNormal(const Vector2f& p1, const Vector2f& p2, Vector2f& norm
normal.x = p1.y - p2.y; normal.x = p1.y - p2.y;
normal.y = p2.x - p1.x; normal.y = p2.x - p1.x;
float len = sqrt(normal.x * normal.x + normal.y * normal.y); float len = std::sqrt(normal.x * normal.x + normal.y * normal.y);
if (len == 0.f) if (len == 0.f)
return false; return false;

View File

@ -26,7 +26,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Network/Http.hpp> #include <SFML/Network/Http.hpp>
#include <ctype.h> #include <cctype>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <sstream> #include <sstream>
@ -41,7 +41,7 @@ namespace
std::string ToLower(std::string str) std::string ToLower(std::string str)
{ {
for (std::string::iterator i = str.begin(); i != str.end(); ++i) for (std::string::iterator i = str.begin(); i != str.end(); ++i)
*i = static_cast<char>(tolower(*i)); *i = static_cast<char>(std::tolower(*i));
return str; return str;
} }
} }

View File

@ -28,7 +28,6 @@
#include <SFML/Network/IpAddress.hpp> #include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Http.hpp> #include <SFML/Network/Http.hpp>
#include <SFML/Network/SocketImpl.hpp> #include <SFML/Network/SocketImpl.hpp>
#include <string.h>
namespace sf namespace sf

View File

@ -28,7 +28,7 @@
#include <SFML/Network/Packet.hpp> #include <SFML/Network/Packet.hpp>
#include <SFML/Network/SocketImpl.hpp> #include <SFML/Network/SocketImpl.hpp>
#include <SFML/System/String.hpp> #include <SFML/System/String.hpp>
#include <string.h> #include <cstring>
namespace sf namespace sf
@ -56,7 +56,7 @@ void Packet::Append(const void* data, std::size_t sizeInBytes)
{ {
std::size_t start = myData.size(); std::size_t start = myData.size();
myData.resize(start + sizeInBytes); myData.resize(start + sizeInBytes);
memcpy(&myData[start], data, sizeInBytes); std::memcpy(&myData[start], data, sizeInBytes);
} }
} }
@ -223,7 +223,7 @@ Packet& Packet::operator >>(char* data)
if ((length > 0) && CheckSize(length)) if ((length > 0) && CheckSize(length))
{ {
// Then extract characters // Then extract characters
memcpy(data, GetData() + myReadPos, length); std::memcpy(data, GetData() + myReadPos, length);
data[length] = '\0'; data[length] = '\0';
// Update reading position // Update reading position

View File

@ -31,7 +31,7 @@
#include <SFML/Network/SocketImpl.hpp> #include <SFML/Network/SocketImpl.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <algorithm> #include <algorithm>
#include <string.h> #include <cstring>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4127) // "conditional expression is constant" generated by the FD_SET macro #pragma warning(disable : 4127) // "conditional expression is constant" generated by the FD_SET macro
@ -340,7 +340,7 @@ Socket::Status TcpSocket::Receive(Packet& packet)
{ {
myPendingPacket.Data.resize(myPendingPacket.Data.size() + received); myPendingPacket.Data.resize(myPendingPacket.Data.size() + received);
char* begin = &myPendingPacket.Data[0] + myPendingPacket.Data.size() - received; char* begin = &myPendingPacket.Data[0] + myPendingPacket.Data.size() - received;
memcpy(begin, buffer, received); std::memcpy(begin, buffer, received);
} }
} }

View File

@ -31,7 +31,6 @@
#include <SFML/Network/SocketImpl.hpp> #include <SFML/Network/SocketImpl.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <algorithm> #include <algorithm>
#include <string.h>
namespace sf namespace sf

View File

@ -26,7 +26,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Network/Win32/SocketImpl.hpp> #include <SFML/Network/Win32/SocketImpl.hpp>
#include <string.h> #include <cstring>
namespace sf namespace sf
@ -37,7 +37,7 @@ namespace priv
sockaddr_in SocketImpl::CreateAddress(unsigned long address, unsigned short port) sockaddr_in SocketImpl::CreateAddress(unsigned long address, unsigned short port)
{ {
sockaddr_in addr; sockaddr_in addr;
memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); std::memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
addr.sin_addr.s_addr = htonl(address); addr.sin_addr.s_addr = htonl(address);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);

View File

@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <streambuf> #include <streambuf>
#include <stdio.h> #include <cstdio>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -26,8 +26,8 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Randomizer.hpp> #include <SFML/System/Randomizer.hpp>
#include <stdlib.h> #include <cstdlib>
#include <time.h> #include <ctime>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -39,8 +39,8 @@ namespace
// in milliseconds, so that it is always different // in milliseconds, so that it is always different
unsigned int InitializeSeed() unsigned int InitializeSeed()
{ {
unsigned int seed = static_cast<unsigned int>(time(NULL)); unsigned int seed = static_cast<unsigned int>(std::time(NULL));
srand(seed); std::srand(seed);
return seed; return seed;
} }
@ -54,7 +54,7 @@ namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Randomizer::SetSeed(unsigned int seed) void Randomizer::SetSeed(unsigned int seed)
{ {
srand(seed); std::srand(seed);
globalSeed = seed; globalSeed = seed;
} }
@ -71,7 +71,7 @@ float Randomizer::Random(float begin, float end)
{ {
// This is not the best algorithm, but it is fast and will be enough in most cases // This is not the best algorithm, but it is fast and will be enough in most cases
return static_cast<float>(rand()) / RAND_MAX * (end - begin) + begin; return static_cast<float>(std::rand()) / RAND_MAX * (end - begin) + begin;
} }
@ -82,7 +82,7 @@ int Randomizer::Random(int begin, int end)
{ {
// This is not the best algorithm, but it is fast and will be enough in most cases // This is not the best algorithm, but it is fast and will be enough in most cases
return rand() % (end - begin + 1) + begin; return std::rand() % (end - begin + 1) + begin;
} }
} // namespace sf } // namespace sf

View File

@ -28,7 +28,7 @@
#include <SFML/System/String.hpp> #include <SFML/System/String.hpp>
#include <SFML/System/Utf.hpp> #include <SFML/System/Utf.hpp>
#include <iterator> #include <iterator>
#include <string.h> #include <cstring>
namespace sf namespace sf
@ -122,7 +122,7 @@ String::String(const wchar_t* wideString)
{ {
if (wideString) if (wideString)
{ {
std::size_t length = wcslen(wideString); std::size_t length = std::wcslen(wideString);
if (length > 0) if (length > 0)
{ {
myString.reserve(length + 1); myString.reserve(length + 1);

View File

@ -27,7 +27,6 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Utf.hpp> #include <SFML/System/Utf.hpp>
#include <exception> #include <exception>
#include <string.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -29,7 +29,7 @@
#include <SFML/System/ThreadLocalPtr.hpp> #include <SFML/System/ThreadLocalPtr.hpp>
#include <SFML/OpenGL.hpp> #include <SFML/OpenGL.hpp>
#include <SFML/Window/glext/glext.h> #include <SFML/Window/glext/glext.h>
#include <stdlib.h> #include <cstdlib>
#if defined(SFML_SYSTEM_WINDOWS) #if defined(SFML_SYSTEM_WINDOWS)
@ -167,10 +167,10 @@ GlContext::GlContext()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
int GlContext::EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing) int GlContext::EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing)
{ {
return abs(static_cast<int>(bitsPerPixel - colorBits)) + return std::abs(static_cast<int>(bitsPerPixel - colorBits)) +
abs(static_cast<int>(settings.DepthBits - depthBits)) + std::abs(static_cast<int>(settings.DepthBits - depthBits)) +
abs(static_cast<int>(settings.StencilBits - stencilBits)) + std::abs(static_cast<int>(settings.StencilBits - stencilBits)) +
abs(static_cast<int>(settings.AntialiasingLevel - antialiasing)); std::abs(static_cast<int>(settings.AntialiasingLevel - antialiasing));
} }
} // namespace priv } // namespace priv