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 INCLUDED_CODEMAKER_UNOTYPE_HXX
25 #define INCLUDED_CODEMAKER_UNOTYPE_HXX
26 
27 #include "sal/types.h"
28 
29 #include <vector>
30 
31 namespace rtl { class OString; }
32 
33 namespace codemaker {
34 
35 namespace UnoType {
36     /**
37        An enumeration of all the sorts of UNO types.
38 
39        All complex UNO types are subsumed under SORT_COMPLEX.
40      */
41     enum Sort {
42         SORT_VOID,
43         SORT_BOOLEAN,
44         SORT_BYTE,
45         SORT_SHORT,
46         SORT_UNSIGNED_SHORT,
47         SORT_LONG,
48         SORT_UNSIGNED_LONG,
49         SORT_HYPER,
50         SORT_UNSIGNED_HYPER,
51         SORT_FLOAT,
52         SORT_DOUBLE,
53         SORT_CHAR,
54         SORT_STRING,
55         SORT_TYPE,
56         SORT_ANY,
57         SORT_COMPLEX
58     };
59 
60     /**
61        Maps from a binary UNO type name or UNO type registry name to its type
62        sort.
63 
64        @param type a binary UNO type name or UNO type registry name
65 
66        @return the sort of the UNO type denoted by the given type; the detection
67        of the correct sort is purely syntactical (especially, if the given input
68        is a UNO type registry name that denotes something other than a UNO type,
69        SORT_COMPLEX is returned)
70      */
71     Sort getSort(rtl::OString const & type);
72 
73     /**
74        Determines whether a UNO type name or UNO type registry name denotes a
75        UNO sequence type.
76 
77        @param type a binary UNO type name or UNO type registry name
78 
79        @return true iff the given type denotes a UNO sequence type; the
80        detection is purely syntactical
81      */
82     bool isSequenceType(rtl::OString const & type);
83 
84     /**
85        Decomposes a UNO type name or UNO type registry name.
86 
87        @param type a binary UNO type name or UNO type registry name
88 
89        @param rank if non-null, returns the rank of the denoted UNO type (which
90        is zero for any given type that does not denote a UNO sequence type)
91 
92        @param arguments if non-null, the type arguments are stripped from an
93        instantiated polymorphic struct type and returned via this parameter (in
94        the correct order); if null, type arguments are not stripped from
95        instantiated polymorphic struct types
96 
97        @return the base part of the given type
98      */
99     rtl::OString decompose(
100         rtl::OString const & type, sal_Int32 * rank = 0,
101         std::vector< rtl::OString > * arguments = 0);
102 }
103 
104 }
105 
106 #endif
107