Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX
21 : #define INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX
22 :
23 : #include <stdtypes.h>
24 : #include <general.h>
25 :
26 : #include <rtl/ustring.hxx>
27 :
28 : namespace framework{
29 :
30 : #define JOBURL_EVENT_STR "event="
31 : #define JOBURL_EVENT_LEN 6
32 :
33 : #define JOBURL_ALIAS_STR "alias="
34 : #define JOBURL_ALIAS_LEN 6
35 :
36 : #define JOBURL_SERVICE_STR "service="
37 : #define JOBURL_SERVICE_LEN 8
38 :
39 : #define JOBURL_PART_SEPARATOR ';'
40 : #define JOBURL_PARTARGS_SEPARATOR ','
41 :
42 : /**
43 : @short can be used to parse, validate and work with job URL's
44 : @descr Job URLs are specified by the following syntax:
45 : vnd.sun.star.job:{[event=<name>]|[alias=<name>]|[service=<name>]}
46 : This class can analyze this structure and separate it into his different parts.
47 : After doing that these parts are accessible by the methods of this class.
48 : */
49 0 : class JobURL
50 : {
51 :
52 : // types
53 :
54 : private:
55 :
56 : /**
57 : possible states of a job URL
58 : Note: These values are used in combination. So they must be
59 : values in form 2^n.
60 : */
61 : enum ERequest
62 : {
63 : /// mark a job URL as not valid
64 : E_UNKNOWN = 0,
65 : /// it's an event
66 : E_EVENT = 1,
67 : /// it's an alias
68 : E_ALIAS = 2,
69 : /// it's a service
70 : E_SERVICE = 4
71 : };
72 :
73 : // types
74 :
75 : private:
76 :
77 : /** knows the state of this URL instance */
78 : sal_uInt32 m_eRequest;
79 :
80 : /** holds the event part of a job URL */
81 : OUString m_sEvent;
82 :
83 : /** holds the alias part of a job URL */
84 : OUString m_sAlias;
85 :
86 : /** holds the service part of a job URL */
87 : OUString m_sService;
88 :
89 : /** holds the event arguments */
90 : OUString m_sEventArgs;
91 :
92 : /** holds the alias arguments */
93 : OUString m_sAliasArgs;
94 :
95 : /** holds the service arguments */
96 : OUString m_sServiceArgs;
97 :
98 : // native interface
99 :
100 : public:
101 :
102 : JobURL ( const OUString& sURL );
103 : bool isValid ( ) const;
104 : bool getEvent ( OUString& sEvent ) const;
105 : bool getAlias ( OUString& sAlias ) const;
106 : bool getService ( OUString& sService ) const;
107 :
108 : // private helper
109 :
110 : private:
111 :
112 : static bool implst_split( const OUString& sPart ,
113 : const sal_Char* pPartIdentifier ,
114 : sal_Int32 nPartLength ,
115 : OUString& rPartValue ,
116 : OUString& rPartArguments );
117 :
118 : // debug methods!
119 :
120 : #ifdef ENABLE_COMPONENT_SELF_CHECK
121 :
122 : public:
123 : static void impldbg_checkIt();
124 :
125 : private:
126 : static void impldbg_checkURL( const sal_Char* pURL ,
127 : sal_uInt32 eExpectedPart ,
128 : const sal_Char* pExpectedEvent ,
129 : const sal_Char* pExpectedAlias ,
130 : const sal_Char* pExpectedService ,
131 : const sal_Char* pExpectedEventArgs ,
132 : const sal_Char* pExpectedAliasArgs ,
133 : const sal_Char* pExpectedServiceArgs );
134 : OUString impldbg_toString() const;
135 :
136 : sal_Bool getServiceArgs( OUString& sServiceArgs ) const;
137 : sal_Bool getEventArgs ( OUString& sEventArgs ) const;
138 : sal_Bool getAliasArgs ( OUString& sAliasArgs ) const;
139 :
140 : #endif // ENABLE_COMPONENT_SELF_CHECK
141 : };
142 :
143 : } // namespace framework
144 :
145 : #endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|