mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-05-11 11:34:10 +00:00
21 lines
447 B
C++
21 lines
447 B
C++
#include "llama-io.h"
|
|
|
|
#include <vector>
|
|
|
|
void llama_io_write_i::write_string(const std::string & str) {
|
|
uint32_t str_size = str.size();
|
|
|
|
write(&str_size, sizeof(str_size));
|
|
write(str.data(), str_size);
|
|
}
|
|
|
|
void llama_io_read_i::read_string(std::string & str) {
|
|
uint32_t str_size;
|
|
read(&str_size, sizeof(str_size));
|
|
|
|
std::vector<char> buf(str_size);
|
|
read(buf.data(), str_size);
|
|
|
|
str.assign(buf.data(), str_size);
|
|
}
|