This commit is contained in:
deeaitch committed 2026-10-07 18:50:11 -04:00
1 parent a0938cb29c
commit 3dd9230fca
21 files changed
+491 -450

No files matched your search

+2 -27
View File
@@ -12,31 +12,10 @@
#include "dbc_parser.h"
#include "dbc_statement_handler.h"
#include <cctype>
#include "text_utils.h"
#include <fstream>
#include <stdexcept>
namespace {
/**
* @brief Remove leading and trailing spaces.
* @param text Input text.
* @return Trimmed text.
*/
std::string TrimText(const std::string &text) {
std::string::size_type begin = 0U;
while ((begin < text.size()) &&
std::isspace(static_cast<unsigned char>(text[begin])))
++begin;
std::string::size_type end = text.size();
while ((end > begin) &&
std::isspace(static_cast<unsigned char>(text[end - 1U])))
--end;
return text.substr(begin, end - begin);
}
}// namespace
DbcDatabase DbcParser::ParseFile(const std::string &filePath) const {
std::ifstream input(filePath.c_str());
if (!input.is_open())
@@ -50,7 +29,7 @@ DbcDatabase DbcParser::ParseFile(const std::string &filePath) const {
std::string line;
while (std::getline(input, line)) {
++lineNumber;
line = Trim(line);
line = dbc_detail::TrimText(line);
if (line.empty())
continue;
@@ -67,7 +46,3 @@ DbcDatabase DbcParser::ParseFile(const std::string &filePath) const {
context.ValidateMultiplexing(filePath);
return database;
}
std::string DbcParser::Trim(const std::string &text) {
return TrimText(text);
}