OSCPacker.h

00001 /* Open SoundControl kit in C++                                              */
00002 /* Copyright (C) 2002-2004 libOSC++ contributors. See AUTHORS                */
00003 /*                                                                           */
00004 /* This library is free software; you can redistribute it and/or             */
00005 /* modify it under the terms of the GNU Lesser General Public                */
00006 /* License as published by the Free Software Foundation; either              */
00007 /* version 2.1 of the License, or (at your option) any later version.        */
00008 /*                                                                           */
00009 /* This library is distributed in the hope that it will be useful,           */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         */
00012 /* Lesser General Public License for more details.                           */
00013 /*                                                                           */
00014 /* You should have received a copy of the GNU Lesser General Public          */
00015 /* License along with this library; if not, write to the Free Software       */
00016 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00017 /*                                                                           */
00018 /* For questions regarding this program contact                              */
00019 /* Daniel Holth <dholth@fastmail.fm> or visit                                */
00020 /* http://wiretap.stetson.edu/                                               */
00021 
00034 #ifndef OSCPACKER_H
00035 #define OSCPACKER_H
00036 
00037 #include "int64_t.h"
00038 
00039 #ifdef __MACH__
00040 #include <sys/types.h>
00041 #include <machine/endian.h>
00042 #else
00043 #include <netinet/in.h>
00044 #endif
00045 
00046 
00047 #include <string>
00048 
00049 
00050 class OSCPacker
00051 {
00052   private:
00053     std::string myData;
00054 
00055   protected:
00056     std::string *getDataPointer()  { return &(this->myData); }
00057     bool appendFourBytes  (char *bytes);
00058     bool appendEightBytes (char *bytes);
00059     bool appendBytes      (char *bytes, int count);
00061     void padString(std::string *data);
00062     virtual bool packBytes  (const char*, int bytes);
00063 
00064   public:
00065     OSCPacker() {}
00066     virtual ~OSCPacker()  {}
00067     
00068     virtual void init()     {}
00069     virtual void reset();
00070 
00071     virtual bool packInt    (int32_t);
00072     virtual bool packHyper  (int64_t);
00073     virtual bool packFloat  (float);
00074     virtual bool packDouble (double);
00075     virtual bool packString (const std::string*);
00076     virtual bool packString (const char*);
00077     virtual bool packBlob   (const char*, int bytes);
00078       
00079     virtual std::string getData();
00080 };
00081 
00082 #endif

Generated on Thu Mar 2 23:51:35 2006 for libOSC++ by  doxygen 1.4.6