コード例 #1
0
// Imitate Exclude::set(const ExcludeLite& excludeLite).
static void
setExclude(PyObject* exclude, const ExcludeLite& excludeLite)
{
  PyObjectRef ignoreResult1(PyObject_CallMethodObjArgs(exclude, str.clear, NULL));

  for (size_t i = 0; i < excludeLite.size(); ++i) {
    const ExcludeLite::Entry& entry = excludeLite.get(i);

    if (entry.getType() == ndn_Exclude_COMPONENT) {
      PyObjectRef blob(makeBlob(entry.getComponent().getValue()));
      // Imitate Name::Component::set(const NameLite::Component& componentLite).
      if (entry.getComponent().isImplicitSha256Digest())
        PyObjectRef ignoreResult2(PyObject_CallMethodObjArgs
          (exclude, str.appendImplicitSha256Digest, blob.obj, NULL));
      else
        PyObjectRef ignoreResult3(PyObject_CallMethodObjArgs
          (exclude, str.appendComponent, blob.obj, NULL));
    }
    else if (entry.getType() == ndn_Exclude_ANY)
      PyObjectRef ignoreResult3(PyObject_CallMethodObjArgs
        (exclude, str.appendAny, NULL));
    else
      // unrecognized ndn_ExcludeType"
      // TODO: Handle the error!
      return;
  }
}
コード例 #2
0
void
Exclude::set(const ExcludeLite& excludeLite)
{
  clear();
  for (size_t i = 0; i < excludeLite.size(); ++i) {
    const ExcludeLite::Entry& entry = excludeLite.get(i);

    if (entry.getType() == ndn_Exclude_COMPONENT)
      appendComponent(Name::Component(entry.getComponent()));
    else if (entry.getType() == ndn_Exclude_ANY)
      appendAny();
    else
      throw runtime_error("unrecognized ndn_ExcludeType");
  }
}