MCPcopy Create free account
hub / github.com/csound/csound / parseInstrument

Function parseInstrument

interfaces/CsoundFile.cpp:144–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144bool 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
201CsoundFile::CsoundFile()

Callers 6

getInstrumentCountMethod · 0.85
getInstrumentMethod · 0.85
getInstrumentBodyMethod · 0.85
getInstrumentNamesMethod · 0.85
getInstrumentNumberMethod · 0.85

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected