NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ns3::ndn::Name Class Reference

Class for NDN Name. More...

#include <name.h>

Inheritance diagram for ns3::ndn::Name:
Collaboration diagram for ns3::ndn::Name:

Public Types

typedef std::vector
< name::Component >::iterator 
iterator
 
typedef std::vector
< name::Component >
::const_iterator 
const_iterator
 
typedef std::vector
< name::Component >
::reverse_iterator 
reverse_iterator
 
typedef std::vector
< name::Component >
::const_reverse_iterator 
const_reverse_iterator
 
typedef std::vector
< name::Component >::reference 
reference
 
typedef std::vector
< name::Component >
::const_reference 
const_reference
 
typedef name::Component partial_type
 

Public Member Functions

 Name ()
 Default constructor to create an empty name (zero components, or "/")
 
 Name (const Name &other)
 Copy constructor. More...
 
 Name (const std::string &url)
 Create a name from URL string. More...
 
template<class Iterator >
 Name (Iterator begin, Iterator end)
 Create a name from a container of elements [begin, end) More...
 
Nameoperator= (const Name &other)
 Assignment operator.
 
Nameappend (const name::Component &comp)
 Append a binary blob as a name component. More...
 
NameappendBySwap (name::Component &comp)
 Append a binary blob as a name component. More...
 
template<class Iterator >
Nameappend (Iterator begin, Iterator end)
 Append components a container of elements [begin, end) More...
 
Nameappend (const Name &comp)
 Append components from another ndn::Name object. More...
 
Nameappend (const std::string &compStr)
 Append a string as a name component. More...
 
Nameappend (const void *buf, size_t size)
 Append a binary blob as a name component. More...
 
NameappendNumber (uint64_t number)
 Append network-ordered numeric component to the name. More...
 
NameappendNumberWithMarker (uint64_t number, unsigned char marker)
 Append network-ordered numeric component to the name with marker. More...
 
NameappendSeqNum (uint64_t seqno)
 Helper method to add sequence number to the name (marker = 0x00) More...
 
NameappendControlNum (uint64_t control)
 Helper method to add control number to the name (marker = 0xC1) More...
 
NameappendBlkId (uint64_t blkid)
 Helper method to add block ID to the name (marker = 0xFB) More...
 
NameappendVersion (uint64_t version=Name::nversion)
 Helper method to add version to the name (marker = 0xFD) More...
 
size_t size () const
 Get number of the name components. More...
 
const name::Componentget (int index) const
 Get binary blob of name component. More...
 
name::Componentget (int index)
 Get binary blob of name component. More...
 
Name::const_iterator begin () const
 Begin iterator (const)
 
Name::iterator begin ()
 Begin iterator.
 
Name::const_iterator end () const
 End iterator (const)
 
Name::iterator end ()
 End iterator.
 
Name::const_reverse_iterator rbegin () const
 Reverse begin iterator (const)
 
Name::reverse_iterator rbegin ()
 Reverse begin iterator.
 
Name::const_reverse_iterator rend () const
 Reverse end iterator (const)
 
Name::reverse_iterator rend ()
 Reverse end iterator.
 
Name getSubName (size_t pos=0, size_t len=npos) const
 Get a new name, constructed as a subset of components. More...
 
Name getPrefix (size_t len, size_t skip=0) const
 Get prefix of the name. More...
 
Name getPostfix (size_t len, size_t skip=0) const
 Get postfix of the name. More...
 
std::string toUri () const
 Get text representation of the name (URI)
 
void toUri (std::ostream &os) const
 Write name as URI to the specified output stream. More...
 
int compare (const Name &name) const
 Compare two names, using canonical ordering for each component. More...
 
bool operator== (const Name &name) const
 Check if to Name objects are equal (have the same number of components with the same binary data)
 
bool operator!= (const Name &name) const
 Check if two Name objects are not equal.
 
bool operator<= (const Name &name) const
 Less or equal comparison of two name objects.
 
bool operator< (const Name &name) const
 Less comparison of two name objects.
 
