Skip to content

Commit

Permalink
Added support for TSV files with spaces in variable names (fixes #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghorwin committed Sep 29, 2024
1 parent 320d869 commit 47342ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Makefile*
*.odg\#
*.ilk


moc/
ui/
qrc_*.cpp
/lib_x64/
/release/
/bin/debug/MasterSimulator
/bin/debug/MasterSimulatorUI
12 changes: 10 additions & 2 deletions MasterSim/src/MSIM_Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ void Project::read(const IBK::Path & prjFile, bool /* headerOnly */) {
std::string graphEdges = line.substr(5);
IBK::trim(graphEdges);
std::vector<std::string> tokens;
IBK::explode(graphEdges, tokens, " \t", IBK::EF_TrimTokens);
IBK::explode(graphEdges, tokens, " \t", IBK::EF_TrimTokens | IBK::EF_UseQuotes);
if (tokens.size() != 2 && tokens.size() != 4 && tokens.size() != 6)
throw IBK::Exception(IBK::FormatString("Expected format 'graph <connectorStart> <connectorEnd> [<offset> <scaleFactor> <linewidth> <html-color>]', got '%1'.").arg(line), FUNC_ID);
GraphEdge g;
IBK::trim(tokens[0],"\"");
IBK::trim(tokens[1],"\"");
g.m_outputVariableRef = tokens[0];
g.m_inputVariableRef = tokens[1];
if (tokens.size() >= 4) {
Expand Down Expand Up @@ -334,7 +336,13 @@ void Project::write(const IBK::Path & prjFile) const {
// write graph
for (unsigned int i=0; i<m_graph.size(); ++i) {
const Project::GraphEdge & edge = m_graph[i];
out << "graph " << edge.m_outputVariableRef << " " << edge.m_inputVariableRef;
std::string outVarRef = edge.m_outputVariableRef;
std::string inVarRef = edge.m_inputVariableRef;
if (outVarRef.find(" ") != std::string::npos)
outVarRef = "\"" + outVarRef + "\"";
if (inVarRef.find(" ") != std::string::npos)
inVarRef = "\"" + inVarRef + "\"";
out << "graph " << outVarRef << " " << inVarRef;
if (edge.m_offset != 0.0 || edge.m_scaleFactor != 1.0 || edge.m_color != IBK::Color(0,0,0) || edge.m_linewidth != 0.8) {
out << " " << edge.m_offset << " " << edge.m_scaleFactor;
if (edge.m_color != IBK::Color(0,0,0) || edge.m_linewidth != 0.8) {
Expand Down

0 comments on commit 47342ce

Please sign in to comment.