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

Method parse

src/v1/attributes.cpp:126–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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