title: Creating swig wrapper for C++ (pointers) to python
body: <p>I a very new to swig and I am trying to create a swig wrapper in order to use a few C++ files in python. I have the following C++ class.</p>
  
  <p>The following is a snippet of the code that I am trying to convert:</p>
  
  <pre><code>/*packet_buffer.h*/
  class CPacketBuffer {
   public:
      // construct based on given buffer, data is not copied
      CPacketBuffer(uint8_t* data, uint32_t length) {
          mpBuffer = data;
          mLength  = length;
          mHead    = 0;
          mTail    = length;
      }
      uint8_t* GetBuffer() {
          return (mpBuffer + mHead);
      }
      void Add(const uint8_t* data, uint32_t length) {
              if ((mTail + length) &gt; mLength) {
              length = (mLength - mTail);
          }
  //....
  }
  </code></pre>
  
  <p>I have been trying to write a example.i file that would accept pointers to typedefs(uint8_t *) all day today using help from swig documentation, but I have been unsuccessful.</p>
  
  <p>The following is a packet_buffer.i file that I have tried which doesn't work.</p>
  
  <pre><code>%module packet_buffer
  %include typemaps.i
  %apply unsigned char* {uint8_t*};
  %apply unit8_t *INPUT {uint8_t *data};
  
  
  
  %{
      #define SWIG_FILE_WITH_INIT
      #include "../include/packet_buffer.h"
  %}
  %include "../include/packet_buffer.h"
  </code></pre>
  
  <ol>
  <li>How do I write a swig code for member functions that take pointers to typedefs?</li>
  <li>Can I write a common %apply that can be used across the code or will I have to write specifics for each INPUT, OUTPUT parameter?</li>
  </ol>