mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-04 19:27:41 +00:00
fuzzed binary annotator (#7188)
This commit is contained in:
parent
e2be0c0b06
commit
ae4ce72651
20 changed files with 2241 additions and 2094 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#include "annotated_binary_text_gen.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
|
@ -37,6 +40,16 @@ static bool IsOffset(const BinaryRegionType type) {
|
|||
return type == BinaryRegionType::UOffset || type == BinaryRegionType::SOffset;
|
||||
}
|
||||
|
||||
template<typename T> std::string ToString(T value) {
|
||||
if (std::is_floating_point<T>::value) {
|
||||
std::stringstream ss;
|
||||
ss << value;
|
||||
return ss.str();
|
||||
} else {
|
||||
return std::to_string(value);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string ToValueString(const BinaryRegion ®ion, const uint8_t *binary) {
|
||||
std::string s;
|
||||
|
|
@ -47,7 +60,7 @@ std::string ToValueString(const BinaryRegion ®ion, const uint8_t *binary) {
|
|||
s += ToHex(binary[start_index - i]);
|
||||
}
|
||||
s += " (";
|
||||
s += std::to_string(val);
|
||||
s += ToString(val);
|
||||
s += ")";
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue