Browse Source

Change the ExcludeEntry to use a name component directly.

pull/1/head
Jeff Thompson 12 years ago
parent
commit
38d0e087a0
  1. 2
      ndn-cpp/c/encoding/binary-xml-interest.c
  2. 6
      ndn-cpp/c/interest.h
  3. 2
      ndn-cpp/interest.cpp
  4. 12
      ndn-cpp/interest.hpp
  5. 3
      ndn-cpp/name.hpp

2
ndn-cpp/c/encoding/binary-xml-interest.c

@ -26,7 +26,7 @@ static ndn_Error encodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXml
if (entry->type == ndn_Exclude_COMPONENT) {
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
(encoder, ndn_BinaryXml_DTag_Component, entry->component, entry->componentLength)))
(encoder, ndn_BinaryXml_DTag_Component, entry->component.value, entry->component.valueLength)))
return error;
}
else if (entry->type == ndn_Exclude_ANY) {

6
ndn-cpp/c/interest.h

@ -23,8 +23,7 @@ typedef enum {
*/
struct ndn_ExcludeEntry {
ndn_ExcludeType type;
unsigned char *component; /**< pointer to the pre-allocated buffer for the component value */
unsigned int componentLength; /**< the number of bytes in value */
struct ndn_NameComponent component;
};
/**
@ -37,8 +36,7 @@ struct ndn_ExcludeEntry {
static inline void ndn_ExcludeEntry_init(struct ndn_ExcludeEntry *self, ndn_ExcludeType type, unsigned char *component, unsigned int componentLength)
{
self->type = type;
self->component = component;
self->componentLength = componentLength;
ndn_NameComponent_init(&self->component, component, componentLength);
}
/**

2
ndn-cpp/interest.cpp

@ -28,7 +28,7 @@ void Exclude::set(const struct ndn_Exclude &excludeStruct)
ndn_ExcludeEntry *entry = &excludeStruct.entries[i];
if (entry->type == ndn_Exclude_COMPONENT)
addComponent(entry->component, entry->componentLength);
addComponent(entry->component.value, entry->component.valueLength);
else if (entry->type == ndn_Exclude_ANY)
addAny();
else

12
ndn-cpp/interest.hpp

@ -29,7 +29,7 @@ public:
* Create an ExcludeEntry of type ndn_Exclude_COMPONENT
*/
ExcludeEntry(unsigned char *component, unsigned int componentLen)
: type_(ndn_Exclude_COMPONENT), component_(component, component + componentLen)
: type_(ndn_Exclude_COMPONENT), component_(component, componentLen)
{
}
@ -41,19 +41,17 @@ public:
void get(struct ndn_ExcludeEntry &excludeEntryStruct) const
{
excludeEntryStruct.type = type_;
if (type_ == ndn_Exclude_COMPONENT) {
excludeEntryStruct.componentLength = component_.size();
excludeEntryStruct.component = (unsigned char *)&component_[0];
}
if (type_ == ndn_Exclude_COMPONENT)
component_.get(excludeEntryStruct.component);
}
ndn_ExcludeType getType() const { return type_; }
const std::vector<unsigned char> &getComponent() const { return component_; }
const Name::Component &getComponent() const { return component_; }
private:
ndn_ExcludeType type_;
std::vector<unsigned char> component_; /**< only used if type_ is ndn_Exclude_COMPONENT */
Name::Component component_; /**< only used if type_ is ndn_Exclude_COMPONENT */
};
/**

3
ndn-cpp/name.hpp

@ -50,8 +50,9 @@ public:
*/
void get(struct ndn_NameComponent &componentStruct) const
{
componentStruct.value = (unsigned char *)&value_[0];
componentStruct.valueLength = value_.size();
if (value_.size() > 0)
componentStruct.value = (unsigned char *)&value_[0];
}
/**

Loading…
Cancel
Save