MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / parseNamedFormat

Function parseNamedFormat

src/common/ParseColor.cpp:126–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124//============================================================================//
125
126static bool parseNamedFormat(const char* str, fvec4& color) {
127 const char* end = TextUtils::skipNonWhitespace(str);
128 const size_t nameLen = (end - str);
129 if (nameLen <= 0) {
130 return false;
131 }
132 const std::string name(str, nameLen);
133
134 const ColorMap& colorMap = getColorMap();
135 ColorMap::const_iterator it = colorMap.find(TextUtils::tolower(name));
136 if (it == colorMap.end()) {
137 return false;
138 }
139
140 color = it->second;
141
142 str = TextUtils::skipWhitespace(end);
143 if (*str == 0) {
144 return true;
145 }
146
147 float alpha;
148 if (sscanf(str, "%f", &alpha) > 0) {
149 color.a = alpha;
150 }
151
152 return true;
153}
154
155
156//============================================================================//

Callers 1

parseColorCStringFunction · 0.85

Calls 5

skipNonWhitespaceFunction · 0.85
tolowerFunction · 0.85
skipWhitespaceFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected