xref: /aoo41x/main/idlc/source/options.cxx (revision 3b906df9)
12fe1ca3dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32fe1ca3dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42fe1ca3dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52fe1ca3dSAndrew Rist  * distributed with this work for additional information
62fe1ca3dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72fe1ca3dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82fe1ca3dSAndrew Rist  * "License"); you may not use this file except in compliance
92fe1ca3dSAndrew Rist  * with the License.  You may obtain a copy of the License at
102fe1ca3dSAndrew Rist  *
112fe1ca3dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122fe1ca3dSAndrew Rist  *
132fe1ca3dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142fe1ca3dSAndrew Rist  * software distributed under the License is distributed on an
152fe1ca3dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162fe1ca3dSAndrew Rist  * KIND, either express or implied.  See the License for the
172fe1ca3dSAndrew Rist  * specific language governing permissions and limitations
182fe1ca3dSAndrew Rist  * under the License.
192fe1ca3dSAndrew Rist  *
202fe1ca3dSAndrew Rist  *************************************************************/
212fe1ca3dSAndrew Rist 
222fe1ca3dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idlc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "idlc/options.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "osl/diagnose.h"
30cdf0e10cSrcweir #include "rtl/string.hxx"
31cdf0e10cSrcweir #include "rtl/strbuf.hxx"
32cdf0e10cSrcweir 
33*3b906df9SJuergen Schmidt #include "rtl/ustring.hxx"
34*3b906df9SJuergen Schmidt #include "osl/file.hxx"
35*3b906df9SJuergen Schmidt 
36*3b906df9SJuergen Schmidt #ifdef WNT
37*3b906df9SJuergen Schmidt #   include <windows.h>
38*3b906df9SJuergen Schmidt #endif
39*3b906df9SJuergen Schmidt 
40*3b906df9SJuergen Schmidt /*
41*3b906df9SJuergen Schmidt #ifndef WIN32_LEAN_AND_MEAN
42*3b906df9SJuergen Schmidt #   define WIN32_LEAN_AND_MEAN
43*3b906df9SJuergen Schmidt # ifdef _MSC_VER
44*3b906df9SJuergen Schmidt #   pragma warning(push,1)
45*3b906df9SJuergen Schmidt # endif
46*3b906df9SJuergen Schmidt #   include <windows.h>
47*3b906df9SJuergen Schmidt # ifdef _MSC_VER
48*3b906df9SJuergen Schmidt #   pragma warning(pop)
49*3b906df9SJuergen Schmidt # endif
50*3b906df9SJuergen Schmidt #   include <tchar.h>
51*3b906df9SJuergen Schmidt #   undef WIN32_LEAN_AND_MEAN
52*3b906df9SJuergen Schmidt #endif
53*3b906df9SJuergen Schmidt */
54*3b906df9SJuergen Schmidt 
55cdf0e10cSrcweir #include <stdio.h>
56cdf0e10cSrcweir #include <string.h>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using rtl::OString;
59cdf0e10cSrcweir using rtl::OStringBuffer;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #ifdef SAL_UNX
62cdf0e10cSrcweir #define SEPARATOR '/'
63cdf0e10cSrcweir #else
64cdf0e10cSrcweir #define SEPARATOR '\\'
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir 
Options(char const * progname)67cdf0e10cSrcweir Options::Options(char const * progname)
685979ef3cSJürgen Schmidt     : m_program(progname), m_stdin(false), m_verbose(false), m_quiet(false)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
~Options()72cdf0e10cSrcweir Options::~Options()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // static
checkArgument(std::vector<std::string> & rArgs,char const * arg,size_t len)77cdf0e10cSrcweir bool Options::checkArgument (std::vector< std::string > & rArgs, char const * arg, size_t len)
78cdf0e10cSrcweir {
795979ef3cSJürgen Schmidt     bool result = ((arg != 0) && (len > 0));
805979ef3cSJürgen Schmidt     OSL_PRECOND(result, "idlc::Options::checkArgument(): invalid arguments");
815979ef3cSJürgen Schmidt     if (result)
82cdf0e10cSrcweir     {
835979ef3cSJürgen Schmidt         switch(arg[0])
84cdf0e10cSrcweir         {
855979ef3cSJürgen Schmidt         case '@':
865979ef3cSJürgen Schmidt             if ((result = (len > 1)) == true)
87cdf0e10cSrcweir             {
885979ef3cSJürgen Schmidt                 // "@<cmdfile>"
895979ef3cSJürgen Schmidt                 result = Options::checkCommandFile (rArgs, &(arg[1]));
905979ef3cSJürgen Schmidt             }
915979ef3cSJürgen Schmidt             break;
925979ef3cSJürgen Schmidt         case '-':
935979ef3cSJürgen Schmidt             if ((result = (len > 1)) == true)
945979ef3cSJürgen Schmidt             {
955979ef3cSJürgen Schmidt                 // "-<option>"
965979ef3cSJürgen Schmidt                 switch (arg[1])
975979ef3cSJürgen Schmidt                 {
985979ef3cSJürgen Schmidt                 case 'O':
995979ef3cSJürgen Schmidt                 case 'I':
1005979ef3cSJürgen Schmidt                 case 'D':
1015979ef3cSJürgen Schmidt                 {
1025979ef3cSJürgen Schmidt                     // "-<option>[<param>]
1035979ef3cSJürgen Schmidt                     std::string option(&(arg[0]), 2);
1045979ef3cSJürgen Schmidt                     rArgs.push_back(option);
1055979ef3cSJürgen Schmidt                     if (len > 2)
1065979ef3cSJürgen Schmidt                     {
1075979ef3cSJürgen Schmidt                         // "-<option><param>"
1085979ef3cSJürgen Schmidt                         std::string param(&(arg[2]), len - 2);
1095979ef3cSJürgen Schmidt                         rArgs.push_back(param);
1105979ef3cSJürgen Schmidt                     }
1115979ef3cSJürgen Schmidt                     break;
1125979ef3cSJürgen Schmidt                 }
1135979ef3cSJürgen Schmidt                 default:
1145979ef3cSJürgen Schmidt                     // "-<option>" ([long] option, w/o param)
1155979ef3cSJürgen Schmidt                     rArgs.push_back(std::string(arg, len));
1165979ef3cSJürgen Schmidt                     break;
1175979ef3cSJürgen Schmidt                 }
118cdf0e10cSrcweir             }
119cdf0e10cSrcweir             break;
120cdf0e10cSrcweir         default:
1215979ef3cSJürgen Schmidt             // "<param>"
1225979ef3cSJürgen Schmidt             rArgs.push_back(std::string(arg, len));
1235979ef3cSJürgen Schmidt             break;
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir     }
1265979ef3cSJürgen Schmidt     return (result);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // static
checkCommandFile(std::vector<std::string> & rArgs,char const * filename)130cdf0e10cSrcweir bool Options::checkCommandFile (std::vector< std::string > & rArgs, char const * filename)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     FILE * fp = fopen(filename, "r");
133cdf0e10cSrcweir     if (fp == 0)
134cdf0e10cSrcweir     {
135cdf0e10cSrcweir         fprintf(stderr, "ERROR: can't open command file \"%s\"\n", filename);
136cdf0e10cSrcweir         return (false);
137cdf0e10cSrcweir     }
1385979ef3cSJürgen Schmidt 
139cdf0e10cSrcweir     std::string buffer;
140cdf0e10cSrcweir     buffer.reserve(256);
1415979ef3cSJürgen Schmidt 
142cdf0e10cSrcweir     bool quoted = false;
143cdf0e10cSrcweir     int c = EOF;
144cdf0e10cSrcweir     while ((c = fgetc(fp)) != EOF)
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         switch(c)
147cdf0e10cSrcweir         {
148cdf0e10cSrcweir         case '\"':
1495979ef3cSJürgen Schmidt             quoted = !quoted;
1505979ef3cSJürgen Schmidt             break;
151cdf0e10cSrcweir         case ' ':
152cdf0e10cSrcweir         case '\t':
153cdf0e10cSrcweir         case '\r':
154cdf0e10cSrcweir         case '\n':
1555979ef3cSJürgen Schmidt             if (!quoted)
1565979ef3cSJürgen Schmidt             {
1575979ef3cSJürgen Schmidt                 if (!buffer.empty())
1585979ef3cSJürgen Schmidt                 {
1595979ef3cSJürgen Schmidt                     // append current argument.
1605979ef3cSJürgen Schmidt                     if (!Options::checkArgument(rArgs, buffer.c_str(), buffer.size()))
1615979ef3cSJürgen Schmidt                     {
1625979ef3cSJürgen Schmidt                         (void) fclose(fp);
1635979ef3cSJürgen Schmidt                         return (false);
1645979ef3cSJürgen Schmidt                     }
1655979ef3cSJürgen Schmidt                     buffer.clear();
1665979ef3cSJürgen Schmidt                 }
1675979ef3cSJürgen Schmidt                 break;
1685979ef3cSJürgen Schmidt             }
169cdf0e10cSrcweir         default:
1705979ef3cSJürgen Schmidt             // quoted white-space fall through
1715979ef3cSJürgen Schmidt             buffer.push_back(sal::static_int_cast<char>(c));
1725979ef3cSJürgen Schmidt             break;
173cdf0e10cSrcweir         }
174cdf0e10cSrcweir     }
175cdf0e10cSrcweir     if (!buffer.empty())
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         // append unterminated argument.
178cdf0e10cSrcweir         if (!Options::checkArgument(rArgs, buffer.c_str(), buffer.size()))
179cdf0e10cSrcweir         {
180cdf0e10cSrcweir             (void) fclose(fp);
181cdf0e10cSrcweir             return (false);
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir         buffer.clear();
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir     return (fclose(fp) == 0);
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
badOption(char const * reason,std::string const & rArg)188cdf0e10cSrcweir bool Options::badOption(char const * reason, std::string const & rArg) throw(IllegalArgument)
189cdf0e10cSrcweir {
1905979ef3cSJürgen Schmidt     OStringBuffer message;
1915979ef3cSJürgen Schmidt     if (reason != 0)
1925979ef3cSJürgen Schmidt     {
1935979ef3cSJürgen Schmidt         message.append(reason); message.append(" option '"); message.append(rArg.c_str()); message.append("'");
1945979ef3cSJürgen Schmidt         throw IllegalArgument(message.makeStringAndClear());
1955979ef3cSJürgen Schmidt     }
1965979ef3cSJürgen Schmidt     return false;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
setOption(char const * option,std::string const & rArg)199cdf0e10cSrcweir bool Options::setOption(char const * option, std::string const & rArg)
200cdf0e10cSrcweir {
2015979ef3cSJürgen Schmidt     bool result = (0 == strcmp(option, rArg.c_str()));
2025979ef3cSJürgen Schmidt     if (result)
2035979ef3cSJürgen Schmidt         m_options[rArg.c_str()] = OString(rArg.c_str(), rArg.size());
2045979ef3cSJürgen Schmidt     return (result);
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207*3b906df9SJuergen Schmidt #ifdef WNT
208*3b906df9SJuergen Schmidt /* Helper functiopn to convert windows paths including spaces, brackets etc. into
209*3b906df9SJuergen Schmidt    a windows short Url. The ucpp preprocessor has problems with such paths and returns
210*3b906df9SJuergen Schmidt    with error.
211*3b906df9SJuergen Schmidt */
convertIncPathtoShortWindowsPath(const OString & incPath)212*3b906df9SJuergen Schmidt OString convertIncPathtoShortWindowsPath(const OString& incPath) {
213*3b906df9SJuergen Schmidt 	rtl::OUString path = OStringToOUString(incPath, RTL_TEXTENCODING_UTF8);
214*3b906df9SJuergen Schmidt 
215*3b906df9SJuergen Schmidt 	std::vector<sal_Unicode> vec(path.getLength() + 1);
216*3b906df9SJuergen Schmidt     //GetShortPathNameW only works if the file can be found!
217*3b906df9SJuergen Schmidt     const DWORD len = GetShortPathNameW(
218*3b906df9SJuergen Schmidt 		reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
219*3b906df9SJuergen Schmidt 
220*3b906df9SJuergen Schmidt 	rtl::OUString ret = rtl::OUString(&vec[0], len);
221*3b906df9SJuergen Schmidt 
222*3b906df9SJuergen Schmidt 	if (len > 0)
223*3b906df9SJuergen Schmidt 		return OUStringToOString(ret, RTL_TEXTENCODING_UTF8);
224*3b906df9SJuergen Schmidt 
225*3b906df9SJuergen Schmidt 	return incPath;
226*3b906df9SJuergen Schmidt }
227*3b906df9SJuergen Schmidt #endif
228*3b906df9SJuergen Schmidt 
initOptions(std::vector<std::string> & rArgs)229cdf0e10cSrcweir bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument)
230cdf0e10cSrcweir {
2315979ef3cSJürgen Schmidt     std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
2325979ef3cSJürgen Schmidt     for (; first != last; ++first)
233cdf0e10cSrcweir     {
2345979ef3cSJürgen Schmidt         if ((*first)[0] != '-')
235cdf0e10cSrcweir         {
2365979ef3cSJürgen Schmidt             OString filename((*first).c_str(), (*first).size());
2375979ef3cSJürgen Schmidt             OString tmp(filename.toAsciiLowerCase());
2385979ef3cSJürgen Schmidt             if (tmp.lastIndexOf(".idl") != (tmp.getLength() - 4))
2395979ef3cSJürgen Schmidt             {
2405979ef3cSJürgen Schmidt                 throw IllegalArgument("'" + filename + "' is not a valid input file, only '*.idl' files will be accepted");
2415979ef3cSJürgen Schmidt             }
2425979ef3cSJürgen Schmidt             m_inputFiles.push_back(filename);
2435979ef3cSJürgen Schmidt             continue;
244cdf0e10cSrcweir         }
2455979ef3cSJürgen Schmidt 
2465979ef3cSJürgen Schmidt         std::string const option(*first);
2475979ef3cSJürgen Schmidt         switch((*first)[1])
248cdf0e10cSrcweir         {
2495979ef3cSJürgen Schmidt         case 'O':
250cdf0e10cSrcweir         {
2515979ef3cSJürgen Schmidt             if (!((++first != last) && ((*first)[0] != '-')))
2525979ef3cSJürgen Schmidt             {
2535979ef3cSJürgen Schmidt                 return badOption("invalid", option);
2545979ef3cSJürgen Schmidt             }
2555979ef3cSJürgen Schmidt             OString param((*first).c_str(), (*first).size());
2565979ef3cSJürgen Schmidt             m_options["-O"] = param;
2575979ef3cSJürgen Schmidt             break;
258cdf0e10cSrcweir         }
2595979ef3cSJürgen Schmidt         case 'I':
260cdf0e10cSrcweir         {
2615979ef3cSJürgen Schmidt             if (!((++first != last) && ((*first)[0] != '-')))
2625979ef3cSJürgen Schmidt             {
2635979ef3cSJürgen Schmidt                 return badOption("invalid", option);
2645979ef3cSJürgen Schmidt             }
2655979ef3cSJürgen Schmidt             OString param((*first).c_str(), (*first).size());
2665979ef3cSJürgen Schmidt             {
2675979ef3cSJürgen Schmidt                 // quote param token(s).
2685979ef3cSJürgen Schmidt                 OStringBuffer buffer;
2695979ef3cSJürgen Schmidt                 sal_Int32 k = 0;
2705979ef3cSJürgen Schmidt                 do
2715979ef3cSJürgen Schmidt                 {
272*3b906df9SJuergen Schmidt                     OStringBuffer token;
273*3b906df9SJuergen Schmidt                     token.append("-I");
274*3b906df9SJuergen Schmidt #ifdef WNT
275*3b906df9SJuergen Schmidt 					rtl::OString incpath = convertIncPathtoShortWindowsPath(param.getToken(0, ';', k));
276*3b906df9SJuergen Schmidt #else
277*3b906df9SJuergen Schmidt 					rtl::OString incpath = param.getToken(0, ';', k);
278*3b906df9SJuergen Schmidt #endif
279*3b906df9SJuergen Schmidt 					token.append(incpath);
280*3b906df9SJuergen Schmidt                     //token.append(param.getToken(0, ';', k));
2815979ef3cSJürgen Schmidt                     if (buffer.getLength() > 0)
2825979ef3cSJürgen Schmidt                         buffer.append(' ');
2835979ef3cSJürgen Schmidt                     buffer.append(token);
2845979ef3cSJürgen Schmidt                 } while (k != -1);
2855979ef3cSJürgen Schmidt                 param = buffer.makeStringAndClear();
2865979ef3cSJürgen Schmidt             }
2875979ef3cSJürgen Schmidt             if (m_options.count("-I") > 0)
2885979ef3cSJürgen Schmidt             {
2895979ef3cSJürgen Schmidt                 // append param.
2905979ef3cSJürgen Schmidt                 OStringBuffer buffer(m_options["-I"]);
2915979ef3cSJürgen Schmidt                 buffer.append(' '); buffer.append(param);
2925979ef3cSJürgen Schmidt                 param = buffer.makeStringAndClear();
2935979ef3cSJürgen Schmidt             }
2945979ef3cSJürgen Schmidt             m_options["-I"] = param;
2955979ef3cSJürgen Schmidt             break;
296cdf0e10cSrcweir         }
2975979ef3cSJürgen Schmidt         case 'D':
298cdf0e10cSrcweir         {
2995979ef3cSJürgen Schmidt             if (!((++first != last) && ((*first)[0] != '-')))
3005979ef3cSJürgen Schmidt             {
3015979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3025979ef3cSJürgen Schmidt             }
3035979ef3cSJürgen Schmidt             OString param("-D"); param += OString((*first).c_str(), (*first).size());
3045979ef3cSJürgen Schmidt             if (m_options.count("-D") > 0)
3055979ef3cSJürgen Schmidt             {
3065979ef3cSJürgen Schmidt                 OStringBuffer buffer(m_options["-D"]);
3075979ef3cSJürgen Schmidt                 buffer.append(' '); buffer.append(param);
3085979ef3cSJürgen Schmidt                 param = buffer.makeStringAndClear();
3095979ef3cSJürgen Schmidt             }
3105979ef3cSJürgen Schmidt             m_options["-D"] = param;
3115979ef3cSJürgen Schmidt             break;
312cdf0e10cSrcweir         }
3135979ef3cSJürgen Schmidt         case 'C':
314cdf0e10cSrcweir         {
3155979ef3cSJürgen Schmidt             if (!setOption("-C", option))
3165979ef3cSJürgen Schmidt             {
3175979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3185979ef3cSJürgen Schmidt             }
3195979ef3cSJürgen Schmidt             break;
320cdf0e10cSrcweir         }
3215979ef3cSJürgen Schmidt         case 'c':
322cdf0e10cSrcweir         {
3235979ef3cSJürgen Schmidt             if (!setOption("-cid", option))
3245979ef3cSJürgen Schmidt             {
3255979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3265979ef3cSJürgen Schmidt             }
3275979ef3cSJürgen Schmidt             break;
328cdf0e10cSrcweir         }
3295979ef3cSJürgen Schmidt         case 'q':
330cdf0e10cSrcweir         {
3315979ef3cSJürgen Schmidt             if (!setOption("-quiet", option))
3325979ef3cSJürgen Schmidt             {
3335979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3345979ef3cSJürgen Schmidt             }
3355979ef3cSJürgen Schmidt             m_quiet = true;
3365979ef3cSJürgen Schmidt             break;
337cdf0e10cSrcweir         }
3385979ef3cSJürgen Schmidt         case 'v':
339cdf0e10cSrcweir         {
3405979ef3cSJürgen Schmidt             if (!setOption("-verbose", option))
3415979ef3cSJürgen Schmidt             {
3425979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3435979ef3cSJürgen Schmidt             }
3445979ef3cSJürgen Schmidt             m_verbose = true;
3455979ef3cSJürgen Schmidt             break;
346cdf0e10cSrcweir         }
3475979ef3cSJürgen Schmidt         case 'w':
348cdf0e10cSrcweir         {
3495979ef3cSJürgen Schmidt             if (!(setOption("-w", option) || setOption("-we", option)))
3505979ef3cSJürgen Schmidt             {
3515979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3525979ef3cSJürgen Schmidt             }
3535979ef3cSJürgen Schmidt             break;
354cdf0e10cSrcweir         }
3555979ef3cSJürgen Schmidt         case 'h':
3565979ef3cSJürgen Schmidt         case '?':
357cdf0e10cSrcweir         {
3585979ef3cSJürgen Schmidt             if (!(setOption("-h", option) || setOption("-?", option)))
3595979ef3cSJürgen Schmidt             {
3605979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3615979ef3cSJürgen Schmidt             }
3625979ef3cSJürgen Schmidt             {
3635979ef3cSJürgen Schmidt                 (void) fprintf(stdout, "%s", prepareHelp().getStr());
3645979ef3cSJürgen Schmidt                 return (false);
3655979ef3cSJürgen Schmidt             }
3665979ef3cSJürgen Schmidt             // break; // Unreachable
367cdf0e10cSrcweir         }
3685979ef3cSJürgen Schmidt         case 's':
369cdf0e10cSrcweir         {
3705979ef3cSJürgen Schmidt             if (!setOption("-stdin", option))
3715979ef3cSJürgen Schmidt             {
3725979ef3cSJürgen Schmidt                 return badOption("invalid", option);
3735979ef3cSJürgen Schmidt             }
3745979ef3cSJürgen Schmidt             m_stdin = true;
3755979ef3cSJürgen Schmidt             break;
376cdf0e10cSrcweir         }
3775979ef3cSJürgen Schmidt         default:
3785979ef3cSJürgen Schmidt             return badOption("unknown", option);
379cdf0e10cSrcweir         }
380cdf0e10cSrcweir     }
3815979ef3cSJürgen Schmidt     return (true);
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
prepareHelp()384cdf0e10cSrcweir OString	Options::prepareHelp()
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	OString help("\nusing: ");
3875979ef3cSJürgen Schmidt 	help += m_program + " [-options] <file_1> ... <file_n> | @<filename> | -stdin\n";
388cdf0e10cSrcweir 	help += "    <file_n>    = file_n specifies one or more idl files.\n";
389cdf0e10cSrcweir 	help += "                  Only files with the extension '.idl' are valid.\n";
390cdf0e10cSrcweir 	help += "    @<filename> = filename specifies the name of a command file.\n";
391cdf0e10cSrcweir     help += "    -stdin      = read idl file from standard input.\n";
392cdf0e10cSrcweir 	help += "  Options:\n";
393cdf0e10cSrcweir 	help += "    -O<path>    = path specifies the output directory.\n";
394cdf0e10cSrcweir 	help += "                  The generated output is a registry file with\n";
395cdf0e10cSrcweir 	help += "                  the same name as the idl input file (or 'stdin'\n";
396cdf0e10cSrcweir     help += "                  for -stdin).\n";
397cdf0e10cSrcweir 	help += "    -I<path>    = path specifies a directory where include\n";
398cdf0e10cSrcweir 	help += "                  files will be searched by the preprocessor.\n";
399cdf0e10cSrcweir 	help += "                  Multiple directories can be combined with ';'.\n";
400cdf0e10cSrcweir 	help += "    -D<name>    = name defines a macro for the preprocessor.\n";
401cdf0e10cSrcweir 	help += "    -C          = generate complete type information, including\n";
402cdf0e10cSrcweir 	help += "                  documentation.\n";
403cdf0e10cSrcweir 	help += "    -cid        = check if identifiers fulfill the UNO naming\n";
404cdf0e10cSrcweir     help += "                  requirements.\n";
405cdf0e10cSrcweir 	help += "    -w          = display warning messages.\n";
406cdf0e10cSrcweir 	help += "    -we         = treat warnings as errors.\n";
407cdf0e10cSrcweir 	help += "    -h|-?       = print this help message and exit.\n\n";
408cdf0e10cSrcweir 	help += prepareVersion();
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	return help;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
prepareVersion()413cdf0e10cSrcweir OString	Options::prepareVersion()
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	OString version(m_program);
416cdf0e10cSrcweir 	version += " Version 1.1\n\n";
417cdf0e10cSrcweir 	return version;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
getProgramName() const420cdf0e10cSrcweir const OString& Options::getProgramName() const
421cdf0e10cSrcweir {
422cdf0e10cSrcweir 	return m_program;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
isValid(const OString & option)425cdf0e10cSrcweir bool Options::isValid(const OString& option)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir 	return (m_options.count(option) > 0);
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
getOption(const OString & option)430cdf0e10cSrcweir const OString& Options::getOption(const OString& option)
431cdf0e10cSrcweir 	throw( IllegalArgument )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	if (!isValid(option))
434cdf0e10cSrcweir 	{
435cdf0e10cSrcweir 		throw IllegalArgument("Option is not valid or currently not set.");
436cdf0e10cSrcweir 	}
437cdf0e10cSrcweir     return m_options[option];
438cdf0e10cSrcweir }
439cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
440