mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Removed sstream from BitStream::toString()
This commit is contained in:
parent
f66f06e895
commit
9849a6ce22
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <uavcan/marshal/bit_stream.hpp>
|
||||
#include <uavcan/transport/transfer_buffer.hpp>
|
||||
|
||||
@ -75,7 +75,9 @@ int BitStream::read(uint8_t* bytes, const int bitlen)
|
||||
|
||||
std::string BitStream::toString() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
std::string out;
|
||||
out.reserve(128);
|
||||
|
||||
for (int offset = 0; true; offset++)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
@ -85,16 +87,15 @@ std::string BitStream::toString() const
|
||||
}
|
||||
for (int i = 7; i >= 0; i--) // Most significant goes first
|
||||
{
|
||||
os << !!(byte & (1 << i));
|
||||
out += (byte & (1 << i)) ? '1' : '0';
|
||||
}
|
||||
os << " ";
|
||||
out += ' ';
|
||||
}
|
||||
std::string output = os.str();
|
||||
if (output.length())
|
||||
if (out.length())
|
||||
{
|
||||
output.erase(output.length() - 1, 1);
|
||||
out.erase(out.length() - 1, 1);
|
||||
}
|
||||
return output;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user