11 #ifndef NDN_DETAIL_URI_H 
   12 #define NDN_DETAIL_URI_H 
   14 #include "ns3/ndn-common.h" 
   18 #include <boost/archive/iterators/transform_width.hpp> 
   19 #include <boost/iterator/transform_iterator.hpp> 
   26 static const bool ESCAPE_CHARACTER [256] = {
 
   27   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   28   1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
 
   29   0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
 
   30   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
 
   31   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   32   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   33   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   34   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   35   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 
   36   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 
 
   40 template<
class CharType>
 
   43   typedef CharType result_type;
 
   44   CharType operator () (CharType ch)
 const 
   46     const char lookup_table [16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'};
 
   48     BOOST_ASSERT (ch < 16);
 
   49     return lookup_table[
static_cast<size_t>(ch)];
 
   53 typedef boost::transform_iterator<hex_from_4_bit<std::string::const_iterator::value_type>,
 
   54                                   boost::archive::iterators::transform_width<std::string::const_iterator, 4, 8, std::string::const_iterator::value_type> > string_from_binary;
 
   58 template<
class CharType>
 
   61   typedef CharType result_type;
 
   62   CharType operator () (CharType ch)
 const 
   64     const signed char lookup_table [] = {
 
   65       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   66       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   67       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   68       0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
 
   69       -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   70       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   71       -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 
   72       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
 
   75     signed char value = -1;
 
   76     if ((
unsigned)ch < 128)
 
   77       value = lookup_table [(unsigned)ch];
 
   79       boost::throw_exception (error::StringTransform ());
 
   85 typedef boost::archive::iterators::transform_width<boost::transform_iterator<hex_to_4_bit<std::string::const_iterator::value_type>, std::string::const_iterator>, 8, 4> string_to_binary;
 
   96   template<
class Iterator1, 
class Iterator2>
 
   98   fromEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
 
  111                 std::copy (detail::string_to_binary (j), detail::string_to_binary (i), inserter);
 
  119         else if (!detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
 
  132   template<
class Iterator1, 
class Iterator2>
 
  134   toEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
 
  136     const char lookup_table [16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'};
 
  138     for (Iterator1 i = begin; i != end; i++)
 
  140         if (detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
 
  142             *inserter = 
'%';         ++inserter;
 
  143             *inserter = lookup_table [(*i >> 4) & 0x0F]; ++inserter;
 
  144             *inserter = lookup_table [(*i & 0x0F)];      ++inserter;
 
  148             *inserter = *i; ++inserter;
 
  156 #endif // NDN_DETAIL_URI_H 
This file defines basic elements for the library reporting. 
 
boost::error_info< struct tag_pos, int > pos
Report of the position of the error (error-specific meaning) 
 
An error with URI processing. 
 
A helper class to convert to/from URI.