MCPcopy Create free account
hub / github.com/apache/mesos / parse

Method parse

src/common/attributes.cpp:125–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124
125Attribute Attributes::parse(const string& name, const string& text)
126{
127 Attribute attribute;
128 Try<Value> result = internal::values::parse(text);
129
130 if (result.isError()) {
131 LOG(FATAL) << "Failed to parse attribute " << name
132 << " text " << text
133 << " error " << result.error();
134 } else {
135 Value value = result.get();
136 attribute.set_name(name);
137
138 if (value.type() == Value::RANGES) {
139 attribute.set_type(Value::RANGES);
140 attribute.mutable_ranges()->MergeFrom(value.ranges());
141 } else if (value.type() == Value::TEXT) {
142 attribute.set_type(Value::TEXT);
143 attribute.mutable_text()->MergeFrom(value.text());
144 } else if (value.type() == Value::SCALAR) {
145 attribute.set_type(Value::SCALAR);
146 attribute.mutable_scalar()->MergeFrom(value.scalar());
147 } else {
148 LOG(FATAL) << "Bad type for attribute " << name
149 << " text " << text
150 << " type " << value.type();
151 }
152 }
153
154 return attribute;
155}
156
157
158Attributes Attributes::parse(const string& s)

Callers

nothing calls this directly

Calls 11

tokenizeFunction · 0.85
splitFunction · 0.85
typeMethod · 0.80
MergeFromMethod · 0.80
parseFunction · 0.70
errorMethod · 0.65
isErrorMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected