コード例 #1
0
void
Exclude::get(ExcludeLite& excludeLite) const
{
  excludeLite.clear();
  for (size_t i = 0; i < entries_.size(); ++i) {
    ndn_Error error;
    if (entries_[i].getType() == ndn_Exclude_COMPONENT) {
      NameLite::Component component;
      entries_[i].getComponent().get(component);
      if ((error = excludeLite.appendComponent(component)))
        throw runtime_error(ndn_getErrorString(error));
    }
    else {
      if ((error = excludeLite.appendAny()))
        throw runtime_error(ndn_getErrorString(error));
    }
  }
}
コード例 #2
0
// Imitate Exclude::get(ExcludeLite& excludeLite).
static void
toExcludeLite(PyObject* exclude, ExcludeLite& excludeLite)
{
  excludeLite.clear();
  PyObjectRef entries(PyObject_GetAttr(exclude, str._entries));
  for (size_t i = 0; i < PyList_GET_SIZE(entries.obj); ++i) {
    PyObject* entry = PyList_GET_ITEM(entries.obj, i);
    ndn_Error error;
    if (toLongByMethod(entry, str.getType) == Exclude_COMPONENT) {
      PyObjectRef component(PyObject_CallMethodObjArgs
        (entry, str.getComponent, NULL));
      NameLite::Component componentLite;
      toNameComponentLite(component, componentLite);
      if ((error = excludeLite.appendComponent(componentLite)))
        // TODO: Handle the error!
        return;
    }
    else {
      if ((error = excludeLite.appendAny()))
        // TODO: Handle the error!
        return;
    }
  }
}