mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-23 07:59:03 +00:00
Refactor freqman_db parsing (#1244)
* WIP freqman changes/memory perf/stash * Split ui tone_key function out for testing. * Add more tests and fix bugs. * Use default max_entries in recond * Set limit back to 90 for now
This commit is contained in:
@@ -36,7 +36,8 @@
|
||||
*/
|
||||
|
||||
/* Iterates lines in buffer split on '\n'.
|
||||
* NB: very basic iterator impl, don't try anything fancy with it. */
|
||||
* NB: very basic iterator impl, don't try anything fancy with it.
|
||||
* For example, you _must_ deref the iterator after advancing it. */
|
||||
template <typename BufferType>
|
||||
class BufferLineReader {
|
||||
public:
|
||||
@@ -133,4 +134,18 @@ using FileLineReader = BufferLineReader<File>;
|
||||
* are used or they will dangle. */
|
||||
std::vector<std::string_view> split_string(std::string_view str, char c);
|
||||
|
||||
/* Returns the number of lines in a file. */
|
||||
template <typename BufferType>
|
||||
uint32_t count_lines(BufferLineReader<BufferType>& reader) {
|
||||
uint32_t count = 0;
|
||||
auto it = reader.begin();
|
||||
|
||||
do {
|
||||
*it; // Necessary to force the file read.
|
||||
++count;
|
||||
} while (++it != reader.end());
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user