| 142 | } |
| 143 | |
| 144 | bool PUBLIC parseInstrument(const std::string &definition, std::string &preNumber, std::string &id, std::string &name, std::string &postName) |
| 145 | { |
| 146 | preNumber.erase(); |
| 147 | name.erase(); |
| 148 | postName.erase(); |
| 149 | id.erase(); |
| 150 | int beginId = definition.find("instr"); |
| 151 | if(beginId == -1) |
| 152 | { |
| 153 | return false; |
| 154 | } |
| 155 | beginId += 5; |
| 156 | int newline = definition.find("\n", beginId); |
| 157 | int semicolon = definition.find(";", beginId); |
| 158 | if(semicolon > newline) |
| 159 | { |
| 160 | semicolon = -1; |
| 161 | } |
| 162 | size_t endId = 0; |
| 163 | size_t beginName = 0; |
| 164 | size_t endName = 0; |
| 165 | if(newline == -1) |
| 166 | { |
| 167 | return false; |
| 168 | } |
| 169 | if(semicolon == -1) |
| 170 | { |
| 171 | endId = newline; |
| 172 | id = definition.substr(beginId, endId - beginId); |
| 173 | trim(id); |
| 174 | if(id.length() == 0) |
| 175 | { |
| 176 | return false; |
| 177 | } |
| 178 | if(!strchr("0123456789", id[0])) |
| 179 | { |
| 180 | name = id; |
| 181 | } |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | endId = semicolon; |
| 186 | beginName = semicolon + 1; |
| 187 | endName = newline; |
| 188 | id = definition.substr(beginId, endId - beginId); |
| 189 | trim(id); |
| 190 | if(id.length() == 0) |
| 191 | { |
| 192 | return false; |
| 193 | } |
| 194 | name = definition.substr(beginName, endName - beginName); |
| 195 | trim(name); |
| 196 | } |
| 197 | postName = definition.substr(endName); |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | CsoundFile::CsoundFile() |
no test coverage detected