Skip to content

Commit 340b0e1

Browse files
committed
Remove superflous access specifiers
1 parent 0f17982 commit 340b0e1

6 files changed

Lines changed: 26 additions & 26 deletions

File tree

libs/common/include/s25util/BinaryFile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class BinaryFile
5151
void WriteUnsignedChar(unsigned char i) const;
5252
void WriteRawData(const void* data, unsigned length) const;
5353

54-
void WriteShortString(const std::string& str); /// Länge max 254
55-
void WriteLongString(const std::string& str); /// Länge max 2^32-2
54+
void WriteShortString(const std::string& str) const; /// Länge max 254
55+
void WriteLongString(const std::string& str) const; /// Länge max 2^32-2
5656

5757
/// Lesemethoden
5858
int ReadSignedInt();

libs/common/include/s25util/Serializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Serializer
6464
}
6565

6666
/// Schreibt den Buffer in eine Datei
67-
void WriteToFile(BinaryFile& file);
67+
void WriteToFile(BinaryFile& file) const;
6868
/// Liest den Buffer aus einer Datei
6969
virtual void ReadFromFile(BinaryFile& file);
7070

libs/common/src/BinaryFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void BinaryFile::WriteRawData(const void* const data, const unsigned length) con
8787
CHECKED_WRITE(libendian::write((const char*)data, length, file));
8888
}
8989

90-
void BinaryFile::WriteShortString(const std::string& str)
90+
void BinaryFile::WriteShortString(const std::string& str) const
9191
{
9292
if(str.length() + 1 > std::numeric_limits<unsigned char>::max())
9393
throw std::out_of_range("String '" + str + "' is to long for a short string");
@@ -96,7 +96,7 @@ void BinaryFile::WriteShortString(const std::string& str)
9696
WriteRawData(str.c_str(), length);
9797
}
9898

99-
void BinaryFile::WriteLongString(const std::string& str)
99+
void BinaryFile::WriteLongString(const std::string& str) const
100100
{
101101
auto length = unsigned(str.length() + 1);
102102
WriteUnsignedInt(length);

libs/common/src/Serializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void Serializer::SetLength(const unsigned length)
3939
pos_ = length_;
4040
}
4141

42-
void Serializer::WriteToFile(BinaryFile& file)
42+
void Serializer::WriteToFile(BinaryFile& file) const
4343
{
4444
file.WriteUnsignedInt(GetLength());
4545
file.WriteRawData(GetData(), GetLength());

libs/network/include/s25util/Socket.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Socket
119119
void Close();
120120

121121
/// Binds the socket to a specific port
122-
bool Bind(unsigned short port, bool useIPv6);
122+
bool Bind(unsigned short port, bool useIPv6) const;
123123

124124
/// setzt das Socket auf Listen.
125125
bool Listen(unsigned short port, bool use_ipv6 = false, bool use_upnp = true);
@@ -132,42 +132,42 @@ class Socket
132132
const ProxySettings& proxy = ProxySettings());
133133

134134
/// liest Daten vom Socket in einen Puffer.
135-
int Recv(void* buffer, int length, bool block = true);
135+
int Recv(void* buffer, int length, bool block = true) const;
136136
/// Reads data from socket and returns peer address. Can be used for unbound sockets
137-
int Recv(void* buffer, int length, PeerAddr& addr);
137+
int Recv(void* buffer, int length, PeerAddr& addr) const;
138138
template<typename T, size_t T_size>
139139
int Recv(std::array<T, T_size>& buffer, const int length = T_size * sizeof(T), bool block = true)
140140
{
141141
return Recv(buffer.data(), length, block);
142142
}
143143

144144
/// schreibt Daten von einem Puffer auf das Socket.
145-
int Send(const void* buffer, int length);
145+
int Send(const void* buffer, int length) const;
146146
/// Sends data to the specified address (only for connectionless sockets!)
147-
int Send(const void* buffer, int length, const PeerAddr& addr);
147+
int Send(const void* buffer, int length, const PeerAddr& addr) const;
148148
template<typename T, size_t T_size>
149149
int Send(const std::array<T, T_size>& buffer)
150150
{
151151
return Send(buffer.data(), buffer.size() * sizeof(T));
152152
}
153153

154154
/// setzt eine Socketoption.
155-
bool SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionLen, int nLevel = IPPROTO_TCP);
155+
bool SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionLen, int nLevel = IPPROTO_TCP) const;
156156

157157
/// Größer-Vergleichsoperator.
158-
bool operator>(const Socket& sock);
158+
bool operator>(const Socket& sock) const;
159159

160160
/// prüft auf wartende Bytes.
161161
int BytesWaiting();
162162

