How do I scan through a string in C++?

Trying to implement a Sliding Universal Score system here, I want to create a function that scans a string from a text file and converts each line into a variable value. There are 2 things I need to accomplish this:

  1. read each line individually and assign them to variables depending on what the line starts with
  2. read a certain amount of digits from number data individually and assign them as proper values

How can I scan through the string from the file (similar to Scanner from Java) to read all this data?

It all depends on the formatting of the source text.
Can you give an example of what the text that needs to be processed looks like?

This file is taken from something using a very similar system, in the end, the extension would be changed to txt
expert.sus (16.7 KB)

 * Sliding Universal Score files can be pretty confusing at first glance, so I'm writing notes here about them
 * All data points have the first character of the line as a #, any lines that don't start with a # are considered comments
 * #REQUEST is probably a needed data point for setting up the chart, however it is rarely used.  Just keep the line that says '#REQUEST "ticks_per_beat 480'
 * FORMAT: #mmmcxy: (number data)
 *	number data: two digit values all together used to define the notes
 *		length of data: the division for the measure at which the notes are placed at
 *		digit one: note subtype
 *		digit two: note width
 *	mmm: measure the notes are in
 *	c: type for all notes
 *	x: x position for all notes
 *	y: exlusive to longs and guides, it is always 0
 * all single digit values can go above 9 by using alphabetical letters
 * FORMAT: mmm02: x
 *	x: the time signature value, it confusingly defined so I don't exactly know how this works yet
 * VALUE FORMAT: #BPMxx: value
 *	xx: the id of the BPM change
 *	value: the exact vqalue of the BPM (not defined confusingly)
 * TIMING FORMAT: #mmm08: xx
 *	xx: the id the BPM change time is tied to
 * this changes the speed of the notes for the chart
 * FORMAT: #TIL00: "measure'tick:value" // this is a list inside a string
 *	value: the multiplicative value the speed changes by
 * '#HISPEED 00' and '#MESUREHS 00' are need data points used in other things to change the speed of individual notes, however, since HISPEEDs change the speed of all notes here, this can be ignored

To get started, use FString::ParseIntoArrayLines to get an array of strings.
Then in the loop use FString::Split where InS = FString(β€œ:”)
On the left side there will be a key, and on the right side there will be a value.

Also, you probably want to get rid of the # character in the parameter name, use FString::RightChop.

As far as I understand, at the beginning there is information about the package, and then the data that directly interests us.

If FString::Split = false or FString::StartsWith = false where InPrefix = FString (β€œ#”) then this is a description of the package or comment, this line must be ignored, otherwise we parse it into key and value as described above.

1 Like

What’s going on here?

Please ignore last reply, I found a more error safe way of splitting up the string

Thanks for this, now I just need to do complicated coding to convert every data point into notes