Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
impeller::scene::importer::Switches Struct Reference

#include <switches.h>

Public Member Functions

 Switches ()
 
 ~Switches ()
 
 Switches (const fml::CommandLine &command_line)
 
bool AreValid (std::ostream &explain) const
 

Static Public Member Functions

static void PrintHelp (std::ostream &stream)
 

Public Attributes

std::shared_ptr< fml::UniqueFDworking_directory
 
std::string source_file_name
 
SourceType input_type
 
std::string output_file_name
 

Detailed Description

Definition at line 20 of file switches.h.

Constructor & Destructor Documentation

◆ Switches() [1/2]

impeller::scene::importer::Switches::Switches ( )
default

◆ ~Switches()

impeller::scene::importer::Switches::~Switches ( )
default

◆ Switches() [2/2]

impeller::scene::importer::Switches::Switches ( const fml::CommandLine command_line)
explicit

Definition at line 54 of file switches.cc.

55 : working_directory(std::make_shared<fml::UniqueFD>(fml::OpenDirectory(
56 compiler::Utf8FromPath(std::filesystem::current_path()).c_str(),
57 false, // create if necessary,
59 source_file_name(command_line.GetOptionValueWithDefault("input", "")),
61 output_file_name(command_line.GetOptionValueWithDefault("output", "")) {
62 if (!working_directory || !working_directory->is_valid()) {
63 return;
64 }
65}
std::string GetOptionValueWithDefault(std::string_view name, std::string_view default_value) const
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition file_posix.cc:97
std::string Utf8FromPath(const std::filesystem::path &path)
Converts a native format path to a utf8 string.
Definition utilities.cc:30
static SourceType SourceTypeFromCommandLine(const fml::CommandLine &command_line)
Definition switches.cc:43
std::shared_ptr< fml::UniqueFD > working_directory
Definition switches.h:21

Member Function Documentation

◆ AreValid()

bool impeller::scene::importer::Switches::AreValid ( std::ostream &  explain) const

Definition at line 67 of file switches.cc.

67 {
68 bool valid = true;
69
71 explain << "Unknown input type." << std::endl;
72 valid = false;
73 }
74
75 if (!working_directory || !working_directory->is_valid()) {
76 explain << "Could not figure out working directory." << std::endl;
77 valid = false;
78 }
79
80 if (source_file_name.empty()) {
81 explain << "Input file name was empty." << std::endl;
82 valid = false;
83 }
84
85 if (output_file_name.empty()) {
86 explain << "Target output file name was empty." << std::endl;
87 valid = false;
88 }
89
90 return valid;
91}

◆ PrintHelp()

void impeller::scene::importer::Switches::PrintHelp ( std::ostream &  stream)
static

Definition at line 24 of file switches.cc.

24 {
25 stream << std::endl;
26 stream << "SceneC is an offline 3D geometry file parser." << std::endl;
27 stream << "---------------------------------------------------------------"
28 << std::endl;
29 stream << "Valid Argument are:" << std::endl;
30 stream << "--input=<source_file>" << std::endl;
31 stream << "[optional] --input-kind={";
32 for (const auto& source_type : kKnownSourceTypes) {
33 stream << source_type.first << ", ";
34 }
35 stream << "} (default: gltf)" << std::endl;
36 stream << "--output=<output_file>" << std::endl;
37}
static const std::map< std::string, SourceType > kKnownSourceTypes
Definition switches.cc:20

Member Data Documentation

◆ input_type

SourceType impeller::scene::importer::Switches::input_type

Definition at line 23 of file switches.h.

◆ output_file_name

std::string impeller::scene::importer::Switches::output_file_name

Definition at line 24 of file switches.h.

◆ source_file_name

std::string impeller::scene::importer::Switches::source_file_name

Definition at line 22 of file switches.h.

◆ working_directory

std::shared_ptr<fml::UniqueFD> impeller::scene::importer::Switches::working_directory

Definition at line 21 of file switches.h.


The documentation for this struct was generated from the following files: