64{
65
66 for (int i = 1; i < argc; i++) {
67 const char* cp = argv[i];
68
69 if (!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
71 exit(EXIT_SUCCESS);
72 } else if (!strcmp(cp, "-v") || !strcmp(cp, "--verbose")) {
73 verbose = true;
74 } else if (!strcmp(cp, "-d") || !strcmp(cp, "--c++-dir-name")) {
75 if (++i == argc || argv[i][0] == '-')
77 else
78 cpp_dir_name = argv[i];
79 } else if (!strcmp(cp, "-n") || !strcmp(cp, "--c++-namespace")) {
80 if (++i == argc || argv[i][0] == '-')
82 else
83 cpp_ns_name = argv[i];
84 } else if (!strcmp(cp, "-i") || !strcmp(cp, "--c++-headers-dir")) {
85 if (++i == argc || argv[i][0] == '-')
87 else
88 cpp_hdr_dir = argv[i];
89 } else if (!strcmp(cp, "-f") || !strcmp(cp, "--info-file-name")) {
90 if (++i == argc || argv[i][0] == '-')
92 else
93 info_file_name = argv[i];
94 } else {
95 std::list<std::string>* slist = ((!strcmp(cp, "-c") || !strcmp(cp, "--classes")) ? &class_names
96 : (!strcmp(cp, "-s") || !strcmp(cp, "--schema-files")) ? &file_names
97 : (!strcmp(cp, "-I") || !strcmp(cp, "--include-dirs")) ? &include_dirs
98 : (!strcmp(cp, "-D") || !strcmp(cp, "--user-defined-classes")) ? &user_classes
99 : nullptr);
100
101 if (slist) {
102 int j = 0;
103 for (; j < argc - i - 1; ++j) {
104 if (argv[i + 1 + j][0] != '-')
105 slist->push_back(argv[i + 1 + j]);
106 else
107 break;
108 }
109 i += j;
110 } else {
111 std::cerr << "ERROR: Unexpected parameter: \"" << cp << "\"\n\n";
113 exit(EXIT_FAILURE);
114 }
115 }
116 }
117
118 if (file_names.size() == 0) {
119 std::cerr << "At least one schema file is required\n";
120 exit(EXIT_FAILURE);
121 }
122
123 if (verbose) {
124 std::cout << "VERBOSE:\n"
125 " Command line parameters:\n"
126 " c++ directory name: \""
127 << cpp_dir_name
128 << "\"\n"
129 " c++ namespace name: \""
130 << cpp_ns_name
131 << "\"\n"
132 " c++ headers directory: \""
133 << cpp_hdr_dir
134 << "\"\n"
135 " classes:";
136
137 if (!class_names.empty()) {
138 std::cout << std::endl;
139
140 for (const auto& i : class_names)
141 std::cout << " - " << i << std::endl;
142 } else {
143 std::cout << " no\n";
144 }
145
146 std::cout << " file names:";
147
148 if (!file_names.empty()) {
149 std::cout << std::endl;
150
151 for (const auto& i : file_names)
152 std::cout << " * " << i << std::endl;
153 } else {
154 std::cout << " no\n";
155 }
156
157 std::cout << " include directories for search:";
158
159 if (!include_dirs.empty()) {
160 std::cout << std::endl;
161
162 for (const auto& i : include_dirs)
163 std::cout << " * " << i << std::endl;
164 } else {
165 std::cout << " no\n";
166 }
167
168 std::cout << " user-defined classes:";
169
170 if (!user_classes.empty()) {
171 std::cout << std::endl;
172
173 for (const auto& i : user_classes)
174 std::cout << " * " << i << std::endl;
175 } else {
176 std::cout << " no\n";
177 }
178 }
179}
static void usage(const char *s)
static void no_param(const char *s)