{
switch (node->type) {
case gp::Node::kReal: {
if (node->children.size() == 1) {
std::string unit_name = node->children[0].value;
double unit_value = 0;
if (units->Find(unit_name, unit_value)) {
double val = boost::lexical_cast<double>(node->value);
std::string store =
boost::lexical_cast<std::string>(val * unit_value);
value.reset(new gp::PropertyValue(store));
}else {
throw
gp::PositionalPropertyValueException::CouldNotFindUnit(
node->children[0].position, unit_name);
}
}else {
value.reset(new gp::PropertyValue(node->value));
}
break;
}
case gp::Node::kString: {
value.reset(new gp::PropertyValue('"'+node->value+'"'));
break;
}
case gp::Node::kBool: {
value.reset(new gp::PropertyValue(node->value));
break;
}
case gp::Node::kVector: {
std::vector<std::string> result;
BOOST_FOREACH(const gp::Node& child, node->children) {
gp::PropertyValue::ScopedPtr vvalue;
result.push_back(vvalue->ToString());
}
value.reset(new gp::PropertyValue(result));
break;
}
case gp::Node::kMap: {
std::map<std::string, std::string> result;
BOOST_FOREACH(const gp::Node& child, node->children) {
gp::PropertyValue::ScopedPtr kvalue;
gp::PropertyValue::ScopedPtr vvalue;
result.insert(
std::pair<std::string, std::string>(
kvalue->ToString(),
vvalue->ToString()));
}
value.reset(new gp::PropertyValue(result));
break;
}
case gp::Node::kProperty: {
gp::PropertyName::ScopedPtr property;
gp::Property* exists = NULL;
if (NULL != (exists = catalog->Find(property->client(),
property->property()))) {
value.reset(new gp::PropertyValue(exists->property_value()));
}else {
throw
gp::PositionalPropertyValueException::CouldNotFindProperty(
node->position,property->ToString());
}
break;
}
case gp::Node::kPropertyRef: {
gp::PropertyName::ScopedPtr property;
reference.push_back(property->client());
reference.push_back(property->property());
value.reset(new gp::PropertyValue(reference,property->position(),
true));
break;
}
default: {
assert(false);
break;
}
}
}