void
injectRefs (Json::Value &params, Json::Value &responses)
{
  if (params.isObject () || params.isArray () ) {
    for (auto it = params.begin(); it != params.end() ; it++) {
      injectRefs (*it, responses);
    }
  } else if (params.isConvertibleTo (Json::ValueType::stringValue) ) {
    std::string param = JsonFixes::getString (params);

    if (param.size() > NEW_REF.size()
        && param.substr (0, NEW_REF.size() ) == NEW_REF) {
      std::string ref = param.substr (NEW_REF.size() );

      try {
        int index = stoi (ref);

        insertResult (params, responses, index);
      } catch (std::invalid_argument &e) {
        Json::Value data;

        KurentoException ke (MALFORMED_TRANSACTION,
                             "Invalid index of newref '" + ref + "'");

        data[TYPE] = ke.getType();

        throw JsonRpc::CallException (ke.getCode (), ke.getMessage (), data);
      }
    }
  }
}
Esempio n. 2
0
/**
 * @brief Append the media contained in a result to the model
 * @param p_result the media to append is p_result->value.p_media
 * @param row the future row for this media
 * @return a VLC error code
 * @note Always signals. Do not use in a loop.
 */
inline int MLModel::appendResult( const ml_result_t *p_result )
{
    return insertResult( p_result, -1, true );
}