From 8f975735b2c22e4d12473d85a88d765a790e2a73 Mon Sep 17 00:00:00 2001 From: IXtreme Date: Wed, 4 Mar 2026 00:41:07 -0500 Subject: [PATCH] parses and lists all sims --- Makefile | 50 ++++++++++++++ src/main.cpp | 170 ++++++++++++++++++++++++++++++++++++++++++++++++ src/testc.c | 5 ++ src/testc.h | 6 ++ src/testcpp.cpp | 7 ++ src/testcpp.hpp | 6 ++ 6 files changed, 244 insertions(+) create mode 100644 Makefile create mode 100644 src/main.cpp create mode 100644 src/testc.c create mode 100644 src/testc.h create mode 100644 src/testcpp.cpp create mode 100644 src/testcpp.hpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2781483 --- /dev/null +++ b/Makefile @@ -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 + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..d5c0c3c --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,170 @@ +#include +#include +#include + + +#include "testcpp.hpp" + + +#include +#include +#include +#include +#include +#include + +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 MakeEntires(std::string filename) { + + std::vector out; + + std::ifstream matches(filename); + + if (!matches.is_open()) { + std::cout << "Err reading " <") 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 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(300, 300, 300, 300, "MossMan :D"); + + auto group = std::make_unique(0,0,300,300); + auto box = std::make_unique(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(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(); +} diff --git a/src/testc.c b/src/testc.c new file mode 100644 index 0000000..8c780ff --- /dev/null +++ b/src/testc.c @@ -0,0 +1,5 @@ +#include + +void TestC() { + printf("TestC\n"); +} diff --git a/src/testc.h b/src/testc.h new file mode 100644 index 0000000..04350f8 --- /dev/null +++ b/src/testc.h @@ -0,0 +1,6 @@ +#ifndef TESTC_HEADER +#define TESTC_HEADER + +void TestC(); + +#endif diff --git a/src/testcpp.cpp b/src/testcpp.cpp new file mode 100644 index 0000000..8f7adc2 --- /dev/null +++ b/src/testcpp.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std; +void TestCPPFunc() { + cout << "TestCPPFunc" << endl; + +} diff --git a/src/testcpp.hpp b/src/testcpp.hpp new file mode 100644 index 0000000..7d1dcb3 --- /dev/null +++ b/src/testcpp.hpp @@ -0,0 +1,6 @@ +#ifndef TESTCPP_HEADER +#define TESTCPP_HEADER + +void TestCPPFunc(); + +#endif