Skip to content

Commit

Permalink
Changed compile() to use std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hrszpuk committed Dec 30, 2024
1 parent 4991286 commit 0beedf4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include <map>
#include <string>
#include <fstream>
#include <optional>

void help();
const std::string& compile(const std::string& contents, const std::map<std::string, bool>& options);
std::optional<std::string> compile(const std::string& contents, const std::map<std::string, bool>& options);

std::map <std::string, bool> options = {
{"-l", false},
Expand Down Expand Up @@ -65,7 +66,11 @@ int main(int argc, char** argv) {
std::string contents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();

std::string output = compile(contents, options);
auto output = compile(contents, options);
if (!output) {
std::cerr << "Compilation failed.\n";
return 1;
}

if (outputFilenameSpecified) {
std::cout << "Output has been written to: " << outputFilename << "\n";
Expand Down Expand Up @@ -96,6 +101,6 @@ void help() {
);
}

const std::string& compile(const std::string& contents, const std::map<std::string, bool>& options) {
std::optional<std::string> compile(const std::string& contents, const std::map<std::string, bool>& options) {
return "";
}

0 comments on commit 0beedf4

Please sign in to comment.