MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / parseCommaSeparatedValues

Function parseCommaSeparatedValues

Source/Node/AlignNode.cpp:158–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156};
157
158static std::vector<std::pair<CSSValue, float>> parseCommaSeparatedValues(std::string_view values, bool allowPercent = false, bool allowAuto = false) {
159 std::vector<std::pair<CSSValue, float>> result;
160 auto parts = values | std::ranges::views::split(',');
161 for (auto&& part : parts) {
162 auto partStr = Slice{&*part.begin(), static_cast<size_t>(std::ranges::distance(part))}.trimSpace();
163 if (allowAuto && partStr == "auto") {
164 result.push_back({CSSValue::Auto, 0});
165 } else if (allowPercent && !partStr.empty() && partStr.back() == '%') {
166 std::string str(partStr);
167 if (auto num = safeStringToFloat(str)) {
168 result.push_back({CSSValue::Percentage, num.value()});
169 } else {
170 return {};
171 }
172 } else {
173 std::string str(partStr);
174 if (auto num = safeStringToFloat(str)) {
175 result.push_back({CSSValue::Number, num.value()});
176 } else {
177 return {};
178 }
179 }
180 }
181 return result;
182}
183
184static void setEdges(YGNodeRef node, const std::vector<std::pair<CSSValue, float>>& values, void (*setter)(YGNodeRef, YGEdge, float), void (*percentSetter)(YGNodeRef, YGEdge, float) = nullptr, void (*autoSetter)(YGNodeRef, YGEdge) = nullptr) {
185 auto setValue = [&](YGEdge edge, const std::pair<CSSValue, float>& value) {

Callers 1

cssMethod · 0.85

Calls 8

splitFunction · 0.85
safeStringToFloatFunction · 0.85
distanceFunction · 0.50
beginMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected