ForwardingFlags: Added ForwardingFlags class and use it in registerPrefix and ForwardingEntry instead of int flags.
diff --git a/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c b/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
index e8987db..8788cec 100644
--- a/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
+++ b/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
@@ -25,8 +25,9 @@
   if ((error = ndn_BinaryXmlEncoder_writeOptionalUnsignedDecimalIntDTagElement
       (encoder, ndn_BinaryXml_DTag_FaceID, forwardingEntry->faceId)))
     return error;
-  if ((error = ndn_BinaryXmlEncoder_writeOptionalUnsignedDecimalIntDTagElement
-      (encoder, ndn_BinaryXml_DTag_ForwardingFlags, forwardingEntry->forwardingFlags)))
+  if ((error = ndn_BinaryXmlEncoder_writeUnsignedDecimalIntDTagElement
+      (encoder, ndn_BinaryXml_DTag_ForwardingFlags, 
+       ndn_ForwardingFlags_getForwardingEntryFlags(&forwardingEntry->forwardingFlags))))
     return error;
   if ((error = ndn_BinaryXmlEncoder_writeOptionalUnsignedDecimalIntDTagElement
       (encoder, ndn_BinaryXml_DTag_FreshnessSeconds, forwardingEntry->freshnessSeconds)))
@@ -54,9 +55,17 @@
   if ((error = ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
       (decoder, ndn_BinaryXml_DTag_FaceID, &forwardingEntry->faceId)))
     return error;
+  
+  int forwardingEntryFlags;
   if ((error = ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
-      (decoder, ndn_BinaryXml_DTag_ForwardingFlags, &forwardingEntry->forwardingFlags)))
+      (decoder, ndn_BinaryXml_DTag_ForwardingFlags, &forwardingEntryFlags)))
     return error;
+  if (forwardingEntryFlags >= 0)
+    ndn_ForwardingFlags_setForwardingEntryFlags(&forwardingEntry->forwardingFlags, forwardingEntryFlags);
+  else
+    // This sets the default flags.
+    ndn_ForwardingFlags_initialize(&forwardingEntry->forwardingFlags);
+  
   if ((error = ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
       (decoder, ndn_BinaryXml_DTag_FreshnessSeconds, &forwardingEntry->freshnessSeconds)))
     return error;
diff --git a/ndn-cpp/c/forwarding-entry.h b/ndn-cpp/c/forwarding-entry.h
index a57429d..8fbfaa2 100644
--- a/ndn-cpp/c/forwarding-entry.h
+++ b/ndn-cpp/c/forwarding-entry.h
@@ -10,11 +10,23 @@
 #include "common.h"
 #include "name.h"
 #include "publisher-public-key-digest.h"
+#include "forwarding-flags.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+typedef enum {
+  ndn_ForwardingEntryFlags_ACTIVE         = 1,
+  ndn_ForwardingEntryFlags_CHILD_INHERIT  = 2,
+  ndn_ForwardingEntryFlags_ADVERTISE      = 4,
+  ndn_ForwardingEntryFlags_LAST           = 8,
+  ndn_ForwardingEntryFlags_CAPTURE       = 16,
+  ndn_ForwardingEntryFlags_LOCAL         = 32,
+  ndn_ForwardingEntryFlags_TAP           = 64,
+  ndn_ForwardingEntryFlags_CAPTURE_OK   = 128
+} ndn_ForwardingEntryFlags;
+
 /**
  * An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a hub.
  */
@@ -24,7 +36,7 @@
   struct ndn_Name prefix;
   struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
   int faceId;               /**< -1 for none. */
-  int forwardingFlags;      /**< -1 for none. */
+  struct ndn_ForwardingFlags forwardingFlags;
   int freshnessSeconds;     /**< -1 for none. */
 };
 
@@ -43,7 +55,7 @@
   ndn_Name_initialize(&self->prefix, prefixNameComponents, maxPrefixNameComponents);
   ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
   self->faceId = -1;
-  self->forwardingFlags = -1;
+  ndn_ForwardingFlags_initialize(&self->forwardingFlags);
   self->freshnessSeconds = -1;
 }
 
