16 #include "ns3/ndn-common.h"
17 #include "ns3/simple-ref-count.h"
18 #include "ns3/attribute.h"
19 #include "ns3/attribute-helper.h"
21 #include "name-component.h"
29 class Name :
public SimpleRefCount<Name>
32 typedef std::vector<name::Component>::iterator iterator;
33 typedef std::vector<name::Component>::const_iterator const_iterator;
34 typedef std::vector<name::Component>::reverse_iterator reverse_iterator;
35 typedef std::vector<name::Component>::const_reverse_iterator const_reverse_iterator;
36 typedef std::vector<name::Component>::reference reference;
37 typedef std::vector<name::Component>::const_reference const_reference;
62 Name (
const std::string &url);
70 template<
class Iterator>
71 Name (Iterator begin, Iterator end);
77 operator= (
const Name &other);
111 template<
class Iterator>
113 append (Iterator begin, Iterator end);
122 append (
const Name &comp);
134 append (
const std::string &compStr);
144 append (
const void *buf,
size_t size);
158 appendNumber (uint64_t number);
178 appendNumberWithMarker (uint64_t number,
unsigned char marker);
186 appendSeqNum (uint64_t seqno);
194 appendControlNum (uint64_t control);
202 appendBlkId (uint64_t blkid);
212 appendVersion (uint64_t version = Name::nversion);
234 get (
int index)
const;
249 inline Name::const_iterator
252 inline Name::iterator
255 inline Name::const_iterator
258 inline Name::iterator
261 inline Name::const_reverse_iterator
264 inline Name::reverse_iterator
267 inline Name::const_reverse_iterator
270 inline Name::reverse_iterator
284 getSubName (
size_t pos = 0,
size_t len = npos)
const;
292 getPrefix (
size_t len,
size_t skip = 0)
const;
300 getPostfix (
size_t len,
size_t skip = 0)
const;
313 toUri (std::ostream &os)
const;
326 compare (
const Name &name)
const;
332 operator == (
const Name &name)
const;
338 operator != (
const Name &name)
const;
344 operator <= (
const Name &name)
const;
350 operator < (
const Name &name)
const;
356 operator >= (
const Name &name)
const;
362 operator > (
const Name &name)
const;
369 operator [] (
int index);
376 operator [] (
int index)
const;
382 operator + (
const Name &name)
const;
389 push_back (
const T &comp);
394 const static size_t npos =
static_cast<size_t> (-1);
395 const static uint64_t nversion =
static_cast<uint64_t
> (-1);
398 std::vector<name::Component> m_comps;
401 inline std::ostream &
402 operator << (std::ostream &os,
const Name &name)
408 inline std::istream &
409 operator >> (std::istream &is, Name &name)
422 template<
class Iterator>
423 Name::Name (Iterator begin, Iterator end)
431 if (comp.size () != 0)
439 if (comp.size () != 0)
442 newComp->swap (comp);
447 template<
class Iterator>
449 Name::append (Iterator begin, Iterator end)
451 for (Iterator i = begin; i != end; i++)
459 Name::append (
const Name &comp)
466 return append (comp.
begin (), comp.
end ());
470 Name::append (
const std::string &compStr)
473 return appendBySwap (comp);
477 Name::append (
const void *buf,
size_t size)
480 return appendBySwap (comp);
484 Name::appendNumber (uint64_t number)
487 return appendBySwap (comp.
fromNumber (number));
491 Name::appendNumberWithMarker (uint64_t number,
unsigned char marker)
498 Name::appendSeqNum (uint64_t seqno)
500 return appendNumberWithMarker (seqno, 0x00);
504 Name::appendControlNum (uint64_t control)
506 return appendNumberWithMarker (control, 0xC1);
510 Name::appendBlkId (uint64_t blkid)
512 return appendNumberWithMarker (blkid, 0xFB);
518 return m_comps.size ();
524 inline Name::const_iterator
527 return m_comps.begin ();
530 inline Name::iterator
533 return m_comps.begin ();
536 inline Name::const_iterator
539 return m_comps.end ();
542 inline Name::iterator
545 return m_comps.end ();
548 inline Name::const_reverse_iterator
549 Name::rbegin ()
const
551 return m_comps.rbegin ();
554 inline Name::reverse_iterator
557 return m_comps.rbegin ();
560 inline Name::const_reverse_iterator
563 return m_comps.rend ();
567 inline Name::reverse_iterator
570 return m_comps.rend ();
578 Name::getPrefix (
size_t len,
size_t skip)
const
580 return getSubName (skip, len);
584 Name::getPostfix (
size_t len,
size_t skip)
const
586 return getSubName (size () - len - skip, len);
592 Name::push_back (
const T &comp)
598 Name::operator ==(
const Name &name)
const
600 return (compare (name) == 0);
604 Name::operator !=(
const Name &name)
const
606 return (compare (name) != 0);
610 Name::operator <= (
const Name &name)
const
612 return (compare (name) <= 0);
616 Name::operator < (
const Name &name)
const
618 return (compare (name) < 0);
622 Name::operator >= (
const Name &name)
const
624 return (compare (name) >= 0);
628 Name::operator > (
const Name &name)
const
630 return (compare (name) > 0);
634 Name::operator [] (
int index)
640 Name::operator [] (
int index)
const
645 ATTRIBUTE_HELPER_HEADER (
Name);
std::string toUri() const
Get text representation of the name (URI)
Name::const_iterator end() const
End iterator (const)
Name::const_iterator begin() const
Begin iterator (const)
Component & fromNumber(uint64_t number)
Create network-ordered numeric 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.
Component & fromNumberWithMarker(uint64_t number, unsigned char marker)
Create network-ordered numeric component to the name with marker.
void push_back(const T &comp)
A wrapper for append method.