Add 'xo-websock/' from commit '57bf06a68f'
git-subtree-dir: xo-websock git-subtree-mainline:97eefaea22git-subtree-split:57bf06a68f
This commit is contained in:
commit
dd1a6b1afc
30 changed files with 4667 additions and 0 deletions
38
xo-websock/src/websock/EndpointUtil.cpp
Normal file
38
xo-websock/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