diff --git a/ndn-cpp/c/forwarding-flags.c b/ndn-cpp/c/forwarding-flags.c
new file mode 100644
index 0000000..e7477ed
--- /dev/null
+++ b/ndn-cpp/c/forwarding-flags.c
@@ -0,0 +1,56 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "forwarding-entry.h"
+#include "forwarding-flags.h"
+
+void ndn_ForwardingFlags_initialize(struct ndn_ForwardingFlags *self)
+{
+  self->active = 1;
+  self->childInherit = 1;
+  self->advertise = 0;
+  self->last = 0;
+  self->capture = 0;
+  self->local = 0;
+  self->tap = 0;
+  self->captureOk = 0;
+}
+
+int ndn_ForwardingFlags_getForwardingEntryFlags(struct ndn_ForwardingFlags *self)
+{
+  int result = 0;
+  
+  if (self->active)
+    result |= ndn_ForwardingEntryFlags_ACTIVE;
+  else if (self->childInherit)
+    result |= ndn_ForwardingEntryFlags_CHILD_INHERIT;
+  else if (self->advertise)
+    result |= ndn_ForwardingEntryFlags_ADVERTISE;
+  else if (self->last)
+    result |= ndn_ForwardingEntryFlags_LAST;
+  else if (self->capture)
+    result |= ndn_ForwardingEntryFlags_CAPTURE;
+  else if (self->local)
+    result |= ndn_ForwardingEntryFlags_LOCAL;
+  else if (self->tap)
+    result |= ndn_ForwardingEntryFlags_TAP;
+  else if (self->captureOk)
+    result |= ndn_ForwardingEntryFlags_CAPTURE_OK;
+  
+  return result;
+}
+
+void ndn_ForwardingFlags_setForwardingEntryFlags(struct ndn_ForwardingFlags *self, int forwardingEntryFlags)
+{
+  self->active = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ACTIVE) ? 1 : 0;
+  self->childInherit = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CHILD_INHERIT) ? 1 : 0;
+  self->advertise = (forwardingEntryFlags & ndn_ForwardingEntryFlags_ADVERTISE) ? 1 : 0;
+  self->last = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LAST) ? 1 : 0;
+  self->capture = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE) ? 1 : 0;
+  self->local = (forwardingEntryFlags & ndn_ForwardingEntryFlags_LOCAL) ? 1 : 0;
+  self->tap = (forwardingEntryFlags & ndn_ForwardingEntryFlags_TAP) ? 1 : 0;
+  self->captureOk = (forwardingEntryFlags & ndn_ForwardingEntryFlags_CAPTURE_OK) ? 1 : 0;
+}
diff --git a/ndn-cpp/c/forwarding-flags.h b/ndn-cpp/c/forwarding-flags.h
new file mode 100644
index 0000000..ba6f6b5
--- /dev/null
+++ b/ndn-cpp/c/forwarding-flags.h
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_FORWARDING_FLAGS_H
+#define	NDN_FORWARDING_FLAGS_H
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/**
+ * An ndn_ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an interest for
+ * a registered prefix.  We use a separate ForwardingFlags object to retain future compatibility if the daemon forwarding
+ * bits are changed, amended or deprecated.
+ */
+struct ndn_ForwardingFlags {
+  int active; /**< 1 if the flag is set, 0 if cleared. */
+  int childInherit;
+  int advertise;
+  int last;
+  int capture;
+  int local;
+  int tap;
+  int captureOk;  
+};
+
+/**
+ * Initialize an ndn_ForwardingFlags struct with the default with "active" and "childInherit" set and all other flags cleared.
+ * @param self A pointer to the ndn_ForwardingFlags struct.
+ */
+void ndn_ForwardingFlags_initialize(struct ndn_ForwardingFlags *self);
+
+/**
+ * Get an integer with the bits set according to the flags as used by the ForwardingEntry message.
+ * @param self A pointer to the ndn_ForwardingFlags struct.
+ * @return An integer with the bits set.
+ */
+int ndn_ForwardingFlags_getForwardingEntryFlags(struct ndn_ForwardingFlags *self);
+
+/**
+ * Set the flags according to the bits in forwardingEntryFlags as used by the ForwardingEntry message.
+ * @param self A pointer to the ndn_ForwardingFlags struct.
+ * @param flags An integer with the bits set.
+ */
+void ndn_ForwardingFlags_setForwardingEntryFlags(struct ndn_ForwardingFlags *self, int forwardingEntryFlags);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
diff --git a/ndn-cpp/face.hpp b/ndn-cpp/face.hpp
index f20bc26..c3ced09 100644
--- a/ndn-cpp/face.hpp
+++ b/ndn-cpp/face.hpp
@@ -87,12 +87,13 @@
    * use func_lib::ref() as appropriate.
    * @param onRegisterFailed A function object to call if failed to retrieve the connected hub’s ID or failed to register the prefix.
    * This calls onRegisterFailed(prefix) where prefix is the prefix given to registerPrefix.
