feat: parse wavefront as string lines
This commit is contained in:
36
src/main.cpp
36
src/main.cpp
@@ -13,7 +13,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "wavefront.hpp"
|
||||
#include "output.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -109,31 +108,22 @@ int main(int argc, char *argv[]) {
|
||||
// printUsage();
|
||||
// return 1;
|
||||
// }
|
||||
WaveFront::Settings wavefront_settings(
|
||||
selected_objects.empty() ? std::nullopt : std::make_optional(selected_objects),
|
||||
selected_groups.empty() ? std::nullopt : std::make_optional(selected_groups)
|
||||
);
|
||||
WaveFront wavefront_parser(wavefront_settings);
|
||||
// WaveFrontFilter wavefront_filter(
|
||||
// selected_objects.empty() ? std::nullopt : std::make_optional(selected_objects),
|
||||
// selected_groups.empty() ? std::nullopt : std::make_optional(selected_groups)
|
||||
// );
|
||||
|
||||
try {
|
||||
if (input_file_path == "-") {
|
||||
wavefront_parser.parse(std::cin);
|
||||
} else {
|
||||
std::ifstream input_file(input_file_path);
|
||||
if (!input_file) {
|
||||
std::cerr << "Failed to open input file: " << input_file_path << std::endl;
|
||||
return 1;
|
||||
}
|
||||
wavefront_parser.parse(input_file);
|
||||
}
|
||||
} catch (const WaveFront::parse_error& e) {
|
||||
std::cerr << input_file_path << ":" << e.line_number() << ": " << e.what() << std::endl;
|
||||
return 1;
|
||||
std::ifstream input_file;
|
||||
std::istream &input_stream = (input_file_path == "")
|
||||
? std::cin
|
||||
: (input_file.open(input_file_path), input_file);
|
||||
|
||||
if (!input_stream) {
|
||||
std::cerr << "Failed to open file: " << input_file_path << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
Output output;
|
||||
|
||||
output.compile(wavefront_parser);
|
||||
auto wavefront_lines = parse_wavefront(input_stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user