1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
/*
* libopenmpt_cxx.cpp
* ------------------
* Purpose: libopenmpt C++ interface implementation
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#include "openmpt/all/BuildSettings.hpp"
#include "libopenmpt_internal.h"
#include "libopenmpt.hpp"
#include "libopenmpt_ext.hpp"
#include "libopenmpt_impl.hpp"
#include "libopenmpt_ext_impl.hpp"
#include <algorithm>
#include <stdexcept>
#include <cstdlib>
#include <cstring>
namespace openmpt {
exception::exception( const std::string & text_ ) noexcept
: std::exception()
, text(0)
{
text = static_cast<char*>( std::malloc( text_.length() + 1 ) );
if ( text ) {
std::memcpy( text, text_.c_str(), text_.length() + 1 );
}
}
exception::exception( const exception & other ) noexcept
: std::exception()
, text(0)
{
const char * const text_ = ( other.what() ? other.what() : "" );
text = static_cast<char*>( std::malloc( std::strlen( text_ ) + 1 ) );
if ( text ) {
std::memcpy( text, text_, std::strlen( text_ ) + 1 );
}
}
exception::exception( exception && other ) noexcept
: std::exception()
, text(0)
{
text = std::move( other.text );
other.text = 0;
}
exception & exception::operator = ( const exception & other ) noexcept {
if ( this == &other ) {
return *this;
}
if ( text ) {
std::free( text );
text = 0;
}
const char * const text_ = ( other.what() ? other.what() : "" );
text = static_cast<char*>( std::malloc( std::strlen( text_ ) + 1 ) );
if ( text ) {
std::memcpy( text, text_, std::strlen( text_ ) + 1 );
}
return *this;
}
exception & exception::operator = ( exception && other ) noexcept {
if ( this == &other ) {
return *this;
}
if ( text ) {
std::free( text );
text = 0;
}
text = std::move( other.text );
other.text = 0;
return *this;
}
exception::~exception() noexcept {
if ( text ) {
std::free( text );
text = 0;
}
}
const char * exception::what() const noexcept {
if ( text ) {
return text;
} else {
return "out of memory";
}
}
std::uint32_t get_library_version() {
return openmpt::version::get_library_version();
}
std::uint32_t get_core_version() {
return openmpt::version::get_core_version();
}
namespace string {
std::string get( const std::string & key ) {
return openmpt::version::get_string( key );
}
} // namespace string
} // namespace openmpt
namespace openmpt {
std::vector<std::string> get_supported_extensions() {
return openmpt::module_impl::get_supported_extensions();
}
bool is_extension_supported( const std::string & extension ) {
return openmpt::module_impl::is_extension_supported( extension );
}
bool is_extension_supported2( std::string_view extension ) {
return openmpt::module_impl::is_extension_supported( extension );
}
double could_open_probability( std::istream & stream, double effort, std::ostream & log ) {
return openmpt::module_impl::could_open_probability( stream, effort, openmpt::helper::make_unique<std_ostream_log>( log ) );
}
double could_open_propability( std::istream & stream, double effort, std::ostream & log ) {
return openmpt::module_impl::could_open_probability( stream, effort, openmpt::helper::make_unique<std_ostream_log>( log ) );
}
std::size_t probe_file_header_get_recommended_size() {
return openmpt::module_impl::probe_file_header_get_recommended_size();
}
int probe_file_header( std::uint64_t flags, const std::byte * data, std::size_t size, std::uint64_t filesize ) {
return openmpt::module_impl::probe_file_header( flags, data, size, filesize );
}
int probe_file_header( std::uint64_t flags, const std::uint8_t * data, std::size_t size, std::uint64_t filesize ) {
return openmpt::module_impl::probe_file_header( flags, data, size, filesize );
}
int probe_file_header( std::uint64_t flags, const std::byte * data, std::size_t size ) {
return openmpt::module_impl::probe_file_header( flags, data, size );
}
int probe_file_header( std::uint64_t flags, const std::uint8_t * data, std::size_t size ) {
return openmpt::module_impl::probe_file_header( flags, data, size );
}
int probe_file_header( std::uint64_t flags, std::istream & stream ) {
return openmpt::module_impl::probe_file_header( flags, stream );
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4702) // unreachable code
#endif // _MSC_VER
module::module( const module & ) : impl(nullptr) {
throw exception("openmpt::module is non-copyable");
}
// cppcheck-suppress operatorEqVarError
void module::operator = ( const module & ) {
throw exception("openmpt::module is non-copyable");
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif // _MSC_VER
module::module() : impl(0) {
return;
}
void module::set_impl( module_impl * i ) {
impl = i;
}
module::module( std::istream & stream, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( stream, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::vector<std::byte> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::byte * beg, const std::byte * end, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( beg, end - beg, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::byte * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::vector<std::uint8_t> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( beg, end - beg, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::uint8_t * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const std::vector<char> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const char * beg, const char * end, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( beg, end - beg, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const char * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::module( const void * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : impl(0) {
impl = new module_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
}
module::~module() {
delete impl;
impl = 0;
}
void module::select_subsong( std::int32_t subsong ) {
impl->select_subsong( subsong );
}
std::int32_t module::get_selected_subsong() const {
return impl->get_selected_subsong();
}
void module::set_repeat_count( std::int32_t repeat_count ) {
impl->set_repeat_count( repeat_count );
}
std::int32_t module::get_repeat_count() const {
return impl->get_repeat_count();
}
double module::get_duration_seconds() const {
return impl->get_duration_seconds();
}
double module::set_position_seconds( double seconds ) {
return impl->set_position_seconds( seconds );
}
double module::get_position_seconds() const {
return impl->get_position_seconds();
}
double module::set_position_order_row( std::int32_t order, std::int32_t row ) {
return impl->set_position_order_row( order, row );
}
std::int32_t module::get_render_param( int param ) const {
return impl->get_render_param( param );
}
void module::set_render_param( int param, std::int32_t value ) {
impl->set_render_param( param, value );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ) {
return impl->read( samplerate, count, mono );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ) {
return impl->read( samplerate, count, left, right );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ) {
return impl->read( samplerate, count, left, right, rear_left, rear_right );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, float * mono ) {
return impl->read( samplerate, count, mono );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, float * left, float * right ) {
return impl->read( samplerate, count, left, right );
}
std::size_t module::read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ) {
return impl->read( samplerate, count, left, right, rear_left, rear_right );
}
std::size_t module::read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo ) {
return impl->read_interleaved_stereo( samplerate, count, interleaved_stereo );
}
std::size_t module::read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad ) {
return impl->read_interleaved_quad( samplerate, count, interleaved_quad );
}
std::size_t module::read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo ) {
return impl->read_interleaved_stereo( samplerate, count, interleaved_stereo );
}
std::size_t module::read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad ) {
return impl->read_interleaved_quad( samplerate, count, interleaved_quad );
}
std::vector<std::string> module::get_metadata_keys() const {
return impl->get_metadata_keys();
}
std::string module::get_metadata( const std::string & key ) const {
return impl->get_metadata( key );
}
double module::get_current_estimated_bpm() const {
return impl->get_current_estimated_bpm();
}
std::int32_t module::get_current_speed() const {
return impl->get_current_speed();
}
std::int32_t module::get_current_tempo() const {
return impl->get_current_tempo();
}
std::int32_t module::get_current_order() const {
return impl->get_current_order();
}
std::int32_t module::get_current_pattern() const {
return impl->get_current_pattern();
}
std::int32_t module::get_current_row() const {
return impl->get_current_row();
}
std::int32_t module::get_current_playing_channels() const {
return impl->get_current_playing_channels();
}
float module::get_current_channel_vu_mono( std::int32_t channel ) const {
return impl->get_current_channel_vu_mono( channel );
}
float module::get_current_channel_vu_left( std::int32_t channel ) const {
return impl->get_current_channel_vu_left( channel );
}
float module::get_current_channel_vu_right( std::int32_t channel ) const {
return impl->get_current_channel_vu_right( channel );
}
float module::get_current_channel_vu_rear_left( std::int32_t channel ) const {
return impl->get_current_channel_vu_rear_left( channel );
}
float module::get_current_channel_vu_rear_right( std::int32_t channel ) const {
return impl->get_current_channel_vu_rear_right( channel );
}
std::int32_t module::get_num_subsongs() const {
return impl->get_num_subsongs();
}
std::int32_t module::get_num_channels() const {
return impl->get_num_channels();
}
std::int32_t module::get_num_orders() const {
return impl->get_num_orders();
}
std::int32_t module::get_num_patterns() const {
return impl->get_num_patterns();
}
std::int32_t module::get_num_instruments() const {
return impl->get_num_instruments();
}
std::int32_t module::get_num_samples() const {
return impl->get_num_samples();
}
std::vector<std::string> module::get_subsong_names() const {
return impl->get_subsong_names();
}
std::vector<std::string> module::get_channel_names() const {
return impl->get_channel_names();
}
std::vector<std::string> module::get_order_names() const {
return impl->get_order_names();
}
std::vector<std::string> module::get_pattern_names() const {
return impl->get_pattern_names();
}
std::vector<std::string> module::get_instrument_names() const {
return impl->get_instrument_names();
}
std::vector<std::string> module::get_sample_names() const {
return impl->get_sample_names();
}
std::int32_t module::get_order_pattern( std::int32_t order ) const {
return impl->get_order_pattern( order );
}
std::int32_t module::get_pattern_num_rows( std::int32_t pattern ) const {
return impl->get_pattern_num_rows( pattern );
}
std::uint8_t module::get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const {
return impl->get_pattern_row_channel_command( pattern, row, channel, command );
}
std::string module::format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const {
return impl->format_pattern_row_channel_command( pattern, row, channel, command );
}
std::string module::highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const {
return impl->highlight_pattern_row_channel_command( pattern, row, channel, command );
}
std::string module::format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const {
return impl->format_pattern_row_channel( pattern, row, channel, width, pad );
}
std::string module::highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const {
return impl->highlight_pattern_row_channel( pattern, row, channel, width, pad );
}
std::vector<std::string> module::get_ctls() const {
return impl->get_ctls();
}
std::string module::ctl_get( const std::string & ctl ) const {
return impl->ctl_get( ctl );
}
bool module::ctl_get_boolean( std::string_view ctl ) const {
return impl->ctl_get_boolean( ctl );
}
std::int64_t module::ctl_get_integer( std::string_view ctl ) const {
return impl->ctl_get_integer( ctl );
}
double module::ctl_get_floatingpoint( std::string_view ctl ) const {
return impl->ctl_get_floatingpoint( ctl );
}
std::string module::ctl_get_text( std::string_view ctl ) const {
return impl->ctl_get_text( ctl );
}
void module::ctl_set( const std::string & ctl, const std::string & value ) {
impl->ctl_set( ctl, value );
}
void module::ctl_set_boolean( std::string_view ctl, bool value ) {
impl->ctl_set_boolean( ctl, value );
}
void module::ctl_set_integer( std::string_view ctl, std::int64_t value ) {
impl->ctl_set_integer( ctl, value );
}
void module::ctl_set_floatingpoint( std::string_view ctl, double value ) {
impl->ctl_set_floatingpoint( ctl, value );
}
void module::ctl_set_text( std::string_view ctl, std::string_view value ) {
impl->ctl_set_text( ctl, value );
}
module_ext::module_ext( std::istream & stream, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( stream, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const std::vector<std::uint8_t> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const std::vector<char> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const std::vector<std::byte> & data, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const std::uint8_t * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const char * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const std::byte * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::module_ext( const void * data, std::size_t size, std::ostream & log, const std::map< std::string, std::string > & ctls ) : ext_impl(0) {
ext_impl = new module_ext_impl( data, size, openmpt::helper::make_unique<std_ostream_log>( log ), ctls );
set_impl( ext_impl );
}
module_ext::~module_ext() {
set_impl( 0 );
delete ext_impl;
ext_impl = 0;
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4702) // unreachable code
#endif // _MSC_VER
module_ext::module_ext( const module_ext & other ) : module(other), ext_impl(nullptr) {
throw std::runtime_error("openmpt::module_ext is non-copyable");
}
// cppcheck-suppress operatorEqVarError
void module_ext::operator = ( const module_ext & ) {
throw std::runtime_error("openmpt::module_ext is non-copyable");
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif // _MSC_VER
void * module_ext::get_interface( const std::string & interface_id ) {
return ext_impl->get_interface( interface_id );
}
} // namespace openmpt
|