mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
COMMON: Parsing FILE token in CueSheets
This commit is contained in:
parent
5284c8d7a0
commit
9f3b4b6128
@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/formats/cue.h"
|
||||
|
||||
namespace Common {
|
||||
@ -106,7 +107,50 @@ CueSheet::CueSheet(const char *sheet) {
|
||||
}
|
||||
}
|
||||
|
||||
struct LookupTable {
|
||||
const char *key;
|
||||
int value;
|
||||
};
|
||||
|
||||
static int lookupInTable(LookupTable *table, const char *key) {
|
||||
while (table->key) {
|
||||
if (!strcmp(key, table->key))
|
||||
return table->value;
|
||||
|
||||
table++;
|
||||
}
|
||||
|
||||
error("CueSheet::lookupInTable(): Unknown token %s", key);
|
||||
}
|
||||
|
||||
LookupTable fileTypes[] = {
|
||||
{ "BINARY", CueSheet::kCueFileTypeBinary },
|
||||
{ "AIFF", CueSheet::kCueFileTypeAIFF },
|
||||
{ "WAVE", CueSheet::kCueFileTypeWave },
|
||||
{ "MP3", CueSheet::kCueFileTypeMP3 },
|
||||
{ "MOTOROLA", CueSheet::kCueFileTypeMotorola },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
void CueSheet::parseHeaderContext(const char *line) {
|
||||
const char *s = line;
|
||||
|
||||
String command = nexttok(s, &s);
|
||||
|
||||
if (command == "FILE") {
|
||||
_files.push_back(CueFile());
|
||||
|
||||
_currentFile++;
|
||||
|
||||
_files[_currentFile].name = nexttok(s, &s);
|
||||
|
||||
String type = nexttok(s, &s);
|
||||
|
||||
_files[_currentFile].type = kCueFileTypeBinary;
|
||||
_files[_currentFile].type = (CueFileType)lookupInTable(fileTypes, type.c_str());
|
||||
|
||||
_context = kCueContextFiles;
|
||||
}
|
||||
}
|
||||
|
||||
void CueSheet::parseFilesContext(const char *line) {
|
||||
|
@ -22,9 +22,7 @@
|
||||
#ifndef COMMON_FORMATS_CUE_H
|
||||
#define COMMON_FORMATS_CUE_H
|
||||
|
||||
#include "common/hash-str.h"
|
||||
#include "common/str.h"
|
||||
#include "common/types.h"
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
@ -37,6 +35,20 @@ class CueSheet {
|
||||
public:
|
||||
CueSheet(const char *sheet);
|
||||
|
||||
public:
|
||||
enum CueFileType {
|
||||
kCueFileTypeBinary,
|
||||
kCueFileTypeAIFF,
|
||||
kCueFileTypeWave,
|
||||
kCueFileTypeMP3,
|
||||
kCueFileTypeMotorola,
|
||||
};
|
||||
|
||||
struct CueFile {
|
||||
String name;
|
||||
CueFileType type = kCueFileTypeBinary;
|
||||
};
|
||||
|
||||
private:
|
||||
void parseHeaderContext(const char *line);
|
||||
void parseFilesContext(const char *line);
|
||||
@ -44,6 +56,9 @@ private:
|
||||
|
||||
private:
|
||||
int _context;
|
||||
int _currentFile = -1;
|
||||
|
||||
Common::Array<CueFile> _files;
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
||||
|
Loading…
x
Reference in New Issue
Block a user