874 |
_instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager); |
_instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager); |
875 |
_current_group = new Group(); |
_current_group = new Group(); |
876 |
pCurDef = _current_group; |
pCurDef = _current_group; |
877 |
|
|
878 |
|
parseFile(file,pSampleManager); |
879 |
|
} |
880 |
|
|
881 |
|
void File::parseFile(std::string file, SampleManager* pSampleManager){ |
882 |
enum token_type_t { HEADER, OPCODE }; |
enum token_type_t { HEADER, OPCODE }; |
883 |
token_type_t token_type; |
token_type_t token_type; |
884 |
std::string token_string; |
std::string token_string; |
897 |
if (slash_index != std::string::npos) |
if (slash_index != std::string::npos) |
898 |
line.resize(slash_index); |
line.resize(slash_index); |
899 |
|
|
900 |
|
// #include |
901 |
|
if (line.find("#include ") == 0) { |
902 |
|
size_t fname_start = line.find("\""); |
903 |
|
if (fname_start == std::string::npos) continue; |
904 |
|
|
905 |
|
size_t fname_end = line.find("\"", fname_start + 1); |
906 |
|
if (fname_end == std::string::npos || fname_start == fname_end) |
907 |
|
continue; |
908 |
|
std::string fname = line.substr(fname_start + 1, fname_end - fname_start - 1); |
909 |
|
|
910 |
|
if (!currentDir.empty() && !LinuxSampler::Path(fname).isAbsolute()) |
911 |
|
fname = currentDir + LinuxSampler::File::DirSeparator + fname; |
912 |
|
|
913 |
|
std::string cd = currentDir; // backup current dir |
914 |
|
parseFile(fname, pSampleManager); |
915 |
|
currentDir = cd; // restore currentDir (since altered by parsefile()) |
916 |
|
continue; |
917 |
|
} |
918 |
|
|
919 |
// DEFINITION |
// DEFINITION |
920 |
std::stringstream linestream(line); |
std::stringstream linestream(line); |
921 |
int spaces = 0; |
int spaces = 0; |