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