reSIProcate/stack  9694
Static Public Member Functions | Private Member Functions
resip::Embedded Class Reference

#include <Embedded.hxx>

List of all members.

Static Public Member Functions

static char * decode (const Data &input, unsigned int &decodedLength)
static Data encode (const Data &input)

Private Member Functions

 Embedded ()

Detailed Description

Definition at line 9 of file Embedded.hxx.


Constructor & Destructor Documentation

resip::Embedded::Embedded ( ) [private]

Member Function Documentation

char * Embedded::decode ( const Data input,
unsigned int &  decodedLength 
) [static]

Definition at line 45 of file Embedded.cxx.

References resip::Data::data(), fromHex(), resip::Symbols::PERCENT, and resip::Data::size().

Referenced by main(), and resip::Uri::parseEmbeddedHeaders().

{
   const char *get = in.data();
   const char *end = get + in.size();
   char *ret = new char[in.size()];
   char *put = ret;

   count = 0;
   while (get < end)
   {
      if (*get == Symbols::PERCENT[0] && get+2 < end)
      {
         *put = fromHex(*(get+1), *(get+2));
         get += 3;
      }
      else
      {
         *put = *get;
         get++;
      }
      count++;
      put++;
   }

   return ret;
}

Here is the call graph for this function:

Data Embedded::encode ( const Data input) [static]

Definition at line 103 of file Embedded.cxx.

References hexMap, resip::Symbols::PERCENT, resip::Data::Preallocate, and resip::Data::size().

Referenced by main().

{
   Data out((int)((dat.size()*11)/10), Data::Preallocate);
   
   {
      DataStream str(out);
      for (Data::size_type i = 0; i < dat.size(); i++)
      {
         switch (dat[i])
         {
            case '0': case '1': case '2': case '3': case '4': case '5':
            case '6': case '7': case '8': case '9': case 'a': case 'b':
            case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
            case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
            case 'o': case 'p': case 'q': case 'r': case 's': case 't':
            case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
            case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
            case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
            case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
            case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
            case 'Y': case 'Z': case '[': case ']': case ',': case '?':
            case ':': case '+': case '$': case '-': case '_': case '.':
            case '!': case '~': case '*': case '\'': case '(': case ')':
               str << dat[i];
               break;

            default:
            {
               str << Symbols::PERCENT;

               unsigned char temp = dat[i];
               int hi = (temp & 0xf0)>>4;
               int low = (temp & 0xf);

               str << hexMap[hi];
               str << hexMap[low];
            }
         }
      }
   }

   return out;
}

Here is the call graph for this function:


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