39 std::map<std::string, FileSystemPathBuilder::FormatStringOption>
42 std::map<std::string, FormatStringOption> descr;
55 std::stringstream strstr;
57 boost::regex expression{
"([^{}]+|\\{([^{}]+)\\})"};
58 std::string::const_iterator start =
rawPath.begin();
59 const std::string::const_iterator end =
rawPath.end();
60 boost::match_results<std::string::const_iterator> match;
61 while (boost::regex_search(start, end, match, expression))
65 const std::string matched{match[2].first, match[2].second};
79 <<
"pattern '{" << matched <<
"}' did not match any known FormatString";
86 start = match[0].second;
102 boost::regex patternRegex,
103 std::function<std::string(
const std::string&)> replacer,
104 std::string description)
107 name, {name, std::move(description), std::move(patternRegex), std::move(replacer)});
113 boost::regex{
"LEFT CURLY"},
114 [](
const std::string&) {
return "{"; },
118 boost::regex{
"RIGHT CURLY"},
119 [](
const std::string&) {
return "}"; },
124 boost::regex{
"year"},
125 [](
const std::string&)
127 std::time_t t = std::time(
nullptr);
130 return std::string{buff};
132 "year (last two digits)"};
135 boost::regex{
"Year"},
136 [](
const std::string&)
138 std::time_t t = std::time(
nullptr);
141 return std::string{buff};
143 "Year (all four digits)"};
146 boost::regex{
"month"},
147 [](
const std::string&)
149 std::time_t t = std::time(
nullptr);
152 return std::string{buff};
158 [](
const std::string&)
160 std::time_t t = std::time(
nullptr);
163 return std::string{buff};
168 boost::regex{
"hour"},
169 [](
const std::string&)
171 std::time_t t = std::time(
nullptr);
174 return std::string{buff};
179 boost::regex{
"minute"},
180 [](
const std::string&)
182 std::time_t t = std::time(
nullptr);
185 return std::string{buff};
190 boost::regex{
"second"},
191 [](
const std::string&)
193 std::time_t t = std::time(
nullptr);
196 return std::string{buff};
201 boost::regex{
"Time"},
202 [](
const std::string&)
204 std::time_t t = std::time(
nullptr);
207 std::strftime(buff,
sizeof(buff),
"%H-%M-%S", std::localtime(&t)));
208 return std::string{buff};
213 boost::regex{
"Date"},
214 [](
const std::string&)
216 std::time_t t = std::time(
nullptr);
219 std::strftime(buff,
sizeof(buff),
"%Y-%m-%d", std::localtime(&t)));
220 return std::string{buff};
225 boost::regex{
"DateTime"},
226 [](
const std::string&)
228 std::time_t t = std::time(
nullptr);
231 std::strftime(buff,
sizeof(buff),
"%Y-%m-%d_%H-%M-%S", std::localtime(&t)));
232 return std::string{buff};
234 "YYYY-MM-DD_HH-MM-SS"};
237 boost::regex{
"time-since-epoch"},
238 [](
const std::string&)
239 {
return to_string(std::chrono::high_resolution_clock::now().time_since_epoch().count()); },
240 "time since epoch in nanoseconds (can be used as UUID)"};
244 boost::regex{
"PackageDir:.+"},
245 [](
const std::string&
s)
247 const auto pkg =
s.substr(11);
248 CMakePackageFinder pf{pkg};
250 return pf.getPackageDir();
252 "PackageDir:<PACKAGE>: Package dir of the armarx Package <PACKAGE>."};
255 boost::regex{
"ScenarioDir:.+"},
256 [](
const std::string&
s)
258 const auto pkg =
s.substr(12);
259 CMakePackageFinder pf{pkg};
261 return pf.getScenariosDir();
263 "ScenarioDir:<PACKAGE>: Scenario dir of the armarx Package <PACKAGE>."};
266 boost::regex{
"DataDir:.+"},
267 [](
const std::string&
s)
269 const auto pkg =
s.substr(8);
270 CMakePackageFinder pf{pkg};
272 return pf.getDataDir();
274 "DataDir:<PACKAGE>: Data dir of the armarx Package <PACKAGE>."};
277 boost::regex{
"BuildDir:.+"},
278 [](
const std::string&
s)
280 const auto pkg =
s.substr(9);
281 CMakePackageFinder pf{pkg};
283 return pf.getBuildDir();
285 "BuildDir:<PACKAGE>: Build dir of the armarx Package <PACKAGE>."};
288 boost::regex{
"BinaryDir:.+"},
289 [](
const std::string&
s)
291 const auto pkg =
s.substr(10);
292 CMakePackageFinder pf{pkg};
294 return pf.getBinaryDir();
296 "BinaryDir:<PACKAGE>: Binary dir of the armarx Package <PACKAGE>."};
299 boost::regex{
"CMakeDir:.+"},
300 [](
const std::string&
s)
302 const auto pkg =
s.substr(9);
303 CMakePackageFinder pf{pkg};
305 return pf.getCMakeDir();
307 "CMakeDir:<PACKAGE>: CMake dir of the armarx Package <PACKAGE>."};
310 boost::regex{
"SourceDir:.+"},
311 [](
const std::string&
s)
313 const auto pkg =
s.substr(10);
314 CMakePackageFinder pf{pkg};
316 return pf.getPackageDir() +
"/source/" + pkg;
318 "SourceDir:<PACKAGE>: CMake dir of the armarx Package <PACKAGE>."};
static bool ReplaceEnvVars(std::string &string)
ReplaceEnvVars replaces environment variables in a string with their values, if the env.
static bool ReplaceCMakePackageFinderVars(std::string &string)
Replaces occurrences like $C{PACKAGE_NAME:VAR_NAME} with their CMakePackageFinder value.
static const FileSystemPathBuilder::FormatStringOption & get(const std::string &key)
static std::vector< std::string > getKeys()
static void registerElement(const std::string &key, FileSystemPathBuilder::FormatStringOption element)
#define ARMARX_ANONYMOUS_VARIABLE
creates a identifier.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
double s(double t, double s0, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.
FileSystemPathBuilder::RegisterFormatStringOption ARMARX_ANONYMOUS_VARIABLE
const std::string & to_string(const std::string &s)
const std::string rawPath
static std::string ApplyFormatting(const std::string &rawPath)
static std::string ApplyFormattingAndResolveEnvAndCMakeVars(const std::string &rawPath)
static const boost::regex RawPathRegex
static std::map< std::string, FormatStringOption > GetFormatStringOptions()