bool operator>= (const Name &name) const
 Great or equal comparison of two name objects.
 
bool operator> (const Name &name) const
 Great comparison of two name objects.
 
name::Componentoperator[] (int index)
 Operator [] to simplify access to name components. More...
 
const name::Componentoperator[] (int index) const
 Operator [] to simplify access to name components. More...
 
Name operator+ (const Name &name) const
 Create a new Name object, by copying components from first and second name.
 
template<class T >
void push_back (const T &comp)
 A wrapper for append method.
 

Static Public Attributes

static const size_t npos = static_cast<size_t> (-1)
 Value returned by various member functions when they fail.
 
static const uint64_t nversion = static_cast<uint64_t> (-1)
 

Detailed Description

Class for NDN Name.

Definition at line 29 of file name.h.

Constructor & Destructor Documentation

ns3::ndn::Name::Name ( const Name other)

Copy constructor.

Parameters
otherreference to a NDN name object

Definition at line 102 of file name.cc.

ns3::ndn::Name::Name ( const std::string &  url)

Create a name from URL string.

Parameters
urlURI-represented name
template<class Iterator >
ns3::ndn::Name::Name ( Iterator  begin,
Iterator  end 
)

Create a name from a container of elements [begin, end)

Parameters
beginbegin iterator of the container
endend iterator of the container

Definition at line 423 of file name.h.

Member Function Documentation

Name & ns3::ndn::Name::append ( const name::Component comp)
inline

Append a binary blob as a name component.

Parameters
compa binary blob
Returns
reference to self (to allow chaining of append methods)

Definition at line 429 of file name.h.

References push_back().

Referenced by getSubName(), operator+(), and ns3::ndn::wire::CcnbParser::NameVisitor::visit().

template<class Iterator >
Name & ns3::ndn::Name::append ( Iterator  begin,
Iterator  end 
)
inline

Append components a container of elements [begin, end)

Parameters
beginbegin iterator of the container
endend iterator of the container
Returns
reference to self (to allow chaining of append methods)

Definition at line 449 of file name.h.

Name & ns3::ndn::Name::append ( const Name comp)
inline

Append components from another ndn::Name object.

Parameters
compreference to Name object
Returns
reference to self (to allow chaining of append methods)

Definition at line 459 of file name.h.

References begin(), and end().

Name & ns3::ndn::Name::append ( const std::string &  compStr)
inline

Append a string as a name component.

Parameters
compStra string
Returns
reference to self (to allow chaining of append methods)

No conversions will be done to the string. The string is included in raw form, without any leading '\0' symbols.

Definition at line 470 of file name.h.

Name & ns3::ndn::Name::append ( const void *  buf,
size_t  size 
)
inline

Append a binary blob as a name component.

Parameters
bufpointer to the first byte of the binary blob
sizelength of the binary blob
Returns
reference to self (to allow chaining of append methods)

Definition at line 477 of file name.h.

Name & ns3::ndn::Name::appendBlkId ( uint64_t  blkid)
inline

Helper method to add block ID to the name (marker = 0xFB)

Parameters
blkidblock ID
See also
appendNumberWithMarker

Definition at line 510 of file name.h.

Name & ns3::ndn::Name::appendBySwap ( name::Component comp)
inline

Append a binary blob as a name component.

Parameters
compa binary blob

This version is a little bit more efficient, since it swaps contents of comp and newly added component

Attention!!! This method has an intended side effect: content of comp becomes empty

Definition at line 437 of file name.h.

Name & ns3::ndn::Name::appendControlNum ( uint64_t  control)
inline

Helper method to add control number to the name (marker = 0xC1)

Parameters
controlcontrol number
See also
appendNumberWithMarker

Definition at line 504 of file name.h.

Name & ns3::ndn::Name::appendNumber ( uint64_t  number)
inline

Append network-ordered numeric component to the name.

Parameters
numbernumber to be encoded and added as a component

Number is encoded and added in network order. Tail zero-bytes are not included. For example, if the number is 1, then 1-byte binary blob will be added 0x01. If the number is 256, then 2 binary blob will be added: 0x01 0x01

