| 1 |
/* |
| 2 |
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2020 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 29 мая 2019 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef LSP_PLUG_IN_PROTOCOL_OSC_PARSE_H_ |
| 23 |
#define LSP_PLUG_IN_PROTOCOL_OSC_PARSE_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
#include <lsp-plug.in/protocol/osc/types.h> |
| 27 |
|
| 28 |
namespace lsp |
| 29 |
{ |
| 30 |
namespace osc |
| 31 |
{ |
| 32 |
typedef struct parser_t parser_t; |
| 33 |
|
| 34 |
typedef struct parse_frame_t |
| 35 |
{ |
| 36 |
parser_t *parser; |
| 37 |
parse_frame_t *parent; |
| 38 |
parse_frame_t *child; |
| 39 |
size_t type; |
| 40 |
|
| 41 |
size_t limit; |
| 42 |
} parser_frame_t; |
| 43 |
|
| 44 |
struct parser_t |
| 45 |
{ |
| 46 |
const uint8_t *data; |
| 47 |
size_t offset; |
| 48 |
size_t size; |
| 49 |
|
| 50 |
size_t refs; |
| 51 |
const char *args; |
| 52 |
}; |
| 53 |
|
| 54 |
enum parse_token_t |
| 55 |
{ |
| 56 |
PT_BUNDLE, |
| 57 |
PT_MESSAGE, |
| 58 |
PT_EOR, |
| 59 |
|
| 60 |
PT_INT32, |
| 61 |
PT_FLOAT32, |
| 62 |
PT_OSC_STRING, |
| 63 |
PT_OSC_BLOB, |
| 64 |
PT_INT64, |
| 65 |
PT_OSC_TIMETAG, |
| 66 |
PT_DOUBLE64, |
| 67 |
PT_TYPE, |
| 68 |
PT_ASCII_CHAR, |
| 69 |
PT_RGBA_COLOR, |
| 70 |
PT_MIDI_MESSAGE, |
| 71 |
PT_TRUE, |
| 72 |
PT_FALSE, |
| 73 |
PT_NULL, |
| 74 |
PT_INF, |
| 75 |
PT_ARRAY, |
| 76 |
|
| 77 |
PT_SYMBOL = PT_TYPE |
| 78 |
}; |
| 79 |
|
| 80 |
status_t parse_begin(parse_frame_t *ref, parser_t *parser, const void *data, size_t size); |
| 81 |
|
| 82 |
status_t parse_token(parse_frame_t *ref, parse_token_t *token); |
| 83 |
|
| 84 |
status_t parse_begin_message(parse_frame_t *child, parse_frame_t *ref, const char **address); |
| 85 |
status_t parse_begin_bundle(parse_frame_t *child, parse_frame_t *ref, uint64_t *time_tag); |
| 86 |
status_t parse_begin_array(parse_frame_t *child, parse_frame_t *ref); |
| 87 |
|
| 88 |
status_t parse_raw_message(parse_frame_t *ref, const void **start, size_t *size, const char **address); |
| 89 |
status_t parse_skip(parse_frame_t *ref); |
| 90 |
status_t parse_int32(parse_frame_t *ref, int32_t *value); |
| 91 |
status_t parse_float32(parse_frame_t *ref, float *value); |
| 92 |
status_t parse_string(parse_frame_t *ref, const char **s); |
| 93 |
status_t parse_blob(parse_frame_t *ref, const void **data, size_t *len); |
| 94 |
status_t parse_int64(parse_frame_t *ref, int64_t *value); |
| 95 |
status_t parse_double64(parse_frame_t *ref, double *value); |
| 96 |
status_t parse_time_tag(parse_frame_t *ref, uint64_t *value); |
| 97 |
status_t parse_type(parse_frame_t *ref, const char **s); |
| 98 |
status_t parse_symbol(parse_frame_t *ref, const char **s); |
| 99 |
status_t parse_ascii(parse_frame_t *ref, char *c); |
| 100 |
status_t parse_rgba(parse_frame_t *ref, uint32_t *rgba); |
| 101 |
status_t parse_midi(parse_frame_t *ref, midi::event_t *event); |
| 102 |
status_t parse_midi_raw(parse_frame_t *ref, const uint8_t **event, size_t *len); |
| 103 |
status_t parse_bool(parse_frame_t *ref, bool *value); |
| 104 |
status_t parse_null(parse_frame_t *ref); |
| 105 |
status_t parse_inf(parse_frame_t *ref); |
| 106 |
|
| 107 |
status_t parse_message(parse_frame_t *ref, const char *params, const char **address...); |
| 108 |
status_t parse_messagev(parse_frame_t *ref, const char *params, const char **address, va_list args); |
| 109 |
|
| 110 |
status_t parse_end(parse_frame_t *ref); |
| 111 |
|
| 112 |
status_t parse_destroy(parser_t *parser); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
#endif /* LSP_PLUG_IN_PROTOCOL_OSC_PARSE_H_ */ |