00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00075 #ifndef OSCUNPACKER_H
00076 #define OSCUNPACKER_H
00077
00078 #include "int64_t.h"
00079
00080 #ifdef __MACH__
00081 #include <sys/types.h>
00082 #include <machine/endian.h>
00083 #else
00084 #include <netinet/in.h>
00085 #endif
00086
00087 #include <string>
00088 #include <string.h>
00089 #include <utility>
00090
00091 #include <iostream>
00092
00093
00094 class OSCUnpacker
00095 {
00096 private:
00097 std::string myData;
00098 int myPosition;
00099
00100 protected:
00101 std::string *getDataPointer() { return &(this->myData); }
00103 bool unpackBytes(char *out, int bytes);
00105 bool skipBytes(int bytes);
00106 int getPosition() { return this->myPosition; }
00107 void setPosition(int p) { this->myPosition = p; }
00108
00109 public:
00110 OSCUnpacker();
00111
00112 void init() { this->reset(); }
00113 void reset() { this->setPosition(0); }
00114
00116 bool unpackDouble (double *out);
00118 bool unpackFloat (float *out);
00120 bool unpackHyper (int64_t *out);
00122 bool unpackInt (int32_t *out);
00123
00125 bool unpackString (std::string *out);
00127 bool unpackBlob (std::string *out);
00128
00129
00130
00131
00132
00134 bool skipDouble();
00136 bool skipFloat();
00138 bool skipHyper();
00140 bool skipInt();
00142 bool skipString();
00144 bool skipBlob();
00145
00146 void setData(const std::string& data);
00147 };
00148
00149 #endif