55#include < optional>
66#include < span>
77#include < string>
8+ #include < unordered_map>
89#include < variant>
910#include < vector>
1011
@@ -81,13 +82,24 @@ class LogValue {
8182 LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
8283 std::span<const uint8_t > schema);
8384
85+ // Constructor for struct data with all schemas (including nested)
86+ LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
87+ std::span<const uint8_t > schema,
88+ const std::unordered_map<std::string, std::vector<uint8_t >>& nestedSchemas);
89+
8490 // Constructor for struct arrays
8591 LogValue (const std::vector<uint8_t >& data, std::string_view typeString, bool isArray);
8692
8793 // Constructor for struct arrays with schema
8894 LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
8995 std::span<const uint8_t > schema, bool isArray);
9096
97+ // Constructor for struct arrays with all schemas (including nested)
98+ LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
99+ std::span<const uint8_t > schema,
100+ const std::unordered_map<std::string, std::vector<uint8_t >>& nestedSchemas,
101+ bool isArray);
102+
91103 // Constructor for raw binary data (no default parameter to avoid ambiguity)
92104 LogValue (const std::vector<uint8_t >& value, bool isStruct);
93105
@@ -162,13 +174,22 @@ class LogValue {
162174 ValueVariant m_value;
163175 std::string m_typeString; // For struct types (e.g., "Pose2d")
164176 std::vector<uint8_t > m_schema; // For struct schema bytes (NT4 schema publishing)
177+ std::unordered_map<std::string, std::vector<uint8_t >> m_nestedSchemas; // Nested struct schemas
165178
166179 public:
167180 /* *
168181 * Get the schema bytes for struct types.
169182 * Returns empty span for non-struct types.
170183 */
171184 std::span<const uint8_t > GetSchema () const { return m_schema; }
185+
186+ /* *
187+ * Get all nested schemas (including the main schema).
188+ * Returns map of typeName -> schema bytes.
189+ */
190+ const std::unordered_map<std::string, std::vector<uint8_t >>& GetAllSchemas () const {
191+ return m_nestedSchemas;
192+ }
172193};
173194
174195/* *
@@ -190,8 +211,14 @@ LogValue MakeStructValue(const T& structValue) {
190211 // Get schema bytes
191212 auto schemaBytes = wpi::GetStructSchemaBytes<T>();
192213
193- // Create LogValue with type string and schema
194- return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes);
214+ // Collect all schemas (including nested structs like Translation2d in Pose2d)
215+ std::unordered_map<std::string, std::vector<uint8_t >> allSchemas;
216+ wpi::ForEachStructSchema<T>([&allSchemas](std::string_view name, std::string_view schema) {
217+ allSchemas[std::string (name)] = std::vector<uint8_t >(schema.begin (), schema.end ());
218+ });
219+
220+ // Create LogValue with type string, schema, and all nested schemas
221+ return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes, allSchemas);
195222}
196223
197224/* *
@@ -212,8 +239,14 @@ LogValue MakeStructArrayValue(std::span<const T> structArray) {
212239 // Get schema bytes
213240 auto schemaBytes = wpi::GetStructSchemaBytes<T>();
214241
215- // Create LogValue with type string, schema, and array flag
216- return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes, true );
242+ // Collect all schemas (including nested structs)
243+ std::unordered_map<std::string, std::vector<uint8_t >> allSchemas;
244+ wpi::ForEachStructSchema<T>([&allSchemas](std::string_view name, std::string_view schema) {
245+ allSchemas[std::string (name)] = std::vector<uint8_t >(schema.begin (), schema.end ());
246+ });
247+
248+ // Create LogValue with type string, schema, all nested schemas, and array flag
249+ return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes, allSchemas, true );
217250}
218251
219252} // namespace telemetrykit
0 commit comments