mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sysid] Update JSON library usage (#5765)
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
#include <fmt/format.h>
|
||||
#include <units/angle.h>
|
||||
#include <units/math.h>
|
||||
#include <wpi/MemoryBuffer.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
|
||||
#include "sysid/Util.h"
|
||||
#include "sysid/analysis/FilteringUtils.h"
|
||||
@@ -451,13 +451,13 @@ AnalysisManager::AnalysisManager(std::string_view path, Settings& settings,
|
||||
{
|
||||
// Read JSON from the specified path
|
||||
std::error_code ec;
|
||||
wpi::raw_fd_istream is{path, ec};
|
||||
|
||||
if (ec) {
|
||||
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
|
||||
wpi::MemoryBuffer::GetFile(path, ec);
|
||||
if (fileBuffer == nullptr || ec) {
|
||||
throw FileReadingError(path);
|
||||
}
|
||||
|
||||
is >> m_json;
|
||||
m_json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
|
||||
|
||||
WPI_INFO(m_logger, "Read {}", path);
|
||||
}
|
||||
@@ -469,13 +469,13 @@ AnalysisManager::AnalysisManager(std::string_view path, Settings& settings,
|
||||
|
||||
// Read JSON from the specified path
|
||||
std::error_code ec;
|
||||
wpi::raw_fd_istream is{newPath, ec};
|
||||
|
||||
if (ec) {
|
||||
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
|
||||
wpi::MemoryBuffer::GetFile(path, ec);
|
||||
if (fileBuffer == nullptr || ec) {
|
||||
throw FileReadingError(newPath);
|
||||
}
|
||||
|
||||
is >> m_json;
|
||||
m_json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
|
||||
|
||||
WPI_INFO(m_logger, "Read {}", newPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user