you could use std::string for that.

instead of a raw buffer and length, you can use std::string::data() and std::string::length().