Use in-class member initializers

This commit is contained in:
Chris Thrasher 2022-08-12 23:49:44 -06:00
parent 77dcd712fb
commit 50d86e4755
10 changed files with 21 additions and 47 deletions

View File

@ -232,14 +232,6 @@ public:
ConnectionFailed = 1001 //!< Connection with server failed ConnectionFailed = 1001 //!< Connection with server failed
}; };
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Constructs an empty response.
///
////////////////////////////////////////////////////////////
Response();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the value of a field /// \brief Get the value of a field
/// ///
@ -336,9 +328,9 @@ public:
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
FieldTable m_fields; //!< Fields of the header FieldTable m_fields; //!< Fields of the header
Status m_status; //!< Status code Status m_status{Status::ConnectionFailed}; //!< Status code
unsigned int m_majorVersion; //!< Major HTTP version unsigned int m_majorVersion{0}; //!< Major HTTP version
unsigned int m_minorVersion; //!< Minor HTTP version unsigned int m_minorVersion{0}; //!< Minor HTTP version
std::string m_body; //!< Body of the response std::string m_body; //!< Body of the response
}; };
@ -420,7 +412,7 @@ private:
TcpSocket m_connection; //!< Connection to the host TcpSocket m_connection; //!< Connection to the host
std::optional<IpAddress> m_host; //!< Web host address std::optional<IpAddress> m_host; //!< Web host address
std::string m_hostName; //!< Web host name std::string m_hostName; //!< Web host name
unsigned short m_port; //!< Port used for connection with host unsigned short m_port{0}; //!< Port used for connection with host
}; };
} // namespace sf } // namespace sf

View File

@ -433,9 +433,9 @@ private:
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::vector<char> m_data; //!< Data stored in the packet 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_readPos{0}; //!< Current reading position in the packet
std::size_t m_sendPos; //!< Current send position in the packet (for handling partial sends) std::size_t m_sendPos{0}; //!< Current send position in the packet (for handling partial sends)
bool m_isValid; //!< Reading state of the packet bool m_isValid{true}; //!< Reading state of the packet
}; };
} // namespace sf } // namespace sf

View File

@ -184,7 +184,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Type m_type; //!< Type of the socket (TCP or UDP) Type m_type; //!< Type of the socket (TCP or UDP)
SocketHandle m_socket; //!< Socket descriptor SocketHandle m_socket; //!< Socket descriptor
bool m_isBlocking; //!< Current blocking mode of the socket bool m_isBlocking{true}; //!< Current blocking mode of the socket
}; };
} // namespace sf } // namespace sf

View File

@ -219,10 +219,8 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct PendingPacket struct PendingPacket
{ {
PendingPacket(); std::uint32_t Size{0}; //!< Data of packet size
std::size_t SizeReceived{0}; //!< Number of size bytes received so far
std::uint32_t Size; //!< Data of packet size
std::size_t SizeReceived; //!< Number of size bytes received so far
std::vector<char> Data; //!< Data of the packet std::vector<char> Data; //!< Data of the packet
}; };

View File

@ -199,7 +199,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::vector<char> m_buffer; //!< Temporary buffer holding the received data in Receive(Packet) std::vector<char> m_buffer{std::vector<char>(MaxDatagramSize)}; //!< Temporary buffer holding the received data in Receive(Packet)
}; };
} // namespace sf } // namespace sf

View File

@ -140,12 +140,6 @@ bool Http::Request::hasField(const std::string& field) const
} }
////////////////////////////////////////////////////////////
Http::Response::Response() : m_status(Status::ConnectionFailed), m_majorVersion(0), m_minorVersion(0)
{
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& Http::Response::getField(const std::string& field) const const std::string& Http::Response::getField(const std::string& field) const
{ {
@ -292,9 +286,7 @@ void Http::Response::parseFields(std::istream& in)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Http::Http() : m_host(), m_port(0) Http::Http() = default;
{
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -36,9 +36,7 @@
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet::Packet() : m_readPos(0), m_sendPos(0), m_isValid(true) Packet::Packet() = default;
{
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -35,7 +35,7 @@
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Socket::Socket(Type type) : m_type(type), m_socket(priv::SocketImpl::invalidSocket()), m_isBlocking(true) Socket::Socket(Type type) : m_type(type), m_socket(priv::SocketImpl::invalidSocket())
{ {
} }

View File

@ -425,10 +425,4 @@ Socket::Status TcpSocket::receive(Packet& packet)
return Status::Done; return Status::Done;
} }
////////////////////////////////////////////////////////////
TcpSocket::PendingPacket::PendingPacket() : Size(0), SizeReceived(0), Data()
{
}
} // namespace sf } // namespace sf

View File

@ -38,7 +38,7 @@
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
UdpSocket::UdpSocket() : Socket(Type::Udp), m_buffer(MaxDatagramSize) UdpSocket::UdpSocket() : Socket(Type::Udp)
{ {
} }