163163
/// prüft auf wartende Bytes.
164-
int BytesWaiting(unsigned* received);
164+
int BytesWaiting(unsigned* received) const;
165165

166166
/// liefert die IP des Remote-Hosts.
167-
std::string GetPeerIP();
167+
std::string GetPeerIP() const;
168168

169169
/// liefert die IP des Lokalen-Hosts.
170-
std::string GetSockIP();
170+
std::string GetSockIP() const;
171171

172172
/// Gets a reference to the Socket.
173173
SOCKET GetSocket() const;

libs/network/src/Socket.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void Socket::Close()
298298
refCount_ = nullptr;
299299
}
300300

301-
bool Socket::Bind(unsigned short port, bool useIPv6)
301+
bool Socket::Bind(unsigned short port, bool useIPv6) const
302302
{
303303
union
304304
{
@@ -678,7 +678,7 @@ bool Socket::Connect(const std::string& hostname, const unsigned short port, boo
678678
*
679679
* @return -1 bei Fehler, Anzahl der empfangenen Bytes (max. @p length )
680680
*/
681-
int Socket::Recv(void* buffer, const int length, bool block)
681+
int Socket::Recv(void* buffer, const int length, bool block) const
682682
{
683683
if(!isValid())
684684
return -1;
@@ -687,7 +687,7 @@ int Socket::Recv(void* buffer, const int length, bool block)
687687
return recv(socket_, reinterpret_cast<char*>(buffer), length, (block ? 0 : MSG_PEEK));
688688
}
689689

690-
int Socket::Recv(void* const buffer, const int length, PeerAddr& addr)
690+
int Socket::Recv(void* const buffer, const int length, PeerAddr& addr) const
691691
{
692692
if(!isValid())
693693
return -1;
@@ -704,7 +704,7 @@ int Socket::Recv(void* const buffer, const int length, PeerAddr& addr)
704704
*
705705
* @return -1 bei Fehler, Anzahl der gesendeten Bytes (max. @p length )
706706
*/
707-
int Socket::Send(const void* const buffer, const int length)
707+
int Socket::Send(const void* const buffer, const int length) const
708708
{
709709
if(!isValid())
710710
return -1;
@@ -713,7 +713,7 @@ int Socket::Send(const void* const buffer, const int length)
713713
return send(socket_, reinterpret_cast<const char*>(buffer), length, 0);
714714
}
715715

716-
int Socket::Send(const void* const buffer, const int length, const PeerAddr& addr)
716+
int Socket::Send(const void* const buffer, const int length, const PeerAddr& addr) const
717717
{
718718
if(!isValid())
719719
return -1;
@@ -729,7 +729,7 @@ int Socket::Send(const void* const buffer, const int length, const PeerAddr& add
729729
*
730730
* @return @p true bei Erfolg, @p false bei Fehler
731731
*/
732-
bool Socket::SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionLen, int nLevel)
732+
bool Socket::SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionLen, int nLevel) const
733733
{
734734
return (SOCKET_ERROR != setsockopt(socket_, nLevel, nOptionName, (const char*)lpOptionValue, nOptionLen));
735735
}
@@ -741,7 +741,7 @@ bool Socket::SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionL
741741
*
742742
* @return liefert true falls @p this größer ist als @p sock
743743
*/
744-
bool Socket::operator>(const Socket& sock)
744+
bool Socket::operator>(const Socket& sock) const
745745
{
746746
return this->socket_ > sock.socket_;
747747
}
@@ -767,7 +767,7 @@ int Socket::BytesWaiting()
767767
*
768768
* @return liefert Null bei Erfolg, SOCKET_ERROR bei Fehler
769769
*/
770-
int Socket::BytesWaiting(unsigned* received)
770+
int Socket::BytesWaiting(unsigned* received) const
771771
{
772772
#ifdef _WIN32
773773
DWORD dwReceived;
@@ -784,7 +784,7 @@ int Socket::BytesWaiting(unsigned* received)
784784
*
785785
* @return liefert @p buffer zurück oder @p "" bei Fehler
786786
*/
787-
std::string Socket::GetPeerIP()
787+
std::string Socket::GetPeerIP() const
788788
{
789789
sockaddr_storage peer;
790790
socklen_t length = sizeof(sockaddr_storage);
@@ -802,7 +802,7 @@ std::string Socket::GetPeerIP()
802802
*
803803
* @return liefert @p buffer zurück oder @p "" bei Fehler
804804
*/
805-
std::string Socket::GetSockIP()
805+
std::string Socket::GetSockIP() const
806806
{
807807
sockaddr_storage peer;
808808
socklen_t length = sizeof(sockaddr_storage);

0 commit comments

Comments
 (0)