@@ -41,6 +41,7 @@ namespace urcl
41
41
{
42
42
namespace control
43
43
{
44
+ constexpr double ZERO_EPSILON = 0.000001 ;
44
45
45
46
bool operator <(const ScriptReader::DataVariant& lhs, const ScriptReader::DataVariant& rhs)
46
47
{
@@ -96,7 +97,7 @@ bool operator==(const ScriptReader::DataVariant& lhs, const ScriptReader::DataVa
96
97
{
97
98
if (std::holds_alternative<double >(rhs))
98
99
{
99
- return std::abs ((static_cast <double >(std::get<bool >(lhs)) - std::get<double >(rhs))) < 0.0001 ;
100
+ return std::abs ((static_cast <double >(std::get<bool >(lhs)) - std::get<double >(rhs))) < ZERO_EPSILON ;
100
101
}
101
102
if (std::holds_alternative<int >(rhs))
102
103
{
@@ -144,12 +145,11 @@ std::string ScriptReader::readScriptFile(const std::string& filename, const Data
144
145
return script_code;
145
146
}
146
147
147
- std::string ScriptReader::readFileContent (const std::string& filename )
148
+ std::string ScriptReader::readFileContent (const std::string& file_path )
148
149
{
149
150
std::ifstream ifs;
150
- ifs.open (filename );
151
+ ifs.open (file_path );
151
152
std::string content;
152
- std::ifstream file (filename);
153
153
if (ifs)
154
154
{
155
155
content = std::string ((std::istreambuf_iterator<char >(ifs)), (std::istreambuf_iterator<char >()));
@@ -158,7 +158,7 @@ std::string ScriptReader::readFileContent(const std::string& filename)
158
158
else
159
159
{
160
160
std::stringstream ss;
161
- ss << " Could not open script file '" << filename << " '. Please check if the file exists and is readable." ;
161
+ ss << " Could not open script file '" << file_path << " '. Please check if the file exists and is readable." ;
162
162
throw UrException (ss.str ().c_str ());
163
163
}
164
164
@@ -174,8 +174,9 @@ void ScriptReader::replaceIncludes(std::string& script, const DataDict& data)
174
174
// Replace all include patterns in the line
175
175
while (std::regex_search (script, match, include_pattern))
176
176
{
177
- std::filesystem::path file_path (match[1 ].str ());
178
- std::string file_content = readScriptFile ((script_path_.parent_path () / file_path.string ()).string (), data);
177
+ std::filesystem::path relative_file_path (match[1 ].str ());
178
+ std::string file_content =
179
+ readScriptFile ((script_path_.parent_path () / relative_file_path.string ()).string (), data);
179
180
script.replace (match.position (0 ), match.length (0 ), file_content);
180
181
}
181
182
}
0 commit comments