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 _FILTER_CONFIG_QUERYTOKENIZER_HXX_
25 #define _FILTER_CONFIG_QUERYTOKENIZER_HXX_
26 
27 //_______________________________________________
28 // includes
29 
30 #include <hash_map>
31 #include <rtl/ustring.hxx>
32 
33 //_______________________________________________
34 // namespace
35 
36 namespace filter{
37     namespace config{
38 
39 //_______________________________________________
40 // definitions
41 
42 /** @short      It can be used to split any query string (which can be used at the
43                 related interface <type scope="com::sun::star::container">XContainerQuery</type>)
44                 into its different tokens using a fix schema.
45 
46     @descr      All queries implemented of the services
47                 <ul>
48                     <li><type scope="com::sun::star::document">TypeDetection</type></li>
49                     <li><type scope="com::sun::star::document">FilterFactory</type></li>
50                     <li><type scope="com::sun::star::document">ExtendedTypeDetectionFactory</type></li>
51                     <li><type scope="com::sun::star::frame">FrameLoaderFactory</type></li>
52                     <li><type scope="com::sun::star::frame">ContentHandlerFactory</type></li>
53                 </ul>
54                 uses this schema.
55 
56     @attention  This class is not threadsafe implemented. Because its not neccessary.
57                 But you have to make shure, that ist not used as such :-)
58  */
59 class QueryTokenizer : public ::std::hash_map< ::rtl::OUString                    ,
60                                                ::rtl::OUString                    ,
61                                                ::rtl::OUStringHash                ,
62                                                ::std::equal_to< ::rtl::OUString > >
63 {
64     //-------------------------------------------
65     // member
66 
67     private:
68 
69         /** @short  Because the given query can contain errors,
70                     it should be checked outside.
71 
72             TODO    May its a good idea to describe the real problem
73                     more detailed ...
74          */
75         sal_Bool m_bValid;
76 
77     //-------------------------------------------
78     // interface
79 
80     public:
81 
82         /** @short  create a new tokenizer instance with a
83                     a new query.
84 
85             @descr  The given query is immidiatly analyzed
86                     and seperated into its token, which can
87                     be access by some specialized method later.
88 
89             @param  sQuery
90                     the query string.
91          */
92         QueryTokenizer(const ::rtl::OUString& sQuery);
93 
94         //---------------------------------------
95 
96         /** @short  destruct an instance of this class.
97          */
98         virtual ~QueryTokenizer();
99 
100         //---------------------------------------
101 
102         /** @short  can be used to check if analyzing of given query
103                     was successfully or not.
104          */
105         virtual sal_Bool valid() const;
106 };
107 
108     } // namespace config
109 } // namespace filter
110 
111 #endif // _FILTER_CONFIG_QUERYTOKENIZER_HXX_
112