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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 
27 #include "querytokenizer.hxx"
28 
29 //_______________________________________________
30 // includes
31 
32 //_______________________________________________
33 // namespace
34 
35 namespace filter{
36     namespace config{
37 
38 //_______________________________________________
39 // definitions
40 
41 /*-----------------------------------------------
42     01.08.2003 10:42
43 -----------------------------------------------*/
QueryTokenizer(const::rtl::OUString & sQuery)44 QueryTokenizer::QueryTokenizer(const ::rtl::OUString& sQuery)
45     : m_bValid(sal_True)
46 {
47     sal_Int32 token = 0;
48     while(token != -1)
49     {
50         ::rtl::OUString sToken = sQuery.getToken(0, ':', token);
51         if (sToken.getLength())
52         {
53             sal_Int32 equal = sToken.indexOf('=');
54 
55             if (equal == 0)
56                 m_bValid = sal_False;
57             OSL_ENSURE(m_bValid, "QueryTokenizer::QueryTokenizer()\nFound non boolean query parameter ... but its key is empty. Will be ignored!\n");
58 
59             ::rtl::OUString sKey;
60             ::rtl::OUString sVal;
61 
62             sKey = sToken;
63             if (equal > 0)
64             {
65                 sKey = sToken.copy(0      , equal                       );
66                 sVal = sToken.copy(equal+1, sToken.getLength()-(equal+1));
67             }
68 
69             if (find(sKey) != end())
70                 m_bValid = sal_False;
71             OSL_ENSURE(m_bValid, "QueryTokenizer::QueryTokenizer()\nQuery contains same param more then once. Last one wins :-)\n");
72 
73             (*this)[sKey] = sVal;
74         }
75     }
76 }
77 
78 /*-----------------------------------------------
79     01.08.2003 10:28
80 -----------------------------------------------*/
~QueryTokenizer()81 QueryTokenizer::~QueryTokenizer()
82 {
83     /*TODO*/
84 }
85 
86 /*-----------------------------------------------
87     01.08.2003 10:53
88 -----------------------------------------------*/
valid() const89 sal_Bool QueryTokenizer::valid() const
90 {
91     return m_bValid;
92 }
93 
94     } // namespace config
95 } // namespace filter
96