If the number is zero, an empty component will be added

Definition at line 484 of file name.h.

References ns3::ndn::name::Component::fromNumber().

Name & ns3::ndn::Name::appendNumberWithMarker ( uint64_t  number,
unsigned char  marker 
)
inline

Append network-ordered numeric component to the name with marker.

Parameters
numbernumber to be encoded and added as a component
markerbyte marker, specified by the desired naming convention

Currently defined naming conventions of the marker:

  • 0x00 sequence number
  • 0xC1 control number
  • 0xFB block id
  • 0xFD version number

This version is almost exactly as appendNumber, with exception that it adds initial marker. The number is formatted in the exactly the same way.

See also
appendNumber

Definition at line 491 of file name.h.

References ns3::ndn::name::Component::fromNumberWithMarker().

Name & ns3::ndn::Name::appendSeqNum ( uint64_t  seqno)
inline

Helper method to add sequence number to the name (marker = 0x00)

Parameters
seqnosequence number
See also
appendNumberWithMarker

Definition at line 498 of file name.h.

Name & ns3::ndn::Name::appendVersion ( uint64_t  version = Name::nversion)

Helper method to add version to the name (marker = 0xFD)

Parameters
versionfully formatted version in a desired format (e.g., timestamp). If version is Name::nversion, then the version number is automatically assigned based on UTC timestamp
See also
appendNumberWithMarker

Definition at line 119 of file name.cc.

int ns3::ndn::Name::compare ( const Name name) const

Compare two names, using canonical ordering for each component.

Returns
0 They compare equal <0 If *this comes before other in the canonical ordering >0 If *this comes after in the canonical ordering

Definition at line 253 of file name.cc.

References begin(), and end().

const name::Component & ns3::ndn::Name::get ( int  index) const

Get binary blob of name component.

Parameters
indexindex of the name component. If less than 0, then getting component from the back: get(-1) getting the last component, get(-2) is getting second component from back, etc.
Returns
const reference to binary blob of the requested name component

If index is out of range, an exception will be thrown

Definition at line 144 of file name.cc.

name::Component & ns3::ndn::Name::get ( int  index)

Get binary blob of name component.

Parameters
indexindex of the name component. If less than 0, then getting component from the back
Returns
reference to binary blob of the requested name component

If index is out of range, an exception will be thrown

Definition at line 161 of file name.cc.

Name ns3::ndn::Name::getPostfix ( size_t  len,
size_t  skip = 0 
) const
inline

Get postfix of the name.

Parameters
lenlength of the postfix
skipnumber of components to skip from end of the name

Definition at line 584 of file name.h.

Name ns3::ndn::Name::getPrefix ( size_t  len,
size_t  skip = 0 
) const
inline

Get prefix of the name.

Parameters
lenlength of the prefix
skipnumber of components to skip from beginning of the name

Definition at line 578 of file name.h.

Name ns3::ndn::Name::getSubName ( size_t  pos = 0,
size_t  len = npos 
) const

Get a new name, constructed as a subset of components.

Parameters
posPosition of the first component to be copied to the subname
lenNumber of components to be copied. Value Name::npos indicates that all components till the end of the name.

Definition at line 184 of file name.cc.

References append().

name::Component & ns3::ndn::Name::operator[] ( int  index)
inline

Operator [] to simplify access to name components.

See also
get

Definition at line 634 of file name.h.

const name::Component & ns3::ndn::Name::operator[] ( int  index) const
inline

Operator [] to simplify access to name components.

See also
get

Definition at line 640 of file name.h.

size_t ns3::ndn::Name::size ( ) const
inline

Get number of the name components.

Returns
number of name components

Definition at line 516 of file name.h.

Referenced by ns3::ndn::Producer::OnInterest().

void ns3::ndn::Name::toUri ( std::ostream &  os) const

Write name as URI to the specified output stream.

Parameters
osoutput stream

Definition at line 229 of file name.cc.


The documentation for this class was generated from the following files: