29 #include "../system/cmake/CMakePackageFinder.h"
30 #include "../system/ArmarXDataPath.h"
31 #include "../exceptions/local/ExpressionException.h"
38 "([^{}]+|\\{[^{}]+\\})+"
43 std::map<std::string, FormatStringOption> descr;
56 std::stringstream strstr;
58 boost::regex expression {
"([^{}]+|\\{([^{}]+)\\})"};
59 std::string::const_iterator start =
rawPath.begin();
60 const std::string::const_iterator end =
rawPath.end();
61 boost::match_results<std::string::const_iterator> match;
62 while (boost::regex_search(start, end, match, expression))
66 const std::string matched
68 match[2].first, match[2].second
82 <<
"pattern '{" << matched
83 <<
"}' did not match any known FormatString";
90 start = match[0].second;
103 std::string name, boost::regex patternRegex, std::function<std::string(
const std::string&)> replacer, std::string description)
106 name, {name, std::move(description), std::move(patternRegex), std::move(replacer)});
113 boost::regex{
"LEFT CURLY"},
114 [](
const std::string&){
return "{";},
120 boost::regex{
"RIGHT CURLY"},
121 [](
const std::string&){
return "}";},
128 boost::regex{
"year"},
129 [](
const std::string&)
131 std::time_t t = std::time(
nullptr);
134 return std::string {buff};
136 "year (last two digits)"
141 boost::regex{
"Year"},
142 [](
const std::string&)
144 std::time_t t = std::time(
nullptr);
147 return std::string {buff};
149 "Year (all four digits)"
154 boost::regex{
"month"},
155 [](
const std::string&)
157 std::time_t t = std::time(
nullptr);
160 return std::string {buff};
168 [](
const std::string&)
170 std::time_t t = std::time(
nullptr);
173 return std::string {buff};
180 boost::regex{
"hour"},
181 [](
const std::string&)
183 std::time_t t = std::time(
nullptr);
186 return std::string {buff};
193 boost::regex{
"minute"},
194 [](
const std::string&)
196 std::time_t t = std::time(
nullptr);
199 return std::string {buff};
206 boost::regex{
"second"},
207 [](
const std::string&)
209 std::time_t t = std::time(
nullptr);
212 return std::string {buff};
219 boost::regex{
"Time"},
220 [](
const std::string&)
222 std::time_t t = std::time(
nullptr);
225 return std::string {buff};
232 boost::regex{
"Date"},
233 [](
const std::string&)
235 std::time_t t = std::time(
nullptr);
238 return std::string {buff};
245 boost::regex{
"DateTime"},
246 [](
const std::string&)
248 std::time_t t = std::time(
nullptr);
251 return std::string {buff};
253 "YYYY-MM-DD_HH-MM-SS"
258 boost::regex{
"time-since-epoch"},
259 [](
const std::string&)
261 return to_string(std::chrono::high_resolution_clock::now().time_since_epoch().count());
263 "time since epoch in nanoseconds (can be used as UUID)"
269 boost::regex{
"PackageDir:.+"},
270 [](
const std::string &
s)
272 const auto pkg =
s.substr(11);
273 CMakePackageFinder pf {pkg};
275 return pf.getPackageDir();
277 "PackageDir:<PACKAGE>: Package dir of the armarx Package <PACKAGE>."
282 boost::regex{
"ScenarioDir:.+"},
283 [](
const std::string &
s)
285 const auto pkg =
s.substr(12);
286 CMakePackageFinder pf {pkg};
288 return pf.getScenariosDir();
290 "ScenarioDir:<PACKAGE>: Scenario dir of the armarx Package <PACKAGE>."
295 boost::regex{
"DataDir:.+"},
296 [](
const std::string &
s)
298 const auto pkg =
s.substr(8);
299 CMakePackageFinder pf {pkg};
301 return pf.getDataDir();
303 "DataDir:<PACKAGE>: Data dir of the armarx Package <PACKAGE>."
308 boost::regex{
"BuildDir:.+"},
309 [](
const std::string &
s)
311 const auto pkg =
s.substr(9);
312 CMakePackageFinder pf {pkg};
314 return pf.getBuildDir();
316 "BuildDir:<PACKAGE>: Build dir of the armarx Package <PACKAGE>."
321 boost::regex{
"BinaryDir:.+"},
322 [](
const std::string &
s)
324 const auto pkg =
s.substr(10);
325 CMakePackageFinder pf {pkg};
327 return pf.getBinaryDir();
329 "BinaryDir:<PACKAGE>: Binary dir of the armarx Package <PACKAGE>."
334 boost::regex{
"CMakeDir:.+"},
335 [](
const std::string &
s)
337 const auto pkg =
s.substr(9);
338 CMakePackageFinder pf {pkg};
340 return pf.getCMakeDir();
342 "CMakeDir:<PACKAGE>: CMake dir of the armarx Package <PACKAGE>."
347 boost::regex{
"SourceDir:.+"},
348 [](
const std::string &
s)
350 const auto pkg =
s.substr(10);
351 CMakePackageFinder pf {pkg};
353 return pf.getPackageDir() +
"/source/" + pkg;
355 "SourceDir:<PACKAGE>: CMake dir of the armarx Package <PACKAGE>."