Example #1
0
void
Name::get(NameLite& nameLite) const
{
  nameLite.clear();
  for (size_t i = 0; i < components_.size(); ++i) {
    ndn_Error error;
    NameLite::Component component;
    components_[i].get(component);
    if ((error = nameLite.append(component)))
      throw runtime_error(ndn_getErrorString(error));
  }
}
Example #2
0
// Imitate Name::get(NameLite& nameLite).
static void
toNameLite(PyObject* name, NameLite& nameLite)
{
  nameLite.clear();
  PyObjectRef components(PyObject_GetAttr(name, str._components));
  for (size_t i = 0; i < PyList_GET_SIZE(components.obj); ++i) {
    ndn_Error error;
    NameLite::Component componentLite;
    toNameComponentLite(PyList_GET_ITEM(components.obj, i), componentLite);
    if ((error = nameLite.append(componentLite)))
      // TODO: Handle the error!
      return;
  }
}