mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 07:43:34 +08:00
Removed sstream from BitStream::toString()
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <sstream>
|
#include <string>
|
||||||
#include <uavcan/marshal/bit_stream.hpp>
|
#include <uavcan/marshal/bit_stream.hpp>
|
||||||
#include <uavcan/transport/transfer_buffer.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::string BitStream::toString() const
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::string out;
|
||||||
|
out.reserve(128);
|
||||||
|
|
||||||
for (int offset = 0; true; offset++)
|
for (int offset = 0; true; offset++)
|
||||||
{
|
{
|
||||||
uint8_t byte = 0;
|
uint8_t byte = 0;
|
||||||
@@ -85,16 +87,15 @@ std::string BitStream::toString() const
|
|||||||
}
|
}
|
||||||
for (int i = 7; i >= 0; i--) // Most significant goes first
|
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 (out.length())
|
||||||
if (output.length())
|
|
||||||
{
|
{
|
||||||
output.erase(output.length() - 1, 1);
|
out.erase(out.length() - 1, 1);
|
||||||
}
|
}
|
||||||
return output;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user