xref: /AOO41X/main/idlc/inc/idlc/options.hxx (revision f04bd1c41dbb33d4d3f057e7474795ed0a0da601)
1*f04bd1c4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f04bd1c4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f04bd1c4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f04bd1c4SAndrew Rist  * distributed with this work for additional information
6*f04bd1c4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f04bd1c4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f04bd1c4SAndrew Rist  * "License"); you may not use this file except in compliance
9*f04bd1c4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f04bd1c4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f04bd1c4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f04bd1c4SAndrew Rist  * software distributed under the License is distributed on an
15*f04bd1c4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f04bd1c4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f04bd1c4SAndrew Rist  * specific language governing permissions and limitations
18*f04bd1c4SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f04bd1c4SAndrew Rist  *************************************************************/
21*f04bd1c4SAndrew Rist 
22*f04bd1c4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _IDLC_OPTIONS_HXX_
25cdf0e10cSrcweir #define _IDLC_OPTIONS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _IDLC_IDLCTYPEs_HXX_
28cdf0e10cSrcweir #include <idlc/idlctypes.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir typedef	::std::hash_map< ::rtl::OString,
32cdf0e10cSrcweir 						 ::rtl::OString,
33cdf0e10cSrcweir 						 HashString,
34cdf0e10cSrcweir 						 EqualString > OptionMap;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class IllegalArgument
37cdf0e10cSrcweir {
38cdf0e10cSrcweir public:
IllegalArgument(const::rtl::OString & msg)39cdf0e10cSrcweir 	IllegalArgument(const ::rtl::OString& msg)
40cdf0e10cSrcweir 		: m_message(msg) {}
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	::rtl::OString	m_message;
43cdf0e10cSrcweir };
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class Options
47cdf0e10cSrcweir {
48cdf0e10cSrcweir public:
49cdf0e10cSrcweir 	explicit Options(char const * progname);
50cdf0e10cSrcweir 	~Options();
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     static bool checkArgument(std::vector< std::string > & rArgs, char const * arg, size_t len);
53cdf0e10cSrcweir     static bool checkCommandFile(std::vector< std::string > & rArgs, char const * filename);
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     bool initOptions(std::vector< std::string > & rArgs)
56cdf0e10cSrcweir         throw(IllegalArgument);
57cdf0e10cSrcweir     bool badOption(char const * reason, std::string const & rArg)
58cdf0e10cSrcweir         throw(IllegalArgument);
59cdf0e10cSrcweir     bool setOption(char const * option, std::string const & rArg);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #if 0  /* @@@ */
62cdf0e10cSrcweir 	sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
63cdf0e10cSrcweir 		throw( IllegalArgument );
64cdf0e10cSrcweir #endif /* @@@ */
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	::rtl::OString prepareHelp();
67cdf0e10cSrcweir 	::rtl::OString prepareVersion();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	const ::rtl::OString&	getProgramName() const;
70cdf0e10cSrcweir 	bool				isValid(const ::rtl::OString& option);
71cdf0e10cSrcweir 	const ::rtl::OString&	getOption(const ::rtl::OString& option)
72cdf0e10cSrcweir 		throw( IllegalArgument );
73cdf0e10cSrcweir 
getInputFiles() const74cdf0e10cSrcweir 	const StringVector& getInputFiles() const { return m_inputFiles; }
readStdin() const75cdf0e10cSrcweir     bool readStdin() const { return m_stdin; }
verbose() const76cdf0e10cSrcweir     bool verbose() const { return m_verbose; }
quiet() const77cdf0e10cSrcweir     bool quiet() const { return m_quiet; }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir protected:
80cdf0e10cSrcweir 	::rtl::OString 	m_program;
81cdf0e10cSrcweir 	StringVector	m_inputFiles;
82cdf0e10cSrcweir     bool            m_stdin;
83cdf0e10cSrcweir     bool            m_verbose;
84cdf0e10cSrcweir     bool            m_quiet;
85cdf0e10cSrcweir 	OptionMap		m_options;
86cdf0e10cSrcweir };
87cdf0e10cSrcweir 
88cdf0e10cSrcweir #endif // _IDLC_OPTIONS_HXX_
89cdf0e10cSrcweir 
90