34 if (!fmt)
throw std::runtime_error(
"fmt in CStream::printf cannot be NULL");
36 int result = -1, length = 1024;
40 buffer.resize(length + 10);
45 result = ::vsnprintf_s(&buffer[0], length, _TRUNCATE, fmt, args);
47 result =
::vsnprintf(&buffer[0], length, fmt, args);
52 if (result >= length) result = -1;
56 size_t l = strlen(&buffer[0]);
57 this->Write(&buffer[0], (
int)l);
76 size_t N = out_str.size();
77 out_str.resize(N + 1);
78 if (!Read(&out_str[N], 1))
return false;
81 if (out_str[N] ==
'\r')
85 else if (out_str[N] ==
'\n')
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
int vsnprintf(char *buf, size_t bufSize, const char *format, va_list args) noexcept
An OS-independent version of vsnprintf (Notice the bufSize param, which may be ignored in some compil...
bool getline(std::string &out_str)
Reads from the stream until a ' ' character is found ('' characters are ignored). ...