parses and lists all sims

This commit is contained in:
IXtreme 2026-03-04 00:41:07 -05:00
commit 8f975735b2
6 changed files with 244 additions and 0 deletions

50
Makefile Normal file
View file

@ -0,0 +1,50 @@
CC = gcc
CXX = g++
CPPFLAGS = -g
CFLAGS = -g
LDFLAGS = -g
LDLIBS = -lfltk
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
EXE = $(BIN_DIR)/main
C_SRC := $(wildcard $(SRC_DIR)/*.c) #GET LIST OF ALL C FILES
CPP_SRC := $(wildcard $(SRC_DIR)/*.cpp) #GET LIST OF ALL CPP FILES
#SRC := $(C_SRC) $(CPP_SCR)
C_OBJ := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(C_SRC)) #MAKE LIST OF ALL C OBJECT FILES THAT NEED TO BE BUILT
CPP_OBJ := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(CPP_SRC)) #MAKE LIST OF ALL CPP OBJECT FILES THAT NEED TO BE BUILT
OBJ := $(C_OBJ) $(CPP_OBJ)
all: $(EXE)
$(EXE): $(OBJ) | $(BIN_DIR)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BIN_DIR) $(OBJ_DIR):
mkdir -p $@
clean:
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
.PHONY: all clean

170
src/main.cpp Normal file
View file

@ -0,0 +1,170 @@
#include <FL/Enumerations.H>
#include <fstream>
#include <iostream>
#include "testcpp.hpp"
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Multi_Browser.H>
#include <FL/Fl.H>
#include <memory>
#include <vector>
using namespace std;
struct Person {
std::string year;
std::string name;
Person(std::string& y, std::string& n) : year(y), name(n) {}
std::string toString() const {
return "{(Person): " + year + ", " + name + "}";
}
};
std::ostream& operator<<(std::ostream& os, const Person& e) {
//os << "{(Person): " << e.year << ", " << e.name << "}";
os << e.toString();
return os;
}
struct BasicEntry {
Person A;
Person B;
std::string matchlink;
std::string toString() const {
return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + "}";
}
};
std::ostream& operator<<(std::ostream& os, const BasicEntry& e) {
//os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}";
os << e.toString();
return os;
}
std::vector<BasicEntry> MakeEntires(std::string filename) {
std::vector<BasicEntry> out;
std::ifstream matches(filename);
if (!matches.is_open()) {
std::cout << "Err reading " <<filename << std::endl;
exit(1);
}
std::string line;
std::string line1;
std::string line2;
size_t linenum = 1; // One indexed like devtools
while(std::getline(matches, line)) {
if (linenum < 15) {
} else {
if ( (linenum - 15) % 3 == 0) {
line1 = line;
if (line == "</td></tr></tbody></table>") break;
} else if ( (linenum - 15) % 3 == 1) {
line2 = line;
// std::cout << "Debug: L1: " << line1 << std::endl;
// std::cout << "Debug: L2: " << line2 << std::endl;
auto firstquote = line1.find("\"");
// printf("fq: %ld\n", firstquote);
auto secondquote = line1.find("\"", firstquote+1);
// printf("sq: %ld\n", secondquote);
auto matchlink = line1.substr(firstquote+1, secondquote - (firstquote+1));
auto firstslash = line1.find("/", secondquote+ 1);
auto secondslash = line1.find("/", firstslash+1);
auto thirdslash = line1.find("/", secondslash+1);
auto p1class = line1.substr(firstslash+1, secondslash - firstslash - 1);
auto p1name = line1.substr(secondslash+1, thirdslash - secondslash -1);
firstquote = line2.find("\"");
secondquote = line2.find("\"", firstquote+1);
firstslash = line2.find("/", secondquote+1);
secondslash = line2.find("/", firstslash+1);
thirdslash = line2.find("/", secondslash+1);
auto p2class = line2.substr(firstslash+1, secondslash - (firstslash+1));
auto p2name = line2.substr(secondslash+1, thirdslash - (secondslash+1));
auto p1 = Person(p1class, p1name);
auto p2 = Person(p2class, p2name);
printf("%s\n", p2class.c_str());
BasicEntry finent = {.A = p1, .B = p2, .matchlink = matchlink};
out.push_back(finent);
}
}
linenum++;
}
return out;
}
struct State {
std::vector<BasicEntry> entries;
};
int main (int argc, char ** argv) {
if (argc < 2) {
std::cout << "Not enough args" << std::endl;
exit(1);
}
State s;
s.entries = MakeEntires(argv[1]);
for (auto e : s.entries) {
std::cout << e << std::endl;
}
auto window = std::make_unique<Fl_Window>(300, 300, 300, 300, "MossMan :D");
auto group = std::make_unique<Fl_Group>(0,0,300,300);
auto box = std::make_unique<Fl_Box>(0,0,100,50,"MossMan");
box->labelsize(36);
box->labelfont(FL_TIMES | FL_BOLD);
box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT);
auto browser = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
for (auto e : s.entries) {
auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name));
browser->add(h.c_str());
}
group->resizable(*browser);
group->end();
window->resizable(*group);
window->end();
window->show();
return Fl::run();
}

5
src/testc.c Normal file
View file

@ -0,0 +1,5 @@
#include <stdio.h>
void TestC() {
printf("TestC\n");
}

6
src/testc.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef TESTC_HEADER
#define TESTC_HEADER
void TestC();
#endif

7
src/testcpp.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <iostream>
using namespace std;
void TestCPPFunc() {
cout << "TestCPPFunc" << endl;
}

6
src/testcpp.hpp Normal file
View file

@ -0,0 +1,6 @@
#ifndef TESTCPP_HEADER
#define TESTCPP_HEADER
void TestCPPFunc();
#endif