MCPcopy Create free account
hub / github.com/axmolengine/axmol / splitWithForm

Function splitWithForm

core/base/NS.cpp:62–98  ·  view source on GitHub ↗

first, judge whether the form of the string like this: {x,y} if the form is right,the string will be split into the parameter strs; or the parameter strs will be empty. if the form is right return true,else return false.

Source from the content-addressed store, hash-verified

60// or the parameter strs will be empty.
61// if the form is right return true,else return false.
62static bool splitWithForm(std::string_view content, strArray& strs)
63{
64 bool bRet = false;
65
66 do
67 {
68 AX_BREAK_IF(content.empty());
69
70 size_t nPosLeft = content.find('{');
71 size_t nPosRight = content.find('}');
72
73 // don't have '{' and '}'
74 AX_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos);
75 // '}' is before '{'
76 AX_BREAK_IF(nPosLeft > nPosRight);
77
78 auto pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
79 // nothing between '{' and '}'
80 AX_BREAK_IF(pointStr.empty());
81
82 size_t nPos1 = pointStr.find('{');
83 size_t nPos2 = pointStr.find('}');
84 // contain '{' or '}'
85 AX_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos);
86
87 split(pointStr, ",", strs);
88 if (strs.size() != 2 || strs[0].empty() || strs[1].empty())
89 {
90 strs.clear();
91 break;
92 }
93
94 bRet = true;
95 } while (0);
96
97 return bRet;
98}
99
100// implement the functions
101

Callers 3

RectFromStringFunction · 0.85
PointFromStringFunction · 0.85
SizeFromStringFunction · 0.85

Calls 6

splitFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected