26 static_assert(std::is_floating_point_v<T>,
"toFormattedString requires a floating point type");
29 if (len == 0 || data ==
nullptr) {
40 auto format = [&](
char* buf,
size_t bufSize, T value) {
45 ret.reserve(len * 12);
47 for (
size_t i = 0; i < len; ++i) {
51 const int n = format(buf,
sizeof(buf), data[i]);
53 yCError(
VECTOR,
"toFormattedString: formatting error at index %zu", i);
56 if (
static_cast<size_t>(
n) <
sizeof(buf)) {
57 ret.append(buf,
static_cast<size_t>(
n));
61 const size_t offset = ret.size();
62 ret.resize(offset +
static_cast<size_t>(
n) + 1);
63 format(&ret[offset],
static_cast<size_t>(
n) + 1, data[i]);
64 ret.resize(offset +
static_cast<size_t>(
n));
contains the definition of a Vector type
A mini-server for performing network communication in the background.
double * data()
Return a pointer to the first element of the vector.
size_t size() const
Returns the number of elements in the vector.
std::string toFormattedString(int precision=-1, int width=-1) const
Returns a human readable representation of the vector, with formatted numbers.
std::string toFormattedString(int precision=-1, int width=-1) const
Returns a human readable representation of the vector, with formatted numbers.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface to the operating system, including Port based communication.