2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2016 by Christian Schoenebeck * |
* Copyright (C) 2003-2019 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
41 |
#include <map> |
#include <map> |
42 |
#include <set> |
#include <set> |
43 |
#include <iostream> |
#include <iostream> |
44 |
|
#include <stdarg.h> |
45 |
|
|
46 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
47 |
# include <config.h> |
# include <config.h> |
54 |
# include <unistd.h> |
# include <unistd.h> |
55 |
#endif // POSIX |
#endif // POSIX |
56 |
|
|
57 |
#ifdef _MSC_VER |
#if defined _MSC_VER && _MSC_VER < 1600 |
58 |
// Visual C++ 2008 doesn't have stdint.h |
// Visual C++ 2008 doesn't have stdint.h |
59 |
typedef __int8 int8_t; |
typedef __int8 int8_t; |
60 |
typedef __int16 int16_t; |
typedef __int16 int16_t; |
69 |
#endif |
#endif |
70 |
|
|
71 |
#ifdef WIN32 |
#ifdef WIN32 |
72 |
|
# if (_WIN32 && !_WIN64) || (__GNUC__ && !(__x86_64__ || __ppc64__)) /* if 32 bit windows compilation */ |
73 |
|
# if _WIN32_WINNT < 0x0501 |
74 |
|
# undef _WIN32_WINNT |
75 |
|
# define _WIN32_WINNT 0x0501 /* Win XP (no service pack): required for 32 bit compilation for GetFileSizeEx() to be declared by windows.h */ |
76 |
|
# endif |
77 |
|
# endif |
78 |
# include <windows.h> |
# include <windows.h> |
79 |
typedef unsigned int uint; |
typedef unsigned int uint; |
80 |
#endif // WIN32 |
#endif // WIN32 |
151 |
typedef uint64_t file_offset_t; |
typedef uint64_t file_offset_t; |
152 |
|
|
153 |
/** Whether file stream is open in read or in read/write mode. */ |
/** Whether file stream is open in read or in read/write mode. */ |
154 |
typedef enum { |
enum stream_mode_t { |
155 |
stream_mode_read = 0, |
stream_mode_read = 0, |
156 |
stream_mode_read_write = 1, |
stream_mode_read_write = 1, |
157 |
stream_mode_closed = 2 |
stream_mode_closed = 2 |
158 |
} stream_mode_t; |
}; |
159 |
|
|
160 |
/** Current state of the file stream. */ |
/** Current state of the file stream. */ |
161 |
typedef enum { |
enum stream_state_t { |
162 |
stream_ready = 0, |
stream_ready = 0, |
163 |
stream_end_reached = 1, |
stream_end_reached = 1, |
164 |
stream_closed = 2 |
stream_closed = 2 |
165 |
} stream_state_t; |
}; |
166 |
|
|
167 |
/** File stream position dependent to these relations. */ |
/** File stream position dependent to these relations. */ |
168 |
typedef enum { |
enum stream_whence_t { |
169 |
stream_start = 0, |
stream_start = 0, |
170 |
stream_curpos = 1, |
stream_curpos = 1, |
171 |
stream_backward = 2, |
stream_backward = 2, |
172 |
stream_end = 3 |
stream_end = 3 |
173 |
} stream_whence_t; |
}; |
174 |
|
|
175 |
/** Alignment of data bytes in memory (system dependant). */ |
/** Alignment of data bytes in memory (system dependant). */ |
176 |
typedef enum { |
enum endian_t { |
177 |
endian_little = 0, |
endian_little = 0, |
178 |
endian_big = 1, |
endian_big = 1, |
179 |
endian_native = 2 |
endian_native = 2 |
180 |
} endian_t; |
}; |
181 |
|
|
182 |
/** General RIFF chunk structure of a RIFF file. */ |
/** General RIFF chunk structure of a RIFF file. */ |
183 |
enum layout_t { |
enum layout_t { |
305 |
Chunk* GetNextSubChunk(); |
Chunk* GetNextSubChunk(); |
306 |
List* GetFirstSubList(); |
List* GetFirstSubList(); |
307 |
List* GetNextSubList(); |
List* GetNextSubList(); |
308 |
unsigned int CountSubChunks(); |
size_t CountSubChunks(); |
309 |
unsigned int CountSubChunks(uint32_t ChunkID); |
size_t CountSubChunks(uint32_t ChunkID); |
310 |
unsigned int CountSubLists(); |
size_t CountSubLists(); |
311 |
unsigned int CountSubLists(uint32_t ListType); |
size_t CountSubLists(uint32_t ListType); |
312 |
Chunk* AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize); |
Chunk* AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize); |
313 |
List* AddSubList(uint32_t uiListType); |
List* AddSubList(uint32_t uiListType); |
314 |
void DeleteSubChunk(Chunk* pSubChunk); |
void DeleteSubChunk(Chunk* pSubChunk); |
408 |
public: |
public: |
409 |
String Message; |
String Message; |
410 |
|
|
411 |
Exception(String Message) { Exception::Message = Message; } |
Exception(String format, ...); |
412 |
|
Exception(String format, va_list arg); |
413 |
void PrintMessage(); |
void PrintMessage(); |
414 |
virtual ~Exception() {} |
virtual ~Exception() {} |
415 |
|
|
416 |
|
protected: |
417 |
|
Exception(); |
418 |
|
static String assemble(String format, va_list arg); |
419 |
}; |
}; |
420 |
|
|
421 |
String libraryName(); |
String libraryName(); |