implementation + compile as independent module
This commit is contained in:
parent
3913e07f81
commit
c634f33e67
26 changed files with 4297 additions and 0 deletions
38
src/websock/EndpointUtil.cpp
Normal file
38
src/websock/EndpointUtil.cpp
Normal 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 */
|
||||
Loading…
Add table
Add a link
Reference in a new issue