Last active
September 12, 2018 01:56
-
-
Save NachtgeistW/30949f4d902d8708be143a687816aea7 to your computer and use it in GitHub Desktop.
A tool for formatting the output Jubeat song information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Data source: https://www53.atwiki.jp/cosmos_memo/pages/16.html | |
Input format: Singularity xi 197 Lv 4 (295) Lv 8 (625) Lv 10 (958) | |
Output format: | |
Singularity xi 197 BSC 4 | |
Singularity xi 197 ADV 8 | |
Singularity xi 197 EXT 10 | |
*/ | |
#include "pch.h" | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <regex> | |
struct Song_Info { | |
std::string song_info = "0"; | |
int bsc_lv = 1; | |
int adv_lv = 1; | |
int ext_lv = 1; | |
}; | |
int main() | |
{ | |
Song_Info info; | |
std::string temp; | |
std::ifstream input("JubeatInput.txt"); | |
while (std::getline(input, temp)) | |
{ | |
while (temp.find("Lv") == temp.npos) | |
{ | |
std::string temp2; | |
std::getline(input, temp2); | |
temp += temp2; | |
} | |
std::string Lv_regex = "(Lv)(\\s)(\\d+)(\\s)(\\(\\d+\\))(\\t)(Lv)(\\s)(\\d+)(\\s)(\\(\\d+\\))(\\t)(Lv)(\\s)(\\d+)(\\s)(\\(\\d+\\))"; | |
std::regex r(Lv_regex); | |
try | |
{ | |
//store Lv info | |
std::smatch result; | |
std::regex_search(temp, result, r); | |
info.bsc_lv = std::stoi(result.str(3)); | |
info.adv_lv = std::stoi(result.str(9)); | |
info.ext_lv = std::stoi(result.str(15)); | |
//store song info | |
info.song_info = temp; | |
info.song_info.erase(info.song_info.find("Lv")); | |
//output | |
std::ofstream output("JubeatOutput.txt", std::ofstream::app); | |
output << info.song_info << "BSC" << '\t' << info.bsc_lv << '\n' | |
<< info.song_info << "ADV" << '\t' << info.adv_lv << '\n' | |
<< info.song_info << "EXT" << '\t' << info.ext_lv << '\n'; | |
output.close(); | |
} | |
catch (...) { | |
std::string fol_temp; | |
std::getline(input, fol_temp); | |
std::cerr << u8"Can't not read in your data. The error text is:" << temp << '\n' | |
<< u8"The following text is:" << fol_temp << '\n'; | |
} | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I fixed a bug. It would throw out an error when it tried to transfer data from multiple-line before.