iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugOSC_msg.h
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
20#include "IPlugPlatform.h"
21
22BEGIN_IPLUG_NAMESPACE
23
24#define MAX_OSC_MSG_LEN 1024
25#undef GetMessage
26
27static void OSC_BSWAPINTMEM(void *buf)
28{
29 char *p=(char *)buf;
30 char tmp=p[0]; p[0]=p[3]; p[3]=tmp;
31 tmp=p[1]; p[1]=p[2]; p[2]=tmp;
32}
33
34#define OSC_MAKEINTMEM4BE(x) OSC_BSWAPINTMEM(x)
35
36// thanks, REAPER
38{
39public:
41 OscMessageWrite(const OscMessageWrite&) = delete;
42 OscMessageWrite& operator=(const OscMessageWrite&) = delete;
43
44 bool PushWord(const char* word);
45 bool PushInt(int val); // push an int onto the message (not an int arg)
46 bool PushIntArg(int val);
47 bool PushFloatArg(float val);
48 bool PushStringArg(const char* val);
49 const char* GetBuffer(int* len);
50 void DebugDump(const char* label, char* dump, int dumplen);
51private:
52 char m_msg[MAX_OSC_MSG_LEN];
53 char m_types[MAX_OSC_MSG_LEN];
54 char m_args[MAX_OSC_MSG_LEN];
55 char* m_msg_ptr;
56 char* m_type_ptr;
57 char* m_arg_ptr;
58};
59
61{
62public:
63 OscMessageRead(char* buf, int len); // writes over buf
64 OscMessageRead(const OscMessageRead&) = delete;
65 OscMessageRead& operator=(const OscMessageRead&) = delete;
66
67 const char* GetMessage() const; // get the entire message string, no args
68 int GetNumArgs() const;
69 const char* PopWord();
70 const void* GetIndexedArg(int idx, char* typeOut) const; // offset from popped args, NULL if failed. typeOut required
71 const int* PopIntArg(bool peek);
72 const float* PopFloatArg(bool peek);
73 const char* PopStringArg(bool peek);
74 void DebugDump(const char* label, char* dump, int dumplen);
75private:
76 char* m_msg_end;
77 char* m_type_end;
78 char* m_arg_end;
79 char* m_msg_ptr;
80 char* m_type_ptr;
81 char* m_arg_ptr;
82 bool m_msgok;
83};
84
85END_IPLUG_NAMESPACE
Include to get consistently named preprocessor macros for different platforms and logging functionali...