Codechange: rename byte to uint8_t (#12308)
This commit is contained in:
@@ -22,7 +22,7 @@ struct StrongTypedefBase;
|
||||
* as this allows providing custom operator overloads for more complex types
|
||||
* like e.g. structs without needing to modify this class.
|
||||
*/
|
||||
template <typename Tcont = typename std::vector<byte>, typename Titer = typename std::back_insert_iterator<Tcont>>
|
||||
template <typename Tcont = typename std::vector<uint8_t>, typename Titer = typename std::back_insert_iterator<Tcont>>
|
||||
class EndianBufferWriter {
|
||||
/** Output iterator for the destination buffer. */
|
||||
Titer buffer;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
EndianBufferWriter &operator <<(const std::string &data) { return *this << std::string_view{ data }; }
|
||||
EndianBufferWriter &operator <<(const char *data) { return *this << std::string_view{ data }; }
|
||||
EndianBufferWriter &operator <<(std::string_view data) { this->Write(data); return *this; }
|
||||
EndianBufferWriter &operator <<(bool data) { return *this << static_cast<byte>(data ? 1 : 0); }
|
||||
EndianBufferWriter &operator <<(bool data) { return *this << static_cast<uint8_t>(data ? 1 : 0); }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferWriter &operator <<(const OverflowSafeInt<T> &data) { return *this << static_cast<T>(data); };
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Tvalue, typename Tbuf = std::vector<byte>>
|
||||
template <typename Tvalue, typename Tbuf = std::vector<uint8_t>>
|
||||
static Tbuf FromValue(const Tvalue &data)
|
||||
{
|
||||
Tbuf buffer;
|
||||
@@ -118,17 +118,17 @@ private:
|
||||
*/
|
||||
class EndianBufferReader {
|
||||
/** Reference to storage buffer. */
|
||||
std::span<const byte> buffer;
|
||||
std::span<const uint8_t> buffer;
|
||||
/** Current read position. */
|
||||
size_t read_pos = 0;
|
||||
|
||||
public:
|
||||
EndianBufferReader(std::span<const byte> buffer) : buffer(buffer) {}
|
||||
EndianBufferReader(std::span<const uint8_t> buffer) : buffer(buffer) {}
|
||||
|
||||
void rewind() { this->read_pos = 0; }
|
||||
|
||||
EndianBufferReader &operator >>(std::string &data) { data = this->ReadStr(); return *this; }
|
||||
EndianBufferReader &operator >>(bool &data) { data = this->Read<byte>() != 0; return *this; }
|
||||
EndianBufferReader &operator >>(bool &data) { data = this->Read<uint8_t>() != 0; return *this; }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferReader &operator >>(OverflowSafeInt<T> &data) { data = this->Read<T>(); return *this; };
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename Tvalue>
|
||||
static Tvalue ToValue(std::span<const byte> buffer)
|
||||
static Tvalue ToValue(std::span<const uint8_t> buffer)
|
||||
{
|
||||
Tvalue result{};
|
||||
EndianBufferReader reader{ buffer };
|
||||
|
||||
@@ -41,13 +41,13 @@ protected:
|
||||
/** return reference to the array header (non-const) */
|
||||
inline ArrayHeader &Hdr()
|
||||
{
|
||||
return *(ArrayHeader*)(((byte*)data) - HeaderSize);
|
||||
return *(ArrayHeader*)(((uint8_t*)data) - HeaderSize);
|
||||
}
|
||||
|
||||
/** return reference to the array header (const) */
|
||||
inline const ArrayHeader &Hdr() const
|
||||
{
|
||||
return *(ArrayHeader*)(((byte*)data) - HeaderSize);
|
||||
return *(ArrayHeader*)(((uint8_t*)data) - HeaderSize);
|
||||
}
|
||||
|
||||
/** return reference to the block reference counter */
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
static_assert(C < (SIZE_MAX - HeaderSize) / Tsize);
|
||||
|
||||
/* allocate block for header + items (don't construct items) */
|
||||
data = (T*)((MallocT<byte>(HeaderSize + C * Tsize)) + HeaderSize);
|
||||
data = (T*)((MallocT<uint8_t>(HeaderSize + C * Tsize)) + HeaderSize);
|
||||
SizeRef() = 0; // initial number of items
|
||||
RefCnt() = 1; // initial reference counter
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
Clear();
|
||||
/* free the memory block occupied by items */
|
||||
free(((byte*)data) - HeaderSize);
|
||||
free(((uint8_t*)data) - HeaderSize);
|
||||
data = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ enum OptionDataFlags {
|
||||
|
||||
/** Data of an option. */
|
||||
struct OptionData {
|
||||
byte id; ///< Unique identification of this option data, often the same as #shortname.
|
||||
uint8_t id; ///< Unique identification of this option data, often the same as #shortname.
|
||||
char shortname; ///< Short option letter if available, else use \c '\0'.
|
||||
uint16_t flags; ///< Option data flags. @see OptionDataFlags
|
||||
const char *longname; ///< Long option name including '-'/'--' prefix, use \c nullptr if not available.
|
||||
|
||||
Reference in New Issue
Block a user