// Returns true if all the bytes were successfully written to the file descriptor. inlinebool WriteBuffer(int fd, const uint8_t* buffer, size_t byte_count) { while (byte_count > 0) { int bytes_written = TEMP_FAILURE_RETRY(write(fd, buffer, byte_count)); if (bytes_written == -1) { returnfalse;
}
byte_count -= bytes_written; // Reduce the number of remaining bytes.
buffer += bytes_written; // Move the buffer forward.
} returntrue;
}
// Add the string bytes to the buffer. inlinevoid AddStringToBuffer(std::vector<uint8_t>* buffer, const std::string& value) {
buffer->insert(buffer->end(), value.begin(), value.end());
}
// Insert each byte, from low to high into the buffer. template <typename T> inlinevoid AddUintToBuffer(std::vector<uint8_t>* buffer, T value) { for (size_t i = 0; i < sizeof(T); i++) {
buffer->push_back((value >> (i * kBitsPerByte)) & 0xff);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.