Small checkpoint
diff --git a/ccnx/ccnx-common.h b/ccnx/ccnx-common.h
index 1824025..96f60ff 100644
--- a/ccnx/ccnx-common.h
+++ b/ccnx/ccnx-common.h
@@ -40,10 +40,9 @@
#include <utility>
#include <string.h>
-using namespace std;
namespace Ccnx {
-typedef vector<unsigned char> Bytes;
-typedef vector<string>Comps;
+typedef std::vector<unsigned char> Bytes;
+typedef std::vector<std::string>Comps;
typedef boost::shared_ptr<Bytes> BytesPtr;
diff --git a/ccnx/ccnx-name.cpp b/ccnx/ccnx-name.cpp
index cf6a475..cc34c23 100644
--- a/ccnx/ccnx-name.cpp
+++ b/ccnx/ccnx-name.cpp
@@ -24,8 +24,9 @@
#include <ctype.h>
#include <boost/algorithm/string/join.hpp>
+using namespace std;
+
namespace Ccnx{
-CcnxCharbufPtr CcnxCharbuf::Null;
void
CcnxCharbuf::init(ccn_charbuf *buf)
diff --git a/ccnx/ccnx-name.h b/ccnx/ccnx-name.h
index ff93a7d..72f790a 100644
--- a/ccnx/ccnx-name.h
+++ b/ccnx/ccnx-name.h
@@ -47,8 +47,6 @@
const ccn_charbuf *
getBuf() const { return m_buf; }
- static CcnxCharbufPtr Null;
-
const unsigned char *
buf () const
{ return m_buf->buf; }
@@ -66,14 +64,14 @@
struct NameException:
- virtual boost::exception, virtual exception {};
+ virtual boost::exception, virtual std::exception {};
class Name
{
public:
Name();
- Name(const string &name);
- Name(const vector<Bytes> &comps);
+ Name(const std::string &name);
+ Name(const std::vector<Bytes> &comps);
Name(const Name &other);
Name(const unsigned char *data, const ccn_indexbuf *comps);
Name (const unsigned char *buf, const size_t length);
@@ -93,7 +91,7 @@
appendComp(const Bytes &comp);
Name &
- appendComp(const string &compStr);
+ appendComp(const std::string &compStr);
Name &
appendComp(const void *buf, size_t size);
@@ -121,39 +119,45 @@
Bytes
getComp(int index) const;
- // return string format of the comp
+ // return std::string format of the comp
// if all characters are printable, simply returns the string
// if not, print the bytes in hex string format
- string
+ std::string
getCompAsString(int index) const;
uint64_t
getCompAsInt (int index) const;
+ inline std::string
+ getCompFromBackAsString(int index) const;
+
+ inline uint64_t
+ getCompFromBackAsInt (int index) const;
+
Name
getPartialName(int start, int n = -1) const;
- string
+ std::string
toString() const;
Name &
operator=(const Name &other);
bool
- operator==(const string &str) const;
+ operator==(const std::string &str) const;
bool
- operator!=(const string &str) const;
+ operator!=(const std::string &str) const;
friend Name
operator+(const Name &n1, const Name &n2);
private:
- vector<Bytes> m_comps;
+ std::vector<Bytes> m_comps;
};
-ostream&
-operator <<(ostream &os, const Name &name);
+std::ostream&
+operator <<(std::ostream &os, const Name &name);
bool
operator ==(const Name &n1, const Name &n2);
@@ -165,6 +169,18 @@
operator <(const Name &n1, const Name &n2);
+std::string
+Name::getCompFromBackAsString(int index) const
+{
+ return getCompAsString (m_comps.size () - 1 - index);
+}
+
+uint64_t
+Name::getCompFromBackAsInt (int index) const
+{
+ return getCompAsInt (m_comps.size () - 1 - index);
+}
+
} // Ccnx
#endif
diff --git a/ccnx/ccnx-pco.h b/ccnx/ccnx-pco.h
index cecc763..cdb2a7e 100644
--- a/ccnx/ccnx-pco.h
+++ b/ccnx/ccnx-pco.h
@@ -48,6 +48,9 @@
Name
name() const;
+ inline const Bytes &
+ buf () const;
+
private:
void
init(const unsigned char *data, size_t len);
@@ -58,6 +61,13 @@
Bytes m_bytes;
};
+const Bytes &
+ParsedContentObject::buf () const
+{
+ return m_bytes;
+}
+
+
typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
}
diff --git a/ccnx/ccnx-selectors.cpp b/ccnx/ccnx-selectors.cpp
index 001c1b7..b349cc1 100644
--- a/ccnx/ccnx-selectors.cpp
+++ b/ccnx/ccnx-selectors.cpp
@@ -2,6 +2,8 @@
#include "ccnx-common.h"
#include <boost/lexical_cast.hpp>
+using namespace std;
+
namespace Ccnx {
Selectors::Selectors()
@@ -53,7 +55,7 @@
{
if (isEmpty())
{
- return CcnxCharbuf::Null;
+ return CcnxCharbufPtr ();
}
CcnxCharbufPtr ptr(new CcnxCharbuf());
ccn_charbuf *cbuf = ptr->getBuf();
diff --git a/ccnx/ccnx-selectors.h b/ccnx/ccnx-selectors.h
index 420f33e..56e29b5 100644
--- a/ccnx/ccnx-selectors.h
+++ b/ccnx/ccnx-selectors.h
@@ -27,7 +27,7 @@
namespace Ccnx {
struct InterestSelectorException:
- virtual boost::exception, virtual exception {};
+ virtual boost::exception, virtual std::exception {};
class Selectors
{
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index 7f2e567..a8c06a3 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -325,7 +325,7 @@
CcnxCharbufPtr selectorsPtr = selectors.toCcnxCharbuf();
ccn_charbuf *templ = NULL;
- if (selectorsPtr != CcnxCharbuf::Null)
+ if (selectorsPtr)
{
templ = selectorsPtr->getBuf();
}
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index cfd030b..c1c9b9b 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -94,7 +94,7 @@
boost::thread m_thread;
bool m_running;
bool m_connected;
- map<Name, InterestCallback> m_registeredInterests;
+ std::map<Name, InterestCallback> m_registeredInterests;
};
typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;