示例#1
0
ValuePtr Value::select(const string &path) const {
  vector<string> parts;
  String::tokenize(path, parts, ".");

  unsigned i;
  ValuePtr value;

  try {
    for (i = 0; i < parts.size(); i++)
      value = i ? value->get(parts[i]) : get(parts[i]);

    return value;

  } catch (const Exception &e) {
    parts.resize(i + 1);
    THROWC("At JSON path " << String::join(parts, "."), e);
  }
}
示例#2
0
void
throwUOE(const string& expectedType, const ValuePtr& v)
{
    //
    // If the object is an unknown sliced object, we didn't find an
    // value factory, in this case raise a NoValueFactoryException
    // instead.
    //
    UnknownSlicedValue* usv = dynamic_cast<UnknownSlicedValue*>(v.get());
    if(usv)
    {
        throw NoValueFactoryException(__FILE__, __LINE__, "", usv->getUnknownTypeId());
    }

    string type = v->ice_id();
    throw Ice::UnexpectedObjectException(__FILE__, __LINE__,
                                         "expected element of type `" + expectedType + "' but received '" +
                                         type, type, expectedType);
}