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