I am trying to parse a text file with 1200 songs. I want to increase the barcount every time I come across a '|' or a ']' character. I want to have a new line every time the barCount is equal to 4. However, if I come across '\n' I want to reset the bar count to 0.
Unfortunately, what I have so far is only counting '|' and inserting a new line. Can anyone help me fix my code?
This is some of what I have tried to do:
while((start = chartDataString.find(" |", start)) != string::npos){
barCount++;
start+=2;
charCount++;
if(chartDataString[charCount]==']'){barCount++;}
//each line should be 80 characters long
//if(barCount == 3){// || chartDataString.find("]")){
if(chartDataString.find("\n") !=string::npos){
barCount = 0;
}
if(barCount == 4 || chartDataString[charCount] == ']') {
//cout<<"Number of bars: "<<barCount<<endl;
chartDataString.insert(start, "\n");
barCount = 0;
charCount= 0;
}
}