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::Component Class Reference

Class to representing binary blob of NDN name component. More...

#include <name-component.h>

Inheritance diagram for ns3::ndn::name::Component:
Collaboration diagram for ns3::ndn::name::Component:

Public Member Functions

 Component ()
 Default constructor an empty exclude.
 
 Component (const std::string &uri)
 Create component from URI encoded string. More...
 
 Component (std::string::const_iterator begin, std::string::const_iterator end)
 Create component from URI encoded string, with string specified by a pair of iterators. More...
 
 Component (const void *buf, size_t length)
 Create component using a binary blob. More...
 
int compare (const Component &other) const
 Apply canonical ordering on component comparison. More...
 
bool operator<= (const Component &other) const
 Apply canonical ordering on component comparison (less or equal) More...
 
bool operator< (const Component &other) const
 Apply canonical ordering on component comparison (less) More...
 
bool operator>= (const Component &other) const
 Apply canonical ordering on component comparison (greater or equal) More...
 
bool operator> (const Component &other) const
 Apply canonical ordering on component comparison (greater) More...
 
ComponentfromUri (const std::string &uri)
 Create component from URI encoded string. More...
 
ComponentfromUri (std::string::const_iterator begin, std::string::const_iterator end)
 Create component from URI encoded string, with string specified by a pair of iterators. More...
 
ComponentfromNumber (uint64_t number)
 Create network-ordered numeric component. More...
 
ComponentfromNumberWithMarker (uint64_t number, unsigned char marker)
 Create network-ordered numeric component to the name with marker. More...
 
std::string toBlob () const
 Convert binary blob name component to std::string (no conversion is made) More...
 
void toBlob (std::ostream &os) const
 Write blob of the name component to the specified output stream. More...
 
std::string toUri () const
 Convert binary blob name component to std::string, escaping all non-printable characters in URI format. More...
 
void toUri (std::ostream &os) const
 Write name as URI to the specified output stream. More...
 
uint64_t toNumber () const
 Convert binary blob name component (network-ordered number) to number. More...
 
uint64_t toNumberWithMarker (unsigned char marker) const
 Convert binary blob name component (network-ordered number) to number, using appropriate marker from the naming convention. More...
 
uint64_t toSeqNum () const
 Convert binary blob name component, assuming sequence number naming convention (marker = 0x00) More...
 
uint64_t toControlNum () const
 Convert binary blob name component, assuming control number naming convention (marker = 0xC1) More...
 
uint64_t toBlkId () const
 Convert binary blob name component, assuming block ID naming convention (marker = 0xFB) More...
 
uint64_t toVersion () const
 Convert binary blob name component, assuming time-stamping version naming convention (marker = 0xFD) More...
 
- Public Member Functions inherited from ns3::ndn::Blob
 Blob ()
 Creates an empty blob.
 
 Blob (const std::string &data)
 
 Blob (const void *buf, size_t length)
 
char * buf ()
 Get pointer to the first byte of the binary blob.
 
const char * buf () const
 Get const pointer to the first byte of the binary blob.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t size () const
 
void swap (Blob &x)
 
void push_back (value_type val)
 
bool empty () const
 
Bloboperator= (const Blob &other)
 
reference operator[] (size_type pos)
 
const_reference operator[] (size_type pos) const
 
char getItem (size_type pos) const
 
void clear ()
 

Additional Inherited Members

- Public Types inherited from ns3::ndn::Blob
typedef std::vector< char > base
 
typedef base::value_type value_type
 
typedef base::pointer pointer
 
typedef base::const_pointer const_pointer
 
typedef base::reference reference
 
typedef base::const_reference const_reference
 
typedef base::iterator iterator
 
typedef base::const_iterator const_iterator
 
typedef
base::const_reverse_iterator 
const_reverse_iterator
 
typedef base::reverse_iterator reverse_iterator
 
typedef base::size_type size_type
 
typedef base::difference_type difference_type
 
typedef base::allocator_type allocator_type
 

Detailed Description

Class to representing binary blob of NDN name component.

This class is based on Blob (std::vector<char>) and just provides several helpers to work with name components, as well as operator to apply canonical ordering on name components

Definition at line 28 of file name-component.h.

Constructor & Destructor Documentation

ns3::ndn::name::Component::Component ( const std::string &  uri)

Create component from URI encoded string.

Parameters
uriURI encoded name component (convert escaped with % characters)

Definition at line 31 of file name-component.cc.

ns3::ndn::name::Component::Component ( std::string::const_iterator  begin,
std::string::const_iterator  end 
)

Create component from URI encoded string, with string specified by a pair of iterators.

Parameters
beginbegin iterator pointing to the URI encoded name
endend iterator

Definition at line 36 of file name-component.cc.

ns3::ndn::name::Component::Component ( const void *  buf,
size_t  length 
)

Create component using a binary blob.

Parameters
bufpointer to first byte of binary blob to store as a name component
lengthlength of the binary blob

Definition at line 41 of file name-component.cc.

Member Function Documentation

int ns3::ndn::name::Component::compare ( const Component other) const

Apply canonical ordering on component comparison.

Returns
0 They compare equal <0 If *this comes before other in the canonical ordering >0 If *this comes after in the canonical ordering
See also
http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html

Definition at line 84 of file name-component.cc.

Component & ns3::ndn::name::Component::fromNumber ( uint64_t  number)

Create network-ordered numeric component.

Parameters
numbernumber to be encoded and added as a component
Returns
*this

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 created

Definition at line 102 of file name-component.cc.

Referenced by ns3::ndn::Name::appendNumber().

Component & ns3::ndn::name::Component::fromNumberWithMarker ( uint64_t  number,
unsigned char  marker 
)

Create 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
fromNumber

Definition at line 114 of file name-component.cc.

Referenced by ns3::ndn::Name::appendNumberWithMarker().

Component & ns3::ndn::name::Component::fromUri ( const std::string &  uri)

Create component from URI encoded string.

Parameters
uriURI encoded name component (convert escaped with % characters)
Returns
*this

Definition at line 49 of file name-component.cc.

References ns3::ndn::error::get_pos().

Component & ns3::ndn::name::Component::fromUri ( std::string::const_iterator  begin,
std::string::const_iterator  end 
)

Create component from URI encoded string, with string specified by a pair of iterators.

Parameters
beginbegin iterator pointing to the URI encoded name
endend iterator
Returns
*this

Definition at line 67 of file name-component.cc.

References ns3::ndn::error::get_pos().

bool ns3::ndn::name::Component::operator< ( const Component other) const
inline

Apply canonical ordering on component comparison (less)

See also
http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html

Definition at line 246 of file name-component.h.

bool ns3::ndn::name::Component::operator<= ( const Component other) const
inline

Apply canonical ordering on component comparison (less or equal)

See also
http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html

Definition at line 240 of file name-component.h.

bool ns3::ndn::name::Component::operator> ( const Component other) const
inline

Apply canonical ordering on component comparison (greater)

See also
http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html

Definition at line 258 of file name-component.h.

bool ns3::ndn::name::Component::operator>= ( const Component other) const
inline

Apply canonical ordering on component comparison (greater or equal)

See also
http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html

Definition at line 252 of file name-component.h.

uint64_t ns3::ndn::name::Component::toBlkId ( ) const
inline

Convert binary blob name component, assuming block ID naming convention (marker = 0xFB)

Parameters
compname component to be converted
See also
asNumberWithMarker

Definition at line 276 of file name-component.h.

std::string ns3::ndn::name::Component::toBlob ( ) const

Convert binary blob name component to std::string (no conversion is made)

Parameters
compname component to be converted
See also
asUriString

Definition at line 129 of file name-component.cc.

void ns3::ndn::name::Component::toBlob ( std::ostream &  os) const

Write blob of the name component to the specified output stream.

Parameters
osoutput stream

Definition at line 135 of file name-component.cc.

uint64_t ns3::ndn::name::Component::toControlNum ( ) const
inline

Convert binary blob name component, assuming control number naming convention (marker = 0xC1)

Parameters
compname component to be converted
See also
asNumberWithMarker

Definition at line 270 of file name-component.h.

uint64_t ns3::ndn::name::Component::toNumber ( ) const

Convert binary blob name component (network-ordered number) to number.

Parameters
compname component to be converted

Definition at line 192 of file name-component.cc.

uint64_t ns3::ndn::name::Component::toNumberWithMarker ( unsigned char  marker) const

Convert binary blob name component (network-ordered number) to number, using appropriate marker from the naming convention.

Parameters
compname component to be converted
markerrequired marker from the naming convention

If the required marker does not exist, an exception will be thrown

Definition at line 204 of file name-component.cc.

uint64_t ns3::ndn::name::Component::toSeqNum ( ) const
inline

Convert binary blob name component, assuming sequence number naming convention (marker = 0x00)

Parameters
compname component to be converted
See also
asNumberWithMarker

Definition at line 264 of file name-component.h.

std::string ns3::ndn::name::Component::toUri ( ) const

Convert binary blob name component to std::string, escaping all non-printable characters in URI format.

Parameters
compname component to be converted
See also
asString

Definition at line 141 of file name-component.cc.

Referenced by ns3::ndn::Exclude::excludeRange().

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

Write name as URI to the specified output stream.

Parameters
osoutput stream

Definition at line 149 of file name-component.cc.

uint64_t ns3::ndn::name::Component::toVersion ( ) const
inline

Convert binary blob name component, assuming time-stamping version naming convention (marker = 0xFD)

Parameters
compname component to be converted
See also
asNumberWithMarker

Definition at line 282 of file name-component.h.


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