mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[glass] Add protobuf decode error log message (#5812)
This commit is contained in:
@@ -12,12 +12,15 @@ using google::protobuf::Arena;
|
||||
using google::protobuf::FileDescriptorProto;
|
||||
using google::protobuf::Message;
|
||||
|
||||
void ProtobufMessageDatabase::Add(std::string_view filename,
|
||||
bool ProtobufMessageDatabase::Add(std::string_view filename,
|
||||
std::span<const uint8_t> data) {
|
||||
auto& file = m_files[filename];
|
||||
if (file.complete) {
|
||||
file.complete = false;
|
||||
|
||||
m_factory.reset();
|
||||
m_msgs.clear();
|
||||
|
||||
// rebuild the pool EXCEPT for this descriptor
|
||||
m_pool = std::make_unique<google::protobuf::DescriptorPool>();
|
||||
|
||||
@@ -31,7 +34,6 @@ void ProtobufMessageDatabase::Add(std::string_view filename,
|
||||
}
|
||||
|
||||
// clear messages and reset factory; Find() will recreate as needed
|
||||
m_msgs.clear();
|
||||
m_factory = std::make_unique<google::protobuf::DynamicMessageFactory>();
|
||||
}
|
||||
|
||||
@@ -49,10 +51,11 @@ void ProtobufMessageDatabase::Add(std::string_view filename,
|
||||
|
||||
// parse data
|
||||
if (!file.proto->ParseFromArray(data.data(), data.size())) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Build(filename, file);
|
||||
return true;
|
||||
}
|
||||
|
||||
Message* ProtobufMessageDatabase::Find(std::string_view name) const {
|
||||
|
||||
@@ -33,8 +33,9 @@ class ProtobufMessageDatabase {
|
||||
*
|
||||
* @param filename filename
|
||||
* @param data FileDescriptorProto serialized data
|
||||
* @return False if could not parse data
|
||||
*/
|
||||
void Add(std::string_view filename, std::span<const uint8_t> data);
|
||||
bool Add(std::string_view filename, std::span<const uint8_t> data);
|
||||
|
||||
/**
|
||||
* Finds a message in the database by name.
|
||||
|
||||
Reference in New Issue
Block a user