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