xref: /trunk/main/codemaker/inc/codemaker/options.hxx (revision 2037b4de)
1*2037b4deSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2037b4deSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2037b4deSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2037b4deSAndrew Rist  * distributed with this work for additional information
6*2037b4deSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2037b4deSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2037b4deSAndrew Rist  * "License"); you may not use this file except in compliance
9*2037b4deSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2037b4deSAndrew Rist  *
11*2037b4deSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2037b4deSAndrew Rist  *
13*2037b4deSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2037b4deSAndrew Rist  * software distributed under the License is distributed on an
15*2037b4deSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2037b4deSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2037b4deSAndrew Rist  * specific language governing permissions and limitations
18*2037b4deSAndrew Rist  * under the License.
19*2037b4deSAndrew Rist  *
20*2037b4deSAndrew Rist  *************************************************************/
21*2037b4deSAndrew Rist 
22*2037b4deSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_CODEMAKER_OPTIONS_HXX
25cdf0e10cSrcweir #define INCLUDED_CODEMAKER_OPTIONS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <hash_map>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <codemaker/global.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
32cdf0e10cSrcweir typedef	::std::__hash_map__
33cdf0e10cSrcweir <
34cdf0e10cSrcweir 	::rtl::OString,
35cdf0e10cSrcweir 	::rtl::OString,
36cdf0e10cSrcweir 	HashString,
37cdf0e10cSrcweir 	EqualString,
38cdf0e10cSrcweir 	NewAlloc
39cdf0e10cSrcweir > OptionMap;
40cdf0e10cSrcweir #else
41cdf0e10cSrcweir typedef	::std::hash_map
42cdf0e10cSrcweir <
43cdf0e10cSrcweir 	::rtl::OString,
44cdf0e10cSrcweir 	::rtl::OString,
45cdf0e10cSrcweir 	HashString,
46cdf0e10cSrcweir 	EqualString
47cdf0e10cSrcweir > OptionMap;
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir 
50cdf0e10cSrcweir class IllegalArgument
51cdf0e10cSrcweir {
52cdf0e10cSrcweir public:
IllegalArgument(const::rtl::OString & msg)53cdf0e10cSrcweir 	IllegalArgument(const ::rtl::OString& msg)
54cdf0e10cSrcweir 		: m_message(msg) {}
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	::rtl::OString	m_message;
57cdf0e10cSrcweir };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir class Options
60cdf0e10cSrcweir {
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir 	Options();
63cdf0e10cSrcweir 	virtual ~Options();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
66cdf0e10cSrcweir 		throw( IllegalArgument ) = 0;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	virtual ::rtl::OString	prepareHelp() = 0;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	const ::rtl::OString&	getProgramName() const;
71cdf0e10cSrcweir 	sal_Bool				isValid(const ::rtl::OString& option);
72cdf0e10cSrcweir 	const ::rtl::OString	getOption(const ::rtl::OString& option)
73cdf0e10cSrcweir 		throw( IllegalArgument );
74cdf0e10cSrcweir 	const OptionMap& 		getOptions();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	const ::rtl::OString 	getInputFile(sal_uInt16 index)
77cdf0e10cSrcweir 		throw( IllegalArgument );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	const StringVector& getInputFiles();
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	::rtl::OString getExtraInputFile(sal_uInt16 index) const throw( IllegalArgument );
getNumberOfExtraInputFiles() const82cdf0e10cSrcweir 	inline sal_uInt16 getNumberOfExtraInputFiles() const
83cdf0e10cSrcweir         { return (sal_uInt16)m_extra_input_files.size(); }
getExtraInputFiles() const84cdf0e10cSrcweir 	inline const StringVector& getExtraInputFiles() const
85cdf0e10cSrcweir         { return m_extra_input_files; }
86cdf0e10cSrcweir protected:
87cdf0e10cSrcweir 	::rtl::OString 	m_program;
88cdf0e10cSrcweir 	StringVector	m_inputFiles;
89cdf0e10cSrcweir     StringVector    m_extra_input_files;
90cdf0e10cSrcweir 	OptionMap		m_options;
91cdf0e10cSrcweir };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #endif // INCLUDED_CODEMAKER_OPTIONS_HXX
94cdf0e10cSrcweir 
95