-   * @param flags The flags for finer control of which interests are forward to the application.  If omitted, use 3 (ACTIVE | CHILD_INHERIT).
+   * @param flags The flags for finer control of which interests are forward to the application.  If omitted, use 
+   * the default flags defined by the default ForwardingFlags constructor.
    * @param wireFormat A WireFormat object used to encode the input. If omitted, use WireFormat getDefaultWireFormat().
    */
   void 
   registerPrefix
-    (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, int flags = 3, 
+    (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags = ForwardingFlags(), 
      WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
   {
     node_.registerPrefix(prefix, onInterest, onRegisterFailed, flags, wireFormat);
diff --git a/ndn-cpp/forwarding-entry.hpp b/ndn-cpp/forwarding-entry.hpp
index 6884a08..1bd15fa 100644
--- a/ndn-cpp/forwarding-entry.hpp
+++ b/ndn-cpp/forwarding-entry.hpp
@@ -10,6 +10,7 @@
 #include <string>
 #include "name.hpp"
 #include "publisher-public-key-digest.hpp"
+#include "forwarding-flags.hpp"
 #include "c/forwarding-entry.h"
 
 namespace ndn {
@@ -21,15 +22,17 @@
 public:    
   ForwardingEntry
     (const std::string& action, const Name& prefix, const PublisherPublicKeyDigest publisherPublicKeyDigest,
-     int faceId, int forwardingFlags, int freshnessSeconds) 
+     int faceId, const ForwardingFlags& forwardingFlags, int freshnessSeconds) 
   : action_(action), prefix_(prefix), publisherPublicKeyDigest_(publisherPublicKeyDigest), 
     faceId_(faceId), forwardingFlags_(forwardingFlags), freshnessSeconds_(freshnessSeconds)
   {
   }
 
   ForwardingEntry()
-  : faceId_(-1), forwardingFlags_(-1), freshnessSeconds_(-1)
+  : faceId_(-1), freshnessSeconds_(-1)
   {
+    forwardingFlags_.setActive(true);
+    forwardingFlags_.setChildInherit(true);
   }
   
   Blob 
@@ -76,7 +79,7 @@
   int 
   getFaceId() const { return faceId_; }
 
-  int 
+  const ForwardingFlags& 
   getForwardingFlags() const { return forwardingFlags_; }
 
   int 
@@ -96,7 +99,7 @@
   setFaceId(int value) { faceId_ = value; }
       
   void 
-  setForwardingFlags(int value) { forwardingFlags_ = value; }
+  setForwardingFlags(const ForwardingFlags& value) { forwardingFlags_ = value; }
       
   void 
   setFreshnessSeconds(int value) { freshnessSeconds_ = value; }
@@ -106,7 +109,7 @@
   Name prefix_;
   PublisherPublicKeyDigest publisherPublicKeyDigest_;
   int faceId_;           /**< -1 for none. */
-  int forwardingFlags_;  /**< -1 for none. */
+  ForwardingFlags forwardingFlags_;
   int freshnessSeconds_; /**< -1 for none. */
 };
 
diff --git a/ndn-cpp/forwarding-flags.hpp b/ndn-cpp/forwarding-flags.hpp
new file mode 100644
index 0000000..7f06dfd
--- /dev/null
+++ b/ndn-cpp/forwarding-flags.hpp
@@ -0,0 +1,134 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_FORWARDING_FLAGS_HPP
+#define	NDN_FORWARDING_FLAGS_HPP
+
+#include "c/forwarding-flags.h"
+
+namespace ndn {
+
+/**
+ * A ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an interest for
+ * a registered prefix.  We use a separate ForwardingFlags object to retain future compatibility if the daemon forwarding
+ * bits are changed, amended or deprecated.
+ */
+class ForwardingFlags : public ndn_ForwardingFlags {
+public:
+  /**
+   * Create a new ForwardingFlags with "active" and "childInherit" set and all other flags cleared.
+   */
+  ForwardingFlags() 
+  {
+    ndn_ForwardingFlags_initialize(this);
+  }
+  
+  ForwardingFlags(const struct ndn_ForwardingFlags &forwardingFlagsStruct)
+  : ndn_ForwardingFlags(forwardingFlagsStruct)
+  {
+  }
+
+  /**
+   * Get the value of the "active" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getActive() const { return active; }
+  
+  /**
+   * Get the value of the "childInherit" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getChildInherit() const { return childInherit; }
+  
+  /**
+   * Get the value of the "advertise" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getAdvertise() const { return advertise; }
+  
+  /**
+   * Get the value of the "last" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getLast() const { return last; }
+  
+  /**
+   * Get the value of the "capture" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getCapture() const { return capture; }
+  
+  /**
+   * Get the value of the "local" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getLocal() const { return local; }
+  
+  /**
+   * Get the value of the "tap" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getTap() const { return tap; }
+  
+  /**
+   * Get the value of the "captureOk" flag.
+   * @return true if the flag is set, false if it is cleared.
+   */
+  bool getCaptureOk() const { return captureOk; }
+
+  /**
+   * Set the value of the "active" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setActive(bool value) { active = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "childInherit" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setChildInherit(bool value) { childInherit = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "advertise" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setAdvertise(bool value) { advertise = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "last" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setLast(bool value) { last = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "capture" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setCapture(bool value) { capture = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "local" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setLocal(bool value) { local = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "tap" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setTap(bool value) { tap = value ? 1 : 0; }
+  
+  /**
+   * Set the value of the "captureOk" flag
+   * @param value true to set the flag, false to clear it.
+   */  
+  void setCaptureOk(bool value) { captureOk = value ? 1 : 0; }
+};
+
+}
+
+#endif
diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index b7c076e..0309174 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -135,7 +135,7 @@
 
 void 
 Node::registerPrefix
-  (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, int flags, WireFormat& wireFormat)
+  (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags, WireFormat& wireFormat)
 {
   if (ndndId_.size() == 0) {
     // First fetch the ndndId of the connected hub.
@@ -173,7 +173,7 @@
 void 
 Node::registerPrefixHelper
   (const shared_ptr<const Name>& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, 
-   int flags, WireFormat& wireFormat)
+   const ForwardingFlags& flags, WireFormat& wireFormat)
 {
   // Create a ForwardingEntry.
   ForwardingEntry forwardingEntry("selfreg", *prefix, PublisherPublicKeyDigest(), -1, flags, 2147483647);
diff --git a/ndn-cpp/node.hpp b/ndn-cpp/node.hpp
index a9bd81f..3b79658 100644
--- a/ndn-cpp/node.hpp
+++ b/ndn-cpp/node.hpp
@@ -12,6 +12,7 @@
 #include "data.hpp"
 #include "transport/tcp-transport.hpp"
 #include "encoding/binary-xml-element-reader.hpp"
+#include "forwarding-flags.hpp"
 
 namespace ndn {
 
@@ -71,7 +72,8 @@
    */
   void 
   registerPrefix
-    (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, int flags, WireFormat& wireFormat);
+    (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags, 
+     WireFormat& wireFormat);
 
   /**
    * Process any data to receive.  For each element received, call onReceivedElement.
@@ -199,7 +201,7 @@
     class Info {
     public:
       Info(Node *node, const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, 
-           int flags, WireFormat& wireFormat)
+           const ForwardingFlags& flags, WireFormat& wireFormat)
       : node_(*node), prefix_(new Name(prefix)), onInterest_(onInterest), onRegisterFailed_(onRegisterFailed), 
         flags_(flags), wireFormat_(wireFormat)
       {      
@@ -209,7 +211,7 @@
       ptr_lib::shared_ptr<const Name> prefix_;
       const OnInterest onInterest_;
       const OnRegisterFailed onRegisterFailed_;
-      int flags_;
+      ForwardingFlags flags_;
       WireFormat& wireFormat_;
     };
     
@@ -245,7 +247,7 @@
   void 
   registerPrefixHelper
     (const ptr_lib::shared_ptr<const Name>& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, 
-     int flags, WireFormat& wireFormat);
+     const ForwardingFlags& flags, WireFormat& wireFormat);
   
   ptr_lib::shared_ptr<Transport> transport_;
   ptr_lib::shared_ptr<const Transport::ConnectionInfo> connectionInfo_;