Externals: Update SFML to 2.5.0

Among other things, this finally allows pushing 64-bit values into
packets without needing to manually subdivide the value into two 32-bit
values.
This commit is contained in:
Lioncash
2018-08-27 16:55:32 -04:00
parent 4c75331d5d
commit 3130d388db
39 changed files with 1144 additions and 283 deletions

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -30,13 +30,15 @@
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 2
#define SFML_VERSION_MINOR 1
#define SFML_VERSION_MINOR 5
#define SFML_VERSION_PATCH 0
////////////////////////////////////////////////////////////
// Identify the operating system
// see http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__)
#if defined(_WIN32)
// Windows
#define SFML_SYSTEM_WINDOWS
@ -44,20 +46,57 @@
#define NOMINMAX
#endif
#elif defined(linux) || defined(__linux)
#elif defined(__APPLE__) && defined(__MACH__)
// Linux
#define SFML_SYSTEM_LINUX
// Apple platform, see which one it is
#include "TargetConditionals.h"
#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
// MacOS
#define SFML_SYSTEM_MACOS
// iOS
#define SFML_SYSTEM_IOS
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif TARGET_OS_MAC
// FreeBSD
#define SFML_SYSTEM_FREEBSD
// MacOS
#define SFML_SYSTEM_MACOS
#else
// Unsupported Apple system
#error This Apple operating system is not supported by SFML library
#endif
#elif defined(__unix__)
// UNIX system, see which one it is
#if defined(__ANDROID__)
// Android
#define SFML_SYSTEM_ANDROID
#elif defined(__linux__)
// Linux
#define SFML_SYSTEM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define SFML_SYSTEM_FREEBSD
#elif defined(__OpenBSD__)
// OpenBSD
#define SFML_SYSTEM_OPENBSD
#else
// Unsupported UNIX system
#error This UNIX operating system is not supported by SFML library
#endif
#else
@ -91,7 +130,7 @@
// For Visual C++ compilers, we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#pragma warning(disable: 4251)
#endif
@ -123,6 +162,44 @@
#endif
////////////////////////////////////////////////////////////
// Cross-platform warning for deprecated functions and classes
//
// Usage:
// class SFML_DEPRECATED MyClass
// {
// SFML_DEPRECATED void memberFunc();
// };
//
// SFML_DEPRECATED void globalFunc();
////////////////////////////////////////////////////////////
#if defined(SFML_NO_DEPRECATED_WARNINGS)
// User explicitly requests to disable deprecation warnings
#define SFML_DEPRECATED
#elif defined(_MSC_VER)
// Microsoft C++ compiler
// Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to
// trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.
#define SFML_DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
// g++ and Clang
#define SFML_DEPRECATED __attribute__ ((deprecated))
#else
// Other compilers are not supported, leave class or function as-is.
// With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.
#pragma message("SFML_DEPRECATED is not supported for your compiler, please contact the SFML team")
#define SFML_DEPRECATED
#endif
////////////////////////////////////////////////////////////
// Define portable fixed-size types
////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -36,6 +36,8 @@
// This file is "IpAddress.hpp" upstream
#include <SFML/Network/IPAddress.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/SocketHandle.hpp>
#include <SFML/Network/SocketSelector.hpp>
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpSocket.hpp>

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -45,7 +45,7 @@ namespace sf
////////////////////////////////////////////////////////////
class SFML_NETWORK_API Http : NonCopyable
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Define a HTTP request
@ -53,7 +53,7 @@ public :
////////////////////////////////////////////////////////////
class SFML_NETWORK_API Request
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Enumerate the available HTTP methods for a request
@ -61,9 +61,11 @@ public :
////////////////////////////////////////////////////////////
enum Method
{
Get, ///< Request in get mode, standard method to retrieve a page
Post, ///< Request in post mode, usually to send data to a page
Head ///< Request a page's header only
Get, ///< Request in get mode, standard method to retrieve a page
Post, ///< Request in post mode, usually to send data to a page
Head, ///< Request a page's header only
Put, ///< Request in put mode, useful for a REST API
Delete ///< Request in delete mode, useful for a REST API
};
////////////////////////////////////////////////////////////
@ -83,7 +85,7 @@ public :
/// \brief Set the value of a field
///
/// The field is created if it doesn't exist. The name of
/// the field is case insensitive.
/// the field is case-insensitive.
/// By default, a request doesn't contain any field (but the
/// mandatory fields are added later by the HTTP client when
/// sending the request).
@ -141,7 +143,7 @@ public :
////////////////////////////////////////////////////////////
void setBody(const std::string& body);
private :
private:
friend class Http;
@ -190,7 +192,7 @@ public :
////////////////////////////////////////////////////////////
class SFML_NETWORK_API Response
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Enumerate all the valid status codes for a response
@ -210,12 +212,12 @@ public :
MultipleChoices = 300, ///< The requested page can be accessed from several locations
MovedPermanently = 301, ///< The requested page has permanently moved to a new location
MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
NotModified = 304, ///< For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed
NotModified = 304, ///< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed
// 4xx: client error
BadRequest = 400, ///< The server couldn't understand the request (syntax error)
Unauthorized = 401, ///< The requested page needs an authentification to be accessed
Forbidden = 403, ///< The requested page cannot be accessed at all, even with authentification
Unauthorized = 401, ///< The requested page needs an authentication to be accessed
Forbidden = 403, ///< The requested page cannot be accessed at all, even with authentication
NotFound = 404, ///< The requested page doesn't exist
RangeNotSatisfiable = 407, ///< The server can't satisfy the partial GET request (with a "Range" header field)
@ -301,7 +303,7 @@ public :
////////////////////////////////////////////////////////////
const std::string& getBody() const;
private :
private:
friend class Http;
@ -316,6 +318,18 @@ public :
////////////////////////////////////////////////////////////
void parse(const std::string& data);
////////////////////////////////////////////////////////////
/// \brief Read values passed in the answer header
///
/// This function is used by Http to extract values passed
/// in the response.
///
/// \param in String stream containing the header values
///
////////////////////////////////////////////////////////////
void parseFields(std::istream &in);
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
@ -343,9 +357,9 @@ public :
/// This is equivalent to calling setHost(host, port).
/// The port has a default value of 0, which means that the
/// HTTP client will use the right port according to the
/// protocol used (80 for HTTP, 443 for HTTPS). You should
/// leave it like this unless you really need a port other
/// than the standard one, or use an unknown protocol.
/// protocol used (80 for HTTP). You should leave it like
/// this unless you really need a port other than the
/// standard one, or use an unknown protocol.
///
/// \param host Web server to connect to
/// \param port Port to use for connection
@ -360,9 +374,9 @@ public :
/// doesn't actually connect to it until you send a request.
/// The port has a default value of 0, which means that the
/// HTTP client will use the right port according to the
/// protocol used (80 for HTTP, 443 for HTTPS). You should
/// leave it like this unless you really need a port other
/// than the standard one, or use an unknown protocol.
/// protocol used (80 for HTTP). You should leave it like
/// this unless you really need a port other than the
/// standard one, or use an unknown protocol.
///
/// \param host Web server to connect to
/// \param port Port to use for connection
@ -379,7 +393,7 @@ public :
/// Warning: this function waits for the server's response and may
/// not return instantly; use a thread if you don't want to block your
/// application, or use a timeout to limit the time to wait. A value
/// of Time::Zero means that the client will use the system defaut timeout
/// of Time::Zero means that the client will use the system default timeout
/// (which is usually pretty long).
///
/// \param request Request to send
@ -390,7 +404,7 @@ public :
////////////////////////////////////////////////////////////
Response sendRequest(const Request& request, Time timeout = Time::Zero);
private :
private:
////////////////////////////////////////////////////////////
// Member data
@ -414,7 +428,8 @@ private :
/// sf::Http is a very simple HTTP client that allows you
/// to communicate with a web server. You can retrieve
/// web pages, send data to an interactive resource,
/// download a remote file, etc.
/// download a remote file, etc. The HTTPS protocol is
/// not supported.
///
/// The HTTP client is split into 3 classes:
/// \li sf::Http::Request

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -43,7 +43,7 @@ namespace sf
////////////////////////////////////////////////////////////
class SFML_NETWORK_API IpAddress
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -99,7 +99,7 @@ public :
/// This constructor uses the internal representation of
/// the address directly. It should be used for optimization
/// purposes, and only if you got that representation from
/// IpAddress::ToInteger().
/// IpAddress::toInteger().
///
/// \param address 4 bytes of the address packed into a 32-bits integer
///
@ -182,15 +182,27 @@ public :
// Static member data
////////////////////////////////////////////////////////////
static const IpAddress None; ///< Value representing an empty/invalid address
static const IpAddress Any; ///< Value representing any address (0.0.0.0)
static const IpAddress LocalHost; ///< The "localhost" address (for connecting a computer to itself locally)
static const IpAddress Broadcast; ///< The "broadcast" address (for sending UDP messages to everyone on a local network)
private :
private:
friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Resolve the given address string
///
/// \param address Address string
///
////////////////////////////////////////////////////////////
void resolve(const std::string& address);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Uint32 m_address; ///< Address stored as an unsigned 32 bits integer
bool m_valid; ///< Is the address valid?
};
////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -49,7 +49,7 @@ class SFML_NETWORK_API Packet
// A bool-like type that cannot be converted to integer or pointer types
typedef bool (Packet::*BoolType)(std::size_t);
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -139,7 +139,7 @@ public:
/// A packet will be in an invalid state if it has no more
/// data to read.
///
/// This behaviour is the same as standard C++ streams.
/// This behavior is the same as standard C++ streams.
///
/// Usage example:
/// \code
@ -171,41 +171,165 @@ public:
operator BoolType() const;
////////////////////////////////////////////////////////////
/// Overloads of operator >> to read data from the packet
/// Overload of operator >> to read data from the packet
///
////////////////////////////////////////////////////////////
Packet& operator >>(bool& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int8& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint8& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int16& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint16& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int32& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint32& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int64& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint64& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(float& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(double& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(char* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(std::string& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(wchar_t* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(std::wstring& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(String& data);
////////////////////////////////////////////////////////////
/// Overloads of operator << to write data into the packet
/// Overload of operator << to write data into the packet
///
////////////////////////////////////////////////////////////
Packet& operator <<(bool data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(float data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(double data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const char* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const std::string& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const wchar_t* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const std::wstring& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const String& data);
protected:
@ -238,7 +362,7 @@ protected:
///
/// This function can be defined by derived classes to
/// transform the data after it is received; this can be
/// used for uncompression, decryption, etc.
/// used for decompression, decryption, etc.
/// The function receives a pointer to the received data,
/// and must fill the packet with the transformed bytes.
/// The default implementation fills the packet directly
@ -252,7 +376,7 @@ protected:
////////////////////////////////////////////////////////////
virtual void onReceive(const void* data, std::size_t size);
private :
private:
////////////////////////////////////////////////////////////
/// Disallow comparisons between packets
@ -278,6 +402,7 @@ private :
////////////////////////////////////////////////////////////
std::vector<char> m_data; ///< Data stored in the packet
std::size_t m_readPos; ///< Current reading position in the packet
std::size_t m_sendPos; ///< Current send position in the packet (for handling partial sends)
bool m_isValid; ///< Reading state of the packet
};
@ -296,12 +421,12 @@ private :
/// (sf::TcpSocket, sf::UdpSocket).
///
/// Packets solve 2 fundamental problems that arise when
/// transfering data over the network:
/// transferring data over the network:
/// \li data is interpreted correctly according to the endianness
/// \li the bounds of the packet are preserved (one send == one receive)
///
/// The sf::Packet class provides both input and output modes.
/// It is designed to follow the behaviour of standard C++ streams,
/// It is designed to follow the behavior of standard C++ streams,
/// using operators >> and << to extract and insert data.
///
/// It is recommended to use only fixed-size types (like sf::Int32, etc.),

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -44,7 +44,7 @@ class SocketSelector;
////////////////////////////////////////////////////////////
class SFML_NETWORK_API Socket : NonCopyable
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Status codes that may be returned by socket functions
@ -54,6 +54,7 @@ public :
{
Done, ///< The socket has sent / received the data
NotReady, ///< The socket is not ready to send / receive data yet
Partial, ///< The socket sent a part of the data
Disconnected, ///< The TCP socket has been disconnected
Error ///< An unexpected error happened
};
@ -67,7 +68,7 @@ public :
AnyPort = 0 ///< Special value that tells the system to pick any available port
};
public :
public:
////////////////////////////////////////////////////////////
/// \brief Destructor
@ -104,7 +105,7 @@ public :
////////////////////////////////////////////////////////////
bool isBlocking() const;
protected :
protected:
////////////////////////////////////////////////////////////
/// \brief Types of protocols that the socket can use
@ -165,7 +166,7 @@ protected :
////////////////////////////////////////////////////////////
void close();
private :
private:
friend class SocketSelector;

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -42,7 +42,7 @@ class Socket;
////////////////////////////////////////////////////////////
class SFML_NETWORK_API SocketSelector
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -151,7 +151,7 @@ public :
////////////////////////////////////////////////////////////
SocketSelector& operator =(const SocketSelector& right);
private :
private:
struct SocketSelectorImpl;
@ -188,7 +188,7 @@ private :
/// (socket classes are not copyable anyway), it simply keeps
/// a reference to the original sockets that you pass to the
/// "add" function. Therefore, you can't use the selector as a
/// socket container, you must store them oustide and make sure
/// socket container, you must store them outside and make sure
/// that they are alive as long as they are used in the selector.
///
/// Using a selector is simple:

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/IPAddress.hpp>
namespace sf
@ -42,7 +43,7 @@ class TcpSocket;
////////////////////////////////////////////////////////////
class SFML_NETWORK_API TcpListener : public Socket
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -64,21 +65,24 @@ public :
unsigned short getLocalPort() const;
////////////////////////////////////////////////////////////
/// \brief Start listening for connections
/// \brief Start listening for incoming connection attempts
///
/// This functions makes the socket listen to the specified
/// port, waiting for new connections.
/// If the socket was previously listening to another port,
/// it will be stopped first and bound to the new port.
/// This function makes the socket start listening on the
/// specified port, waiting for incoming connection attempts.
///
/// \param port Port to listen for new connections
/// If the socket is already listening on a port when this
/// function is called, it will stop listening on the old
/// port before starting to listen on the new port.
///
/// \param port Port to listen on for incoming connection attempts
/// \param address Address of the interface to listen on
///
/// \return Status code
///
/// \see accept, close
///
////////////////////////////////////////////////////////////
Status listen(unsigned short port);
Status listen(unsigned short port, const IpAddress& address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Stop listening and close the socket

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -45,7 +45,7 @@ class Packet;
////////////////////////////////////////////////////////////
class SFML_NETWORK_API TcpSocket : public Socket
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -97,7 +97,8 @@ public :
/// In blocking mode, this function may take a while, especially
/// if the remote peer is not reachable. The last parameter allows
/// you to stop trying to connect after a given timeout.
/// If the socket was previously connected, it is first disconnected.
/// If the socket is already connected, the connection is
/// forcibly disconnected before attempting to connect again.
///
/// \param remoteAddress Address of the remote peer
/// \param remotePort Port of the remote peer
@ -124,6 +125,9 @@ public :
////////////////////////////////////////////////////////////
/// \brief Send raw data to the remote peer
///
/// To be able to handle partial sends over non-blocking
/// sockets, use the send(const void*, std::size_t, std::size_t&)
/// overload instead.
/// This function will fail if the socket is not connected.
///
/// \param data Pointer to the sequence of bytes to send
@ -136,6 +140,22 @@ public :
////////////////////////////////////////////////////////////
Status send(const void* data, std::size_t size);
////////////////////////////////////////////////////////////
/// \brief Send raw data to the remote peer
///
/// This function will fail if the socket is not connected.
///
/// \param data Pointer to the sequence of bytes to send
/// \param size Number of bytes to send
/// \param sent The number of bytes sent will be written here
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(const void* data, std::size_t size, std::size_t& sent);
////////////////////////////////////////////////////////////
/// \brief Receive raw data from the remote peer
///
@ -157,6 +177,10 @@ public :
////////////////////////////////////////////////////////////
/// \brief Send a formatted packet of data to the remote peer
///
/// In non-blocking mode, if this function returns sf::Socket::Partial,
/// you \em must retry sending the same unmodified packet before sending
/// anything else in order to guarantee the packet arrives at the remote
/// peer uncorrupted.
/// This function will fail if the socket is not connected.
///
/// \param packet Packet to send
@ -244,7 +268,7 @@ private:
/// class to get more details about how they work.
///
/// The socket is automatically disconnected when it is destroyed,
/// but if you want to explicitely close the connection while
/// but if you want to explicitly close the connection while
/// the socket instance is still alive, you can call disconnect.
///
/// Usage example:

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -30,12 +30,12 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/IPAddress.hpp>
#include <vector>
namespace sf
{
class IpAddress;
class Packet;
////////////////////////////////////////////////////////////
@ -44,7 +44,7 @@ class Packet;
////////////////////////////////////////////////////////////
class SFML_NETWORK_API UdpSocket : public Socket
{
public :
public:
////////////////////////////////////////////////////////////
// Constants
@ -82,21 +82,29 @@ public :
/// system to automatically pick an available port, and then
/// call getLocalPort to retrieve the chosen port.
///
/// \param port Port to bind the socket to
/// Since the socket can only be bound to a single port at
/// any given moment, if it is already bound when this
/// function is called, it will be unbound from the previous
/// port before being bound to the new one.
///
/// \param port Port to bind the socket to
/// \param address Address of the interface to bind to
///
/// \return Status code
///
/// \see unbind, getLocalPort
///
////////////////////////////////////////////////////////////
Status bind(unsigned short port);
Status bind(unsigned short port, const IpAddress& address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Unbind the socket from the local port to which it is bound
///
/// The port that the socket was previously using is immediately
/// available after this function is called. If the
/// socket is not bound to a port, this function has no effect.
/// The port that the socket was previously bound to is immediately
/// made available to the operating system after this function is called.
/// This means that a subsequent call to bind() will be able to re-bind
/// the port if no other process has done so in the mean time.
/// If the socket is not bound to a port, this function has no effect.
///
/// \see bind
///
@ -235,7 +243,7 @@ private:
///
/// If the socket is bound to a port, it is automatically
/// unbound from it when the socket is destroyed. However,
/// you can unbind the socket explicitely with the Unbind
/// you can unbind the socket explicitly with the Unbind
/// function if necessary, to stop receiving messages or
/// make the port available for other sockets.
///

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -36,10 +36,12 @@
//#include <SFML/System/Lock.hpp>
//#include <SFML/System/Mutex.hpp>
//#include <SFML/System/Sleep.hpp>
#include <SFML/System/NonCopyable.hpp>
#include <SFML/System/String.hpp>
//#include <SFML/System/Thread.hpp>
//#include <SFML/System/ThreadLocal.hpp>
//#include <SFML/System/ThreadLocalPtr.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/System/Utf.hpp>
//#include <SFML/System/Vector2.hpp>
//#include <SFML/System/Vector3.hpp>
@ -50,7 +52,7 @@
/// \defgroup system System module
///
/// Base module of SFML, defining various utilities. It provides
/// vector classes, unicode strings and conversion functions,
/// vector classes, Unicode strings and conversion functions,
/// threads and mutexes, timing classes.
///
////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -58,7 +58,7 @@ SFML_SYSTEM_API std::ostream& err();
/// insertion operations defined by the STL
/// (operator <<, manipulators, etc.).
///
/// sf::err() can be redirected to write to another output, independantly
/// sf::err() can be redirected to write to another output, independently
/// of std::cerr, by using the rdbuf() function provided by the
/// std::ostream class.
///
@ -75,4 +75,6 @@ SFML_SYSTEM_API std::ostream& err();
/// sf::err().rdbuf(previous);
/// \endcode
///
/// \return Reference to std::ostream representing the SFML error stream
///
////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -40,19 +40,29 @@ namespace sf
////////////////////////////////////////////////////////////
class SFML_SYSTEM_API NonCopyable
{
protected :
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Because this class has a copy constructor, the compiler
/// will not automatically generate the default constructor.
/// That's why we must define it explicitely.
/// That's why we must define it explicitly.
///
////////////////////////////////////////////////////////////
NonCopyable() {}
////////////////////////////////////////////////////////////
/// \brief Default destructor
///
/// By declaring a protected destructor it's impossible to
/// call delete on a pointer of sf::NonCopyable, thus
/// preventing possible resource leaks.
///
////////////////////////////////////////////////////////////
~NonCopyable() {}
private :
private:
////////////////////////////////////////////////////////////
/// \brief Disabled copy constructor
@ -89,7 +99,7 @@ private :
/// \class sf::NonCopyable
/// \ingroup system
///
/// This class makes its instances non-copyable, by explicitely
/// This class makes its instances non-copyable, by explicitly
/// disabling its copy constructor and its assignment operator.
///
/// To create a non-copyable class, simply inherit from

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -29,6 +29,8 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <SFML/System/Utf.hpp>
#include <iterator>
#include <locale>
#include <string>
@ -42,13 +44,13 @@ namespace sf
////////////////////////////////////////////////////////////
class SFML_SYSTEM_API String
{
public :
public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::basic_string<Uint32>::iterator Iterator; ///< Iterator type
typedef std::basic_string<Uint32>::const_iterator ConstIterator; ///< Constant iterator type
typedef std::basic_string<Uint32>::const_iterator ConstIterator; ///< Read-only iterator type
////////////////////////////////////////////////////////////
// Static member data
@ -156,10 +158,56 @@ public :
String(const String& copy);
////////////////////////////////////////////////////////////
/// \brief Implicit cast operator to std::string (ANSI string)
/// \brief Create a new sf::String from a UTF-8 encoded string
///
/// \param begin Forward iterator to the beginning of the UTF-8 sequence
/// \param end Forward iterator to the end of the UTF-8 sequence
///
/// \return A sf::String containing the source string
///
/// \see fromUtf16, fromUtf32
///
////////////////////////////////////////////////////////////
template <typename T>
static String fromUtf8(T begin, T end);
////////////////////////////////////////////////////////////
/// \brief Create a new sf::String from a UTF-16 encoded string
///
/// \param begin Forward iterator to the beginning of the UTF-16 sequence
/// \param end Forward iterator to the end of the UTF-16 sequence
///
/// \return A sf::String containing the source string
///
/// \see fromUtf8, fromUtf32
///
////////////////////////////////////////////////////////////
template <typename T>
static String fromUtf16(T begin, T end);
////////////////////////////////////////////////////////////
/// \brief Create a new sf::String from a UTF-32 encoded string
///
/// This function is provided for consistency, it is equivalent to
/// using the constructors that takes a const sf::Uint32* or
/// a std::basic_string<sf::Uint32>.
///
/// \param begin Forward iterator to the beginning of the UTF-32 sequence
/// \param end Forward iterator to the end of the UTF-32 sequence
///
/// \return A sf::String containing the source string
///
/// \see fromUtf8, fromUtf16
///
////////////////////////////////////////////////////////////
template <typename T>
static String fromUtf32(T begin, T end);
////////////////////////////////////////////////////////////
/// \brief Implicit conversion operator to std::string (ANSI string)
///
/// The current global locale is used for conversion. If you
/// want to explicitely specify a locale, see toAnsiString.
/// want to explicitly specify a locale, see toAnsiString.
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
/// This operator is defined for convenience, and is equivalent
@ -173,7 +221,7 @@ public :
operator std::string() const;
////////////////////////////////////////////////////////////
/// \brief Implicit cast operator to std::wstring (wide string)
/// \brief Implicit conversion operator to std::wstring (wide string)
///
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
@ -188,7 +236,7 @@ public :
operator std::wstring() const;
////////////////////////////////////////////////////////////
/// \brief Convert the unicode string to an ANSI string
/// \brief Convert the Unicode string to an ANSI string
///
/// The UTF-32 string is converted to an ANSI string in
/// the encoding defined by \a locale.
@ -205,7 +253,7 @@ public :
std::string toAnsiString(const std::locale& locale = std::locale()) const;
////////////////////////////////////////////////////////////
/// \brief Convert the unicode string to a wide string
/// \brief Convert the Unicode string to a wide string
///
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
@ -217,6 +265,39 @@ public :
////////////////////////////////////////////////////////////
std::wstring toWideString() const;
////////////////////////////////////////////////////////////
/// \brief Convert the Unicode string to a UTF-8 string
///
/// \return Converted UTF-8 string
///
/// \see toUtf16, toUtf32
///
////////////////////////////////////////////////////////////
std::basic_string<Uint8> toUtf8() const;
////////////////////////////////////////////////////////////
/// \brief Convert the Unicode string to a UTF-16 string
///
/// \return Converted UTF-16 string
///
/// \see toUtf8, toUtf32
///
////////////////////////////////////////////////////////////
std::basic_string<Uint16> toUtf16() const;
////////////////////////////////////////////////////////////
/// \brief Convert the Unicode string to a UTF-32 string
///
/// This function doesn't perform any conversion, since the
/// string is already stored as UTF-32 internally.
///
/// \return Converted UTF-32 string
///
/// \see toUtf8, toUtf16
///
////////////////////////////////////////////////////////////
std::basic_string<Uint32> toUtf32() const;
////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
@ -241,7 +322,7 @@ public :
/// \brief Overload of [] operator to access a character by its position
///
/// This function provides read-only access to characters.
/// Note: this function doesn't throw if \a index is out of range.
/// Note: the behavior is undefined if \a index is out of range.
///
/// \param index Index of the character to get
///
@ -254,7 +335,7 @@ public :
/// \brief Overload of [] operator to access a character by its position
///
/// This function provides read and write access to characters.
/// Note: this function doesn't throw if \a index is out of range.
/// Note: the behavior is undefined if \a index is out of range.
///
/// \param index Index of the character to get
///
@ -321,7 +402,7 @@ public :
/// \brief Find a sequence of one or more characters in the string
///
/// This function searches for the characters of \a str
/// into the string, starting from \a start.
/// in the string, starting from \a start.
///
/// \param str Characters to find
/// \param start Where to begin searching
@ -331,6 +412,49 @@ public :
////////////////////////////////////////////////////////////
std::size_t find(const String& str, std::size_t start = 0) const;
////////////////////////////////////////////////////////////
/// \brief Replace a substring with another string
///
/// This function replaces the substring that starts at index \a position
/// and spans \a length characters with the string \a replaceWith.
///
/// \param position Index of the first character to be replaced
/// \param length Number of characters to replace. You can pass InvalidPos to
/// replace all characters until the end of the string.
/// \param replaceWith String that replaces the given substring.
///
////////////////////////////////////////////////////////////
void replace(std::size_t position, std::size_t length, const String& replaceWith);
////////////////////////////////////////////////////////////
/// \brief Replace all occurrences of a substring with a replacement string
///
/// This function replaces all occurrences of \a searchFor in this string
/// with the string \a replaceWith.
///
/// \param searchFor The value being searched for
/// \param replaceWith The value that replaces found \a searchFor values
///
////////////////////////////////////////////////////////////
void replace(const String& searchFor, const String& replaceWith);
////////////////////////////////////////////////////////////
/// \brief Return a part of the string
///
/// This function returns the substring that starts at index \a position
/// and spans \a length characters.
///
/// \param position Index of the first character
/// \param length Number of characters to include in the substring (if
/// the string is shorter, as many characters as possible
/// are included). \ref InvalidPos can be used to include all
/// characters until the end of the string.
///
/// \return String object containing a substring of this object
///
////////////////////////////////////////////////////////////
String substring(std::size_t position, std::size_t length = InvalidPos) const;
////////////////////////////////////////////////////////////
/// \brief Get a pointer to the C-style array of characters
///
@ -365,7 +489,7 @@ public :
ConstIterator begin() const;
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
/// \brief Return an iterator to the end of the string
///
/// The end iterator refers to 1 position past the last character;
/// thus it represents an invalid character and should never be
@ -379,7 +503,7 @@ public :
Iterator end();
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
/// \brief Return an iterator to the end of the string
///
/// The end iterator refers to 1 position past the last character;
/// thus it represents an invalid character and should never be
@ -392,7 +516,7 @@ public :
////////////////////////////////////////////////////////////
ConstIterator end() const;
private :
private:
friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);
@ -434,7 +558,7 @@ SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically lesser than \a right
/// \return True if \a left is lexicographically before \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator <(const String& left, const String& right);
@ -446,7 +570,7 @@ SFML_SYSTEM_API bool operator <(const String& left, const String& right);
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically greater than \a right
/// \return True if \a left is lexicographically after \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator >(const String& left, const String& right);
@ -458,7 +582,7 @@ SFML_SYSTEM_API bool operator >(const String& left, const String& right);
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically lesser or equal than \a right
/// \return True if \a left is lexicographically before or equivalent to \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
@ -470,7 +594,7 @@ SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically greater or equal than \a right
/// \return True if \a left is lexicographically after or equivalent to \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
@ -487,6 +611,8 @@ SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
////////////////////////////////////////////////////////////
SFML_SYSTEM_API String operator +(const String& left, const String& right);
#include <SFML/System/String.inl>
} // namespace sf
@ -500,7 +626,7 @@ SFML_SYSTEM_API String operator +(const String& left, const String& right);
/// sf::String is a utility string class defined mainly for
/// convenience. It is a Unicode string (implemented using
/// UTF-32), thus it can store any character in the world
/// (european, chinese, arabic, hebrew, etc.).
/// (European, Chinese, Arabic, Hebrew, etc.).
///
/// It automatically handles conversions from/to ANSI and
/// wide strings, so that you can work with standard string

View File

@ -0,0 +1,53 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
template <typename T>
String String::fromUtf8(T begin, T end)
{
String string;
Utf8::toUtf32(begin, end, std::back_inserter(string.m_string));
return string;
}
////////////////////////////////////////////////////////////
template <typename T>
String String::fromUtf16(T begin, T end)
{
String string;
Utf16::toUtf32(begin, end, std::back_inserter(string.m_string));
return string;
}
////////////////////////////////////////////////////////////
template <typename T>
String String::fromUtf32(T begin, T end)
{
String string;
string.m_string.assign(begin, end);
return string;
}

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -39,7 +39,7 @@ namespace sf
////////////////////////////////////////////////////////////
class SFML_SYSTEM_API Time
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
@ -84,7 +84,7 @@ public :
////////////////////////////////////////////////////////////
static const Time Zero; ///< Predefined "zero" time value
private :
private:
friend SFML_SYSTEM_API Time seconds(float);
friend SFML_SYSTEM_API Time milliseconds(Int32);
@ -101,7 +101,7 @@ private :
////////////////////////////////////////////////////////////
explicit Time(Int64 microseconds);
private :
private:
////////////////////////////////////////////////////////////
// Member data
@ -399,6 +399,42 @@ SFML_SYSTEM_API Time& operator /=(Time& left, float right);
////////////////////////////////////////////////////////////
SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
////////////////////////////////////////////////////////////
/// \relates Time
/// \brief Overload of binary / operator to compute the ratio of two time values
///
/// \param left Left operand (a time)
/// \param right Right operand (a time)
///
/// \return \a left divided by \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API float operator /(Time left, Time right);
////////////////////////////////////////////////////////////
/// \relates Time
/// \brief Overload of binary % operator to compute remainder of a time value
///
/// \param left Left operand (a time)
/// \param right Right operand (a time)
///
/// \return \a left modulo \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API Time operator %(Time left, Time right);
////////////////////////////////////////////////////////////
/// \relates Time
/// \brief Overload of binary %= operator to compute/assign remainder of a time value
///
/// \param left Left operand (a time)
/// \param right Right operand (a time)
///
/// \return \a left modulo \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API Time& operator %=(Time& left, Time right);
} // namespace sf

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -47,7 +47,7 @@ class Utf;
template <>
class Utf<8>
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Decode a single UTF-8 character
@ -254,7 +254,7 @@ public :
template <>
class Utf<16>
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Decode a single UTF-16 character
@ -461,7 +461,7 @@ public :
template <>
class Utf<32>
{
public :
public:
////////////////////////////////////////////////////////////
/// \brief Decode a single UTF-32 character
@ -752,7 +752,7 @@ typedef Utf<32> Utf32;
/// to handle ANSI, wide, latin-1, UTF-8, UTF-16 and UTF-32 encodings.
///
/// sf::Utf<X> functions are all static, these classes are not meant to
/// be instanciated. All the functions are template, so that you
/// be instantiated. All the functions are template, so that you
/// can use any character / string type for a given encoding.
///
/// It has 3 specializations:

View File

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -24,12 +24,12 @@
////////////////////////////////////////////////////////////
// References :
// References:
//
// http://www.unicode.org/
// http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
// http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h
// http://people.w3.org/rishida/scripts/uniview/conversion
// https://www.unicode.org/
// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h
// https://people.w3.org/rishida/scripts/uniview/conversion
//
////////////////////////////////////////////////////////////
@ -62,12 +62,12 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
output = 0;
switch (trailingBytes)
{
case 5 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 4 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 3 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 2 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 1 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 0 : output += static_cast<Uint8>(*begin++);
case 5: output += static_cast<Uint8>(*begin++); output <<= 6;
case 4: output += static_cast<Uint8>(*begin++); output <<= 6;
case 3: output += static_cast<Uint8>(*begin++); output <<= 6;
case 2: output += static_cast<Uint8>(*begin++); output <<= 6;
case 1: output += static_cast<Uint8>(*begin++); output <<= 6;
case 0: output += static_cast<Uint8>(*begin++);
}
output -= offsets[trailingBytes];
}
@ -114,10 +114,10 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
Uint8 bytes[4];
switch (bytestoWrite)
{
case 4 : bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 3 : bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 2 : bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 1 : bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 3: bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
case 1: bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
}
// Add them to the output
@ -322,7 +322,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)
template <typename Out>
Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)
{
if (input < 0xFFFF)
if (input <= 0xFFFF)
{
// The character can be copied directly, we just need to check if it's in the valid range
if ((input >= 0xD800) && (input <= 0xDFFF))
@ -339,7 +339,7 @@ Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)
}
else if (input > 0x0010FFFF)
{
// Invalid character (greater than the maximum unicode value)
// Invalid character (greater than the maximum Unicode value)
if (replacement)
*output++ = replacement;
}
@ -638,7 +638,7 @@ Out Utf<32>::toUtf32(In begin, In end, Out output)
template <typename In>
Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
{
// On Windows, gcc's standard library (glibc++) has almost
// On Windows, GCC's standard library (glibc++) has almost
// no support for Unicode stuff. As a consequence, in this
// context we can only use the default locale and ignore
// the one passed as parameter.