Skip to content

Commit

Permalink
add OBCViewer to DEV7 repository
Browse files Browse the repository at this point in the history
  • Loading branch information
BJNFNE authored Sep 17, 2023
1 parent 80da1dd commit 55e41e0
Show file tree
Hide file tree
Showing 21 changed files with 3,126 additions and 0 deletions.
6 changes: 6 additions & 0 deletions OBCViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.26)
project(OBCViewer)

set(CMAKE_CXX_STANDARD 17)

add_executable(OBCViewer OBCViewer.cpp)
53 changes: 53 additions & 0 deletions OBCViewer/OBCViewer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <fstream>

int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " <script.obc> <output.txt>\n" << std::endl;
printf("Supported games:\n");
printf(" * Adibou 3\n");
printf(" * Adi 5\n");
printf(" * Adibou presente series\n");
printf(" * Adiboud'chou series\n");
printf(" * Le Pays des pierres magiques\n");
printf("\n");
printf("<script.obc>\n\t .obc script to view\n\n");
printf("<output.txt>\n\tprints OBC Script in viewable for into the text file\n\n");
return 1;
}

std::string inputOBC = argv[1];
std::string outputOBC = argv[2];

// Use the OBC Script for Input
std::ifstream OBCInput(inputOBC);

if (!OBCInput) {
std::cerr << "Error: Unable to find OBC Script." << std::endl;
return 1;
}

// Open the output file for the OBC Script
std::ofstream OBCOutput(outputOBC);

if (!OBCOutput) {
std::cerr << "Error: Unable to create text output of OBC Script." << std::endl;
return 1;
}

// Read from input and write to output
char c;
while (OBCInput.get(c)) {
if (std::isprint(static_cast<unsigned char>(c))) {
OBCOutput.put(c);
}
}

// Close input & output for OBC Script
OBCInput.close();
OBCOutput.close();

std::cout << "OBC Script (" << argv[1] << ") is viewable and saved output to " << outputOBC << "" <<std::endl;

return 0;
}
Loading

0 comments on commit 55e41e0

Please sign in to comment.