| Flutter Impeller |

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::UniqueFD > | working_directory
std::string | source_file_name
SourceType | input_type
std::string | output_file_name

## Detailed Description

Definition at line 19 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,
58 fml::FilePermission::kRead))),
59 source_file_name(command_line.GetOptionValueWithDefault("input", "")),
60 input_type(SourceTypeFromCommandLine(command_line)),
61 output_file_name(command_line.GetOptionValueWithDefault("output", "")) {
62 if (!working_directory || !working_directory->is_valid()) {
63 return;
64 }
65 }

References working_directory.

## 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
70 if (input_type == SourceType::kUnknown) {
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 }

References input_type, impeller::scene::importer::kUnknown, output_file_name, source_file_name, and working_directory.

Referenced by impeller::scene::importer::Main().

## ◆ 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 }

References impeller::scene::importer::kKnownSourceTypes.

Referenced by impeller::scene::importer::Main().

## Member Data Documentation

## ◆ input_type

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

Definition at line 22 of file switches.h.

Referenced by AreValid(), and impeller::scene::importer::Main().

## ◆ output_file_name

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

Definition at line 23 of file switches.h.

Referenced by AreValid(), and impeller::scene::importer::Main().

## ◆ source_file_name

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

Definition at line 21 of file switches.h.

Referenced by AreValid(), and impeller::scene::importer::Main().

## ◆ working_directory

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

Definition at line 20 of file switches.h.

Referenced by AreValid(), impeller::scene::importer::Main(), and Switches().

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

- impeller/scene/importer/switches.h
- impeller/scene/importer/switches.cc

impeller::scene::importer::Switches::input_type
SourceType input_type
Definition: switches.h:22
impeller::scene::importer::Switches::output_file_name
std::string output_file_name
Definition: switches.h:23
impeller::scene::importer::Switches::source_file_name
std::string source_file_name
Definition: switches.h:21
impeller::scene::importer::kKnownSourceTypes
static const std::map< std::string, SourceType > kKnownSourceTypes
Definition: switches.cc:20
impeller::scene::importer::SourceType::kUnknown
@ kUnknown
impeller::compiler::Utf8FromPath
std::string Utf8FromPath(const std::filesystem::path &path)
Converts a native format path to a utf8 string.
Definition: utilities.cc:14
impeller::scene::importer::SourceTypeFromCommandLine
static SourceType SourceTypeFromCommandLine(const fml::CommandLine &command_line)
Definition: switches.cc:43
impeller::scene::importer::Switches::working_directory
std::shared_ptr< fml::UniqueFD > working_directory
Definition: switches.h:20