use std::size_t
This commit is contained in:
parent
fe6abe1750
commit
3456b1e50d
@ -225,9 +225,9 @@ SocketDescriptor::GetError() noexcept
|
|||||||
: errno;
|
: errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
std::size_t
|
||||||
SocketDescriptor::GetOption(int level, int name,
|
SocketDescriptor::GetOption(int level, int name,
|
||||||
void *value, size_t size) const noexcept
|
void *value, std::size_t size) const noexcept
|
||||||
{
|
{
|
||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ SocketDescriptor::SetNonBlocking() noexcept
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
SocketDescriptor::SetOption(int level, int name,
|
SocketDescriptor::SetOption(int level, int name,
|
||||||
const void *value, size_t size) noexcept
|
const void *value, std::size_t size) noexcept
|
||||||
{
|
{
|
||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ SocketDescriptor::GetPeerAddress() const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::Read(void *buffer, size_t length) noexcept
|
SocketDescriptor::Read(void *buffer, std::size_t length) noexcept
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -442,7 +442,7 @@ SocketDescriptor::Read(void *buffer, size_t length) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::Write(const void *buffer, size_t length) noexcept
|
SocketDescriptor::Write(const void *buffer, std::size_t length) noexcept
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -495,7 +495,7 @@ SocketDescriptor::WaitWritable(int timeout_ms) const noexcept
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::Read(void *buffer, size_t length,
|
SocketDescriptor::Read(void *buffer, std::size_t length,
|
||||||
StaticSocketAddress &address) noexcept
|
StaticSocketAddress &address) noexcept
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
@ -513,7 +513,7 @@ SocketDescriptor::Read(void *buffer, size_t length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::Write(const void *buffer, size_t length,
|
SocketDescriptor::Write(const void *buffer, std::size_t length,
|
||||||
SocketAddress address) noexcept
|
SocketAddress address) noexcept
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
@ -159,8 +159,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @return the value size or 0 on error
|
* @return the value size or 0 on error
|
||||||
*/
|
*/
|
||||||
size_t GetOption(int level, int name,
|
std::size_t GetOption(int level, int name,
|
||||||
void *value, size_t size) const noexcept;
|
void *value, std::size_t size) const noexcept;
|
||||||
|
|
||||||
#ifdef HAVE_STRUCT_UCRED
|
#ifdef HAVE_STRUCT_UCRED
|
||||||
/**
|
/**
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool SetOption(int level, int name,
|
bool SetOption(int level, int name,
|
||||||
const void *value, size_t size) noexcept;
|
const void *value, std::size_t size) noexcept;
|
||||||
|
|
||||||
bool SetBoolOption(int level, int name, bool _value) noexcept {
|
bool SetBoolOption(int level, int name, bool _value) noexcept {
|
||||||
const int value = _value;
|
const int value = _value;
|
||||||
@ -232,8 +232,8 @@ public:
|
|||||||
[[gnu::pure]]
|
[[gnu::pure]]
|
||||||
StaticSocketAddress GetPeerAddress() const noexcept;
|
StaticSocketAddress GetPeerAddress() const noexcept;
|
||||||
|
|
||||||
ssize_t Read(void *buffer, size_t length) noexcept;
|
ssize_t Read(void *buffer, std::size_t length) noexcept;
|
||||||
ssize_t Write(const void *buffer, size_t length) noexcept;
|
ssize_t Write(const void *buffer, std::size_t length) noexcept;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int WaitReadable(int timeout_ms) const noexcept;
|
int WaitReadable(int timeout_ms) const noexcept;
|
||||||
@ -247,13 +247,13 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Receive a datagram and return the source address.
|
* Receive a datagram and return the source address.
|
||||||
*/
|
*/
|
||||||
ssize_t Read(void *buffer, size_t length,
|
ssize_t Read(void *buffer, std::size_t length,
|
||||||
StaticSocketAddress &address) noexcept;
|
StaticSocketAddress &address) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a datagram to the specified address.
|
* Send a datagram to the specified address.
|
||||||
*/
|
*/
|
||||||
ssize_t Write(const void *buffer, size_t length,
|
ssize_t Write(const void *buffer, std::size_t length,
|
||||||
SocketAddress address) noexcept;
|
SocketAddress address) noexcept;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -167,7 +167,7 @@ ValidateUTF8(const char *p) noexcept
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
std::size_t
|
||||||
SequenceLengthUTF8(char ch) noexcept
|
SequenceLengthUTF8(char ch) noexcept
|
||||||
{
|
{
|
||||||
if (IsASCII(ch))
|
if (IsASCII(ch))
|
||||||
@ -194,7 +194,7 @@ SequenceLengthUTF8(char ch) noexcept
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t L>
|
template<std::size_t L>
|
||||||
struct CheckSequenceUTF8 {
|
struct CheckSequenceUTF8 {
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool operator()(const char *p) const noexcept {
|
bool operator()(const char *p) const noexcept {
|
||||||
@ -209,9 +209,9 @@ struct CheckSequenceUTF8<0U> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<size_t L>
|
template<std::size_t L>
|
||||||
gcc_pure
|
gcc_pure
|
||||||
static size_t
|
static std::size_t
|
||||||
InnerSequenceLengthUTF8(const char *p) noexcept
|
InnerSequenceLengthUTF8(const char *p) noexcept
|
||||||
{
|
{
|
||||||
return CheckSequenceUTF8<L>()(p)
|
return CheckSequenceUTF8<L>()(p)
|
||||||
@ -219,7 +219,7 @@ InnerSequenceLengthUTF8(const char *p) noexcept
|
|||||||
: 0U;
|
: 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
std::size_t
|
||||||
SequenceLengthUTF8(const char *p) noexcept
|
SequenceLengthUTF8(const char *p) noexcept
|
||||||
{
|
{
|
||||||
const uint8_t ch = *p++;
|
const uint8_t ch = *p++;
|
||||||
@ -258,14 +258,14 @@ FindNonASCIIOrZero(const char *p) noexcept
|
|||||||
|
|
||||||
const char *
|
const char *
|
||||||
Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
|
Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
|
||||||
size_t buffer_size) noexcept
|
std::size_t buffer_size) noexcept
|
||||||
{
|
{
|
||||||
const char *p = FindNonASCIIOrZero(src);
|
const char *p = FindNonASCIIOrZero(src);
|
||||||
if (*p == 0)
|
if (*p == 0)
|
||||||
/* everything is plain ASCII, we don't need to convert anything */
|
/* everything is plain ASCII, we don't need to convert anything */
|
||||||
return src;
|
return src;
|
||||||
|
|
||||||
if ((size_t)(p - src) >= buffer_size)
|
if ((std::size_t)(p - src) >= buffer_size)
|
||||||
/* buffer too small */
|
/* buffer too small */
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -332,14 +332,14 @@ UnicodeToUTF8(unsigned ch, char *q) noexcept
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
std::size_t
|
||||||
LengthUTF8(const char *p) noexcept
|
LengthUTF8(const char *p) noexcept
|
||||||
{
|
{
|
||||||
/* this is a very naive implementation: it does not do any
|
/* this is a very naive implementation: it does not do any
|
||||||
verification, it just counts the bytes that are not a UTF-8
|
verification, it just counts the bytes that are not a UTF-8
|
||||||
continuation */
|
continuation */
|
||||||
|
|
||||||
size_t n = 0;
|
std::size_t n = 0;
|
||||||
for (; *p != 0; ++p)
|
for (; *p != 0; ++p)
|
||||||
if (!IsContinuation(*p))
|
if (!IsContinuation(*p))
|
||||||
++n;
|
++n;
|
||||||
|
@ -47,7 +47,7 @@ ValidateUTF8(const char *p) noexcept;
|
|||||||
* character, or 0 if the character is not a valid start byte
|
* character, or 0 if the character is not a valid start byte
|
||||||
*/
|
*/
|
||||||
gcc_const
|
gcc_const
|
||||||
size_t
|
std::size_t
|
||||||
SequenceLengthUTF8(char ch) noexcept;
|
SequenceLengthUTF8(char ch) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ SequenceLengthUTF8(char ch) noexcept;
|
|||||||
* if the sequence is malformed
|
* if the sequence is malformed
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
size_t
|
std::size_t
|
||||||
SequenceLengthUTF8(const char *p) noexcept;
|
SequenceLengthUTF8(const char *p) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +67,7 @@ SequenceLengthUTF8(const char *p) noexcept;
|
|||||||
*/
|
*/
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
const char *
|
const char *
|
||||||
Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size) noexcept;
|
Latin1ToUTF8(const char *src, char *buffer, std::size_t buffer_size) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the specified Unicode character to UTF-8 and write it to
|
* Convert the specified Unicode character to UTF-8 and write it to
|
||||||
@ -84,7 +84,7 @@ UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
|
|||||||
* from strlen(), which counts the number of bytes.
|
* from strlen(), which counts the number of bytes.
|
||||||
*/
|
*/
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
size_t
|
std::size_t
|
||||||
LengthUTF8(const char *p) noexcept;
|
LengthUTF8(const char *p) noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user