void PrintUsage();
void PrintVersion();
+ void PrintSample();
private:
bool isProxy_;
std::cerr << "tidlc " << FULLVER << std::endl;
}
+void Options::PrintSample() {
+ std::cerr << "tidlc -p -l C++ -i test.tidl -o CppTestProxy " << std::endl;
+}
+
std::unique_ptr<Options> Options::Parse(int argc, char** argv) {
int cmd[CMD_MAX] = { 0, };
int opt[OPT_MAX] = { 0, };
return std::unique_ptr<Options>(nullptr);
}
- if (cmd[CMD_HELP] || (!cmd[CMD_PROXY] && !cmd[CMD_STUB]) ||
- !opt[OPT_LANGUAGE] || !opt[OPT_INPUT] ||
- !opt[OPT_OUTPUT]) {
+ if (cmd[CMD_HELP]) {
options->PrintUsage();
return std::unique_ptr<Options>(nullptr);
+ } else if (!cmd[CMD_PROXY] && !cmd[CMD_STUB]) {
+ std::cerr << "Stub or proxy must be specified." << std::endl;
+ options->PrintSample();
+ return std::unique_ptr<Options>(nullptr);
+ } else if (!opt[OPT_LANGUAGE]) {
+ std::cerr << "Select a language (C, C++, C#).." << std::endl;
+ options->PrintSample();
+ return std::unique_ptr<Options>(nullptr);
+ } else if (!opt[OPT_INPUT]) {
+ std::cerr << "No input file." << std::endl;
+ options->PrintSample();
+ return std::unique_ptr<Options>(nullptr);
+ } else if (opt[OPT_INPUT]) {
+ std::ifstream in_file(options->input_.c_str());
+ if (!in_file.good()) {
+ std::cerr << "Not exist input file." << std::endl;
+ return std::unique_ptr<Options>(nullptr);
+ }
+ } else if (!opt[OPT_OUTPUT]) {
+ std::cerr << "No out file." << std::endl;
+ options->PrintSample();
+ return std::unique_ptr<Options>(nullptr);
}
options->isProxy_ = cmd[CMD_PROXY] ? true : false;