16 #include <boost/algorithm/string.hpp> 
   24 ATTRIBUTE_HELPER_CPP (Name);
 
   34 Name::Name (
const string &uri)
 
   36   string::const_iterator i = uri.begin ();
 
   37   string::const_iterator end = uri.end ();
 
   39   string::const_iterator firstSlash = std::find (i, end, 
'/');
 
   40   if (firstSlash == end)
 
   43                              << 
error::msg (
"Name should include at least one slash (did you forget to specify initial /?)"));
 
   48       string schema (i, firstSlash);
 
   49       if (*schema.rbegin () != 
':')
 
   51           BOOST_THROW_EXCEPTION (error::Name ()
 
   52                                  << 
error::msg (
"First component of the name does not start with a slash (did you forget to specify initial /?)"));
 
   57       if (!boost::iequals (schema, 
"ccnx:") &&
 
   58           !boost::iequals (schema, 
"ndn:"))
 
   60           BOOST_THROW_EXCEPTION (error::Name ()
 
   61                                  << 
error::msg (
"URI schema is not supported (only ccnx: or ndn: is allowed)")
 
   66   string::const_iterator secondSlash = i;
 
   68   if (secondSlash != end && *secondSlash == 
'/')
 
   74       i = std::find (secondSlash, end, 
'/');
 
   79       BOOST_THROW_EXCEPTION (error::Name ()
 
   87       while (i != end && *i == 
'/')
 
   94       string::const_iterator endOfComponent = std::find (i, end, 
'/');
 
   96       appendBySwap (comp.fromUri (i, endOfComponent));
 
  104   m_comps = other.m_comps;
 
  108 Name::operator= (
const Name &other)
 
  110   m_comps = other.m_comps;
 
  119 Name::appendVersion (uint64_t version)
 
  121   if (version != Name::nversion)
 
  122     return appendNumberWithMarker (version, 0xFD);
 
  125       TimeInterval now = time::NowUnixTimestamp ();
 
  127       int64_t seconds = now.GetSeconds ();
 
  128       int64_t microseconds = now.GetMicroSeconds () - seconds * 1000000;
 
  130       version = (seconds << 12) | (0xFFF & (microseconds / 244 ));
 
  132       version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244 ));
 
  134       return appendNumberWithMarker (version, 0xFD);
 
  144 Name::get (
int index)
 const 
  148       index = size () - (-index);
 
  151   if (static_cast<unsigned int> (index) >= size ())
 
  157   return m_comps [index];
 
  161 Name::get (
int index)
 
  165       index = size () - (-index);
 
  168   if (static_cast<unsigned int> (index) >= size())
 
  174   return m_comps [index];
 
  184 Name::getSubName (
size_t pos, 
size_t len)
 const 
  193   if (pos + len > size ())
 
  196                              << 
error::msg (
"getSubName parameter out of range")
 
  201   for (
size_t i = pos; i < pos + len; i++)
 
  210 Name::operator+ (
const Name &name)
 const 
  229 Name::toUri (std::ostream &os)
 const 
  231   for (Name::const_iterator comp = begin (); comp != end (); comp++)
 
  253 Name::compare (
const Name &name)
 const 
  255   Name::const_iterator i = this->begin ();
 
  256   Name::const_iterator j = name.
begin ();
 
  258   for (; i != this->end () && j != name.
end (); i++, j++)
 
  260       int res = i->compare (*j);
 
  267   if (i == this->end () && j == name.
end ())
 
  270   return (i == this->end ()) ? -1 : +1;
 
Name::const_iterator end() const 
End iterator (const) 
 
Name::const_iterator begin() const 
Begin iterator (const) 
 
boost::error_info< struct tag_msg, std::string > msg
Free-formatted text message explaining the error. 
 
This file defines basic elements for the library reporting. 
 
Name & append(const name::Component &comp)
Append a binary blob as a name component. 
 
boost::error_info< struct tag_pos, int > pos
Report of the position of the error (error-specific meaning) 
 
Class to representing binary blob of NDN name component.