implementation + compile as independent module

This commit is contained in:
Roland Conybeare 2023-10-17 16:07:33 -04:00
commit c634f33e67
26 changed files with 4297 additions and 0 deletions

View file

@ -0,0 +1,38 @@
/* file EndpointUtil.cpp
*
* author: Roland Conybeare, Sep 2022
*/
#include "EndpointUtil.hpp"
namespace xo {
namespace web {
std::string
EndpointUtil::stem(std::string const & pattern)
{
std::size_t p = 0;
do {
p = pattern.find_first_of("$", p);
if ((p != std::string::npos) && (pattern[p+1] == '{')) {
/* fixed stem is chars [0 .. p-1], i.e. 1st p characters */
break;
}
if (p != std::string::npos) {
/* skip to next '$' */
++p;
}
} while (p != std::string::npos);
if (p == std::string::npos) {
/* pattern has no variable components */
return pattern;
} else {
return pattern.substr(0, p);
}
} /*stem*/
} /*namespace web*/
} /*namespace xo*/
/* end EndpointUtil.cpp */