1 /* 2 * globals.h 3 * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath 4 * DIN Is Noise is released under GNU Public License 2.0 5 * For more information, please visit https://dinisnoise.org/ 6 */ 7 8 9 #ifndef __globals 10 #define __globals 11 12 #include "tokenizer.h" 13 14 #include <cstring> 15 #include <string> 16 17 struct load_globals { 18 std::string ignore; 19 int load_intervals (const std::string& fname); 20 void load_note_colors (const std::string& fname); 21 load_globals (); 22 }; 23 24 void calc_volume_vars (int height); 25 void calc_tonic_limits (); 26 27 template <class T> struct pusher { 28 virtual T& operator<< (const std::string& s)=0; 29 virtual T& operator<< (char c)=0; 30 }; 31 32 #include <iostream> 33 into_lines(const std::string & str,pusher<T> & push)34template<class T> void into_lines (const std::string& str, pusher<T>& push) { 35 36 static tokenizer tz; 37 static const std::string newline = "\n"; 38 static const char endln = '\n'; 39 40 if (str.length()) { 41 tz.set (str, newline); 42 std::string ln; 43 while (1) { 44 std::string ln; tz >> ln; 45 if (ln == "") break; else { push << ln << endln; } 46 } 47 } 48 } 49 50 #endif 51 52 53 54