xref: /aoo42x/main/framework/inc/jobs/joburl.hxx (revision 07a3d7f1)
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 __FRAMEWORK_JOBS_JOBURL_HXX_
25 #define __FRAMEWORK_JOBS_JOBURL_HXX_
26 
27 //_______________________________________
28 // my own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/debug.hxx>
32 #include <stdtypes.h>
33 #include <general.h>
34 
35 //_______________________________________
36 // interface includes
37 
38 //_______________________________________
39 // other includes
40 #include <rtl/ustring.hxx>
41 
42 //_______________________________________
43 // namespace
44 
45 namespace framework{
46 
47 //_______________________________________
48 // const
49 
50 #define JOBURL_PROTOCOL_STR        "vnd.sun.star.job:"
51 #define JOBURL_PROTOCOL_LEN        17
52 
53 #define JOBURL_EVENT_STR           "event="
54 #define JOBURL_EVENT_LEN           6
55 
56 #define JOBURL_ALIAS_STR           "alias="
57 #define JOBURL_ALIAS_LEN           6
58 
59 #define JOBURL_SERVICE_STR         "service="
60 #define JOBURL_SERVICE_LEN         8
61 
62 #define JOBURL_PART_SEPERATOR      ';'
63 #define JOBURL_PARTARGS_SEPERATOR  ','
64 
65 //_______________________________________
66 /**
67     @short  can be used to parse, validate and work with job URL's
68     @descr  Job URLs are specified by the following syntax:
69                 vnd.sun.star.job:{[event=<name>]|[alias=<name>]|[service=<name>]}
70             This class can analyze this structure and separate it into his different parts.
71             After doing that these parts are accessible by the methods of this class.
72  */
73 class JobURL : private ThreadHelpBase
74 {
75     //___________________________________
76     // types
77 
78     private:
79 
80         /**
81             possible states of a job URL
82             Note: These values are used in combination. So they must be
83             values in form 2^n.
84          */
85         enum ERequest
86         {
87             /// mark a job URL as not valid
88             E_UNKNOWN = 0,
89             /// it's an event
90             E_EVENT   = 1,
91             /// it's an alias
92             E_ALIAS   = 2,
93             /// it's a service
94             E_SERVICE = 4
95         };
96 
97     //___________________________________
98     // types
99 
100     private:
101 
102         /** knows the state of this URL instance */
103         sal_uInt32 m_eRequest;
104 
105         /** holds the event part of a job URL */
106         ::rtl::OUString m_sEvent;
107 
108         /** holds the alias part of a job URL */
109         ::rtl::OUString m_sAlias;
110 
111         /** holds the service part of a job URL */
112         ::rtl::OUString m_sService;
113 
114         /** holds the event arguments */
115         ::rtl::OUString m_sEventArgs;
116 
117         /** holds the alias arguments */
118         ::rtl::OUString m_sAliasArgs;
119 
120         /** holds the service arguments */
121         ::rtl::OUString m_sServiceArgs;
122 
123     //___________________________________
124     // native interface
125 
126     public:
127 
128                  JobURL        ( const ::rtl::OUString& sURL         );
129         sal_Bool isValid       (                                     ) const;
130         sal_Bool getEvent      (       ::rtl::OUString& sEvent       ) const;
131         sal_Bool getAlias      (       ::rtl::OUString& sAlias       ) const;
132         sal_Bool getService    (       ::rtl::OUString& sService     ) const;
133 
134     //___________________________________
135     // private helper
136 
137     private:
138 
139         static sal_Bool implst_split( const ::rtl::OUString& sPart           ,
140                                       const sal_Char*        pPartIdentifier ,
141                                             sal_Int32        nPartLength     ,
142                                             ::rtl::OUString& rPartValue      ,
143                                             ::rtl::OUString& rPartArguments  );
144 
145     //___________________________________
146     // debug methods!
147 
148     #ifdef ENABLE_COMPONENT_SELF_CHECK
149 
150     public:
151         static void impldbg_checkIt();
152 
153     private:
154         static void impldbg_checkURL( const sal_Char*  pURL                 ,
155                                             sal_uInt32 eExpectedPart        ,
156                                       const sal_Char*  pExpectedEvent       ,
157                                       const sal_Char*  pExpectedAlias       ,
158                                       const sal_Char*  pExpectedService     ,
159                                       const sal_Char*  pExpectedEventArgs   ,
160                                       const sal_Char*  pExpectedAliasArgs   ,
161                                       const sal_Char*  pExpectedServiceArgs );
162         ::rtl::OUString impldbg_toString() const;
163 
164         sal_Bool getServiceArgs(       ::rtl::OUString& sServiceArgs ) const;
165         sal_Bool getEventArgs  (       ::rtl::OUString& sEventArgs   ) const;
166         sal_Bool getAliasArgs  (       ::rtl::OUString& sAliasArgs   ) const;
167 
168     #endif // ENABLE_COMPONENT_SELF_CHECK
169 };
170 
171 } // namespace framework
172 
173 #endif // __FRAMEWORK_JOBS_JOBURL_HXX_
174