Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion devices/YarpRobotLoggerDevice/src/YarpRobotLoggerDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,38 @@ bool BipedalLocomotion::YarpRobotLoggerDevice::saveData(const std::string& tag)

if (!tag.empty())
{
inputFileName = defaultFilePrefix + "_" + tag;
std::string edited_tag = tag;

// Check if the tag is valid
for (size_t i = 1; i < edited_tag.size(); ++i)
{
if (!isalnum(edited_tag[i]) && (edited_tag[i] != '_') && (edited_tag[i] != ' '))
{
log()->error("{} The tag can contain only alphanumeric characters or "
"underscores (tag = \"{}\").",
logPrefix,
inputFileName);
return false;
}
}

// Check if the tag contains spaces. Trigger a warning if this is the case
// and replace the spaces with underscores
if (edited_tag.find(' ') != std::string::npos)
{
log()->warn("{} The tag \"{}\" contains spaces."
"They will be replaced with underscores.",
logPrefix,
edited_tag);
size_t start_pos = 0;
while ((start_pos = edited_tag.find(" ", start_pos)) != std::string::npos)
{
edited_tag.replace(start_pos, std::string(" ").length(), "_");
start_pos += std::string("_").length();
}
}

inputFileName = defaultFilePrefix + "_" + edited_tag;
}

{
Expand Down
Loading