root/oscpack/trunk/osc/OscTypes.h

Revision 53, 3.9 kB (checked in by ross, 3 years ago)

x86_64 fix from John Ffitch plus other 64 bit portability fixes

  • Property svn:eol-style set to native
Line 
1 /*
2         oscpack -- Open Sound Control packet manipulation library
3         http://www.audiomulch.com/~rossb/oscpack
4
5         Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
6
7         Permission is hereby granted, free of charge, to any person obtaining
8         a copy of this software and associated documentation files
9         (the "Software"), to deal in the Software without restriction,
10         including without limitation the rights to use, copy, modify, merge,
11         publish, distribute, sublicense, and/or sell copies of the Software,
12         and to permit persons to whom the Software is furnished to do so,
13         subject to the following conditions:
14
15         The above copyright notice and this permission notice shall be
16         included in all copies or substantial portions of the Software.
17
18         Any person wishing to distribute modifications to the Software is
19         requested to send the modifications to the original developer so that
20         they can be incorporated into the canonical version.
21
22         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24         MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25         IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26         ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27         CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28         WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 */
30 #ifndef INCLUDED_OSCTYPES_H
31 #define INCLUDED_OSCTYPES_H
32
33
34 namespace osc{
35
36 // basic types
37
38 #if defined(__BORLANDC__) || defined(_MSC_VER)
39
40 typedef __int64 int64;
41 typedef unsigned __int64 uint64;
42
43 #else
44
45 typedef long long int64;
46 typedef unsigned long long uint64;
47
48 #endif
49
50
51
52 #ifdef x86_64
53
54 typedef signed int int32;
55 typedef unsigned int uint32;
56
57 #else
58
59 typedef signed long int32;
60 typedef unsigned long uint32;
61
62 #endif
63
64
65
66 enum TypeTagValues {
67     TRUE_TYPE_TAG = 'T',
68     FALSE_TYPE_TAG = 'F',
69     NIL_TYPE_TAG = 'N',
70     INFINITUM_TYPE_TAG = 'I',
71     INT32_TYPE_TAG = 'i',
72     FLOAT_TYPE_TAG = 'f',
73     CHAR_TYPE_TAG = 'c',
74     RGBA_COLOR_TYPE_TAG = 'r',
75     MIDI_MESSAGE_TYPE_TAG = 'm',
76     INT64_TYPE_TAG = 'h',
77     TIME_TAG_TYPE_TAG = 't',
78     DOUBLE_TYPE_TAG = 'd',
79     STRING_TYPE_TAG = 's',
80     SYMBOL_TYPE_TAG = 'S',
81     BLOB_TYPE_TAG = 'b'
82 };
83
84
85
86 // i/o manipulators used for streaming interfaces
87
88 struct BundleInitiator{
89     explicit BundleInitiator( uint64 timeTag_ ) : timeTag( timeTag_ ) {}
90     uint64 timeTag;
91 };
92
93 extern BundleInitiator BeginBundleImmediate;
94
95 inline BundleInitiator BeginBundle( uint64 timeTag=1 )
96 {
97     return BundleInitiator(timeTag);
98 }
99
100
101 struct BundleTerminator{
102 };
103
104 extern BundleTerminator EndBundle;
105
106 struct BeginMessage{
107     explicit BeginMessage( const char *addressPattern_ ) : addressPattern( addressPattern_ ) {}
108     const char *addressPattern;
109 };
110
111 struct MessageTerminator{
112 };
113
114 extern MessageTerminator EndMessage;
115
116
117 // osc specific types. they are defined as structs so they can be used
118 // as separately identifiable types with the streaming operators.
119
120 struct NilType{
121 };
122
123 extern NilType Nil;
124
125
126 struct InfinitumType{
127 };
128
129 extern InfinitumType Infinitum;
130
131 struct RgbaColor{
132     RgbaColor() {}
133     explicit RgbaColor( uint32 value_ ) : value( value_ ) {}
134     uint32 value;
135
136     operator uint32() const { return value; }
137 };
138
139
140 struct MidiMessage{
141     MidiMessage() {}
142     explicit MidiMessage( uint32 value_ ) : value( value_ ) {}
143     uint32 value;
144
145     operator uint32() const { return value; }
146 };
147
148
149 struct TimeTag{
150     TimeTag() {}
151     explicit TimeTag( uint64 value_ ) : value( value_ ) {}
152     uint64 value;
153
154     operator uint64() const { return value; }
155 };
156
157
158 struct Symbol{
159     Symbol() {}
160     explicit Symbol( const char* value_ ) : value( value_ ) {}
161     const char* value;
162
163     operator const char *() const { return value; }
164 };
165
166
167 struct Blob{
168     Blob() {}
169     explicit Blob( const void* data_, unsigned long size_ )
170             : data( data_ ), size( size_ ) {}
171     const void* data;
172     unsigned long size;
173 };
174
175 } // namespace osc
176
177
178 #endif /* INCLUDED_OSCTYPES_H */
Note: See TracBrowser for help on using the browser.