1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_UNOIDL_UNOIDL_HXX
11 #define INCLUDED_UNOIDL_UNOIDL_HXX
13 #include <sal/config.h>
18 #include <osl/mutex.hxx>
19 #include <rtl/ref.hxx>
20 #include <rtl/ustring.hxx>
21 #include <sal/types.h>
22 #include <salhelper/simplereferenceobject.hxx>
23 #include <unoidl/detail/dllapi.hxx>
27 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final
{
29 SAL_DLLPRIVATE
NoSuchFileException(OUString
const & uri
): uri_(uri
) {}
31 SAL_DLLPRIVATE
NoSuchFileException(NoSuchFileException
const & other
):
34 SAL_DLLPRIVATE
~NoSuchFileException() throw ();
36 const OUString
& getUri() const { return uri_
; }
39 NoSuchFileException
& operator =(NoSuchFileException
const &) = delete;
44 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final
{
46 SAL_DLLPRIVATE
FileFormatException(
47 OUString
const & uri
, OUString
const & detail
):
48 uri_(uri
), detail_(detail
)
51 SAL_DLLPRIVATE
FileFormatException(FileFormatException
const & other
):
52 uri_(other
.uri_
), detail_(other
.detail_
)
55 SAL_DLLPRIVATE
~FileFormatException() throw ();
57 const OUString
& getUri() const { return uri_
; }
59 const OUString
& getDetail() const { return detail_
; }
62 FileFormatException
& operator =(FileFormatException
const &) = delete;
68 struct AnnotatedReference
{
70 OUString
const & theName
,
71 std::vector
< OUString
> const & theAnnotations
):
72 name(theName
), annotations(theAnnotations
)
77 std::vector
< OUString
> annotations
;
80 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Entity
: public salhelper::SimpleReferenceObject
{
83 SORT_MODULE
, SORT_ENUM_TYPE
, SORT_PLAIN_STRUCT_TYPE
,
84 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, SORT_EXCEPTION_TYPE
,
85 SORT_INTERFACE_TYPE
, SORT_TYPEDEF
, SORT_CONSTANT_GROUP
,
86 SORT_SINGLE_INTERFACE_BASED_SERVICE
, SORT_ACCUMULATION_BASED_SERVICE
,
87 SORT_INTERFACE_BASED_SINGLETON
, SORT_SERVICE_BASED_SINGLETON
90 Sort
getSort() const { return sort_
; }
93 explicit SAL_DLLPRIVATE
Entity(Sort sort
): sort_(sort
) {}
95 virtual SAL_DLLPRIVATE
~Entity() throw () override
;
101 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL MapCursor
: public salhelper::SimpleReferenceObject
{
103 // throws FileFormatException:
104 virtual rtl::Reference
< Entity
> getNext(OUString
* name
) = 0;
107 SAL_DLLPRIVATE
MapCursor() {}
109 virtual SAL_DLLPRIVATE
~MapCursor() throw() override
;
112 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ModuleEntity
: public Entity
{
114 // throws FileFormatException:
115 virtual std::vector
< OUString
> getMemberNames() const = 0;
117 // throws FileFormatException:
118 virtual rtl::Reference
< MapCursor
> createCursor() const = 0;
121 SAL_DLLPRIVATE
ModuleEntity(): Entity(SORT_MODULE
) {}
123 virtual SAL_DLLPRIVATE
~ModuleEntity() throw () override
;
126 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PublishableEntity
: public Entity
{
128 bool isPublished() const { return published_
; }
130 std::vector
< OUString
> const & getAnnotations() const
131 { return annotations_
; }
134 SAL_DLLPRIVATE
PublishableEntity(
135 Sort sort
, bool published
,
136 std::vector
< OUString
> const & annotations
):
137 Entity(sort
), published_(published
), annotations_(annotations
)
140 virtual SAL_DLLPRIVATE
~PublishableEntity() throw () override
;
145 std::vector
< OUString
> annotations_
;
148 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final
: public PublishableEntity
{
152 OUString
const & theName
, sal_Int32 theValue
,
153 std::vector
< OUString
> const & theAnnotations
):
154 name(theName
), value(theValue
), annotations(theAnnotations
)
161 std::vector
< OUString
> annotations
;
164 SAL_DLLPRIVATE
EnumTypeEntity(
165 bool published
, std::vector
< Member
> const & members
,
166 std::vector
< OUString
> const & annotations
):
167 PublishableEntity(SORT_ENUM_TYPE
, published
, annotations
),
169 { assert(!members
.empty()); }
171 std::vector
< Member
> const & getMembers() const { return members_
; }
174 virtual SAL_DLLPRIVATE
~EnumTypeEntity() throw () override
;
176 std::vector
< Member
> members_
;
179 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final
: public PublishableEntity
{
182 Member(OUString
const & theName
, OUString
const & theType
,
183 std::vector
< OUString
> const & theAnnotations
):
184 name(theName
), type(theType
), annotations(theAnnotations
)
191 std::vector
< OUString
> annotations
;
194 SAL_DLLPRIVATE
PlainStructTypeEntity(
195 bool published
, OUString
const & directBase
,
196 std::vector
< Member
> const & directMembers
,
197 std::vector
< OUString
> const & annotations
):
198 PublishableEntity(SORT_PLAIN_STRUCT_TYPE
, published
, annotations
),
199 directBase_(directBase
), directMembers_(directMembers
)
202 const OUString
& getDirectBase() const { return directBase_
; }
204 std::vector
< Member
> const & getDirectMembers() const
205 { return directMembers_
; }
208 virtual SAL_DLLPRIVATE
~PlainStructTypeEntity() throw () override
;
210 OUString directBase_
;
211 std::vector
< Member
> directMembers_
;
214 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity final
:
215 public PublishableEntity
220 OUString
const & theName
, OUString
const & theType
,
221 bool theParameterized
,
222 std::vector
< OUString
> const & theAnnotations
):
223 name(theName
), type(theType
), parameterized(theParameterized
),
224 annotations(theAnnotations
)
233 std::vector
< OUString
> annotations
;
236 SAL_DLLPRIVATE
PolymorphicStructTypeTemplateEntity(
237 bool published
, std::vector
< OUString
> const & typeParameters
,
238 std::vector
< Member
> const & members
,
239 std::vector
< OUString
> const & annotations
):
241 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, published
, annotations
),
242 typeParameters_(typeParameters
), members_(members
)
245 std::vector
< OUString
> const & getTypeParameters() const
246 { return typeParameters_
; }
248 std::vector
< Member
> const & getMembers() const { return members_
; }
251 virtual SAL_DLLPRIVATE
~PolymorphicStructTypeTemplateEntity() throw () override
;
253 std::vector
< OUString
> typeParameters_
;
254 std::vector
< Member
> members_
;
257 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity final
: public PublishableEntity
{
261 OUString
const & theName
, OUString
const & theType
,
262 std::vector
< OUString
> const & theAnnotations
):
263 name(theName
), type(theType
), annotations(theAnnotations
)
270 std::vector
< OUString
> annotations
;
273 SAL_DLLPRIVATE
ExceptionTypeEntity(
274 bool published
, OUString
const & directBase
,
275 std::vector
< Member
> const & directMembers
,
276 std::vector
< OUString
> const & annotations
):
277 PublishableEntity(SORT_EXCEPTION_TYPE
, published
, annotations
),
278 directBase_(directBase
), directMembers_(directMembers
)
281 const OUString
& getDirectBase() const { return directBase_
; }
283 std::vector
< Member
> const & getDirectMembers() const
284 { return directMembers_
; }
287 virtual SAL_DLLPRIVATE
~ExceptionTypeEntity() throw () override
;
289 OUString directBase_
;
290 std::vector
< Member
> directMembers_
;
293 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity final
: public PublishableEntity
{
297 OUString
const & theName
, OUString
const & theType
,
298 bool theBound
, bool theReadOnly
,
299 std::vector
< OUString
> const & theGetExceptions
,
300 std::vector
< OUString
> const & theSetExceptions
,
301 std::vector
< OUString
> const & theAnnotations
):
302 name(theName
), type(theType
), bound(theBound
),
303 readOnly(theReadOnly
), getExceptions(theGetExceptions
),
304 setExceptions(theSetExceptions
), annotations(theAnnotations
)
305 { assert(!theReadOnly
|| theSetExceptions
.empty()); }
315 std::vector
< OUString
> getExceptions
;
317 std::vector
< OUString
> setExceptions
;
319 std::vector
< OUString
> annotations
;
324 enum Direction
{ DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_IN_OUT
};
327 OUString
const & theName
, OUString
const & theType
,
328 Direction theDirection
):
329 name(theName
), type(theType
), direction(theDirection
)
340 OUString
const & theName
, OUString
const & theReturnType
,
341 std::vector
< Parameter
> const & theParameters
,
342 std::vector
< OUString
> const & theExceptions
,
343 std::vector
< OUString
> const & theAnnotations
):
344 name(theName
), returnType(theReturnType
), parameters(theParameters
),
345 exceptions(theExceptions
), annotations(theAnnotations
)
352 std::vector
< Parameter
> parameters
;
354 std::vector
< OUString
> exceptions
;
356 std::vector
< OUString
> annotations
;
359 SAL_DLLPRIVATE
InterfaceTypeEntity(
361 std::vector
< AnnotatedReference
> const & directMandatoryBases
,
362 std::vector
< AnnotatedReference
> const & directOptionalBases
,
363 std::vector
< Attribute
> const & directAttributes
,
364 std::vector
< Method
> const & directMethods
,
365 std::vector
< OUString
> const & annotations
):
366 PublishableEntity(SORT_INTERFACE_TYPE
, published
, annotations
),
367 directMandatoryBases_(directMandatoryBases
),
368 directOptionalBases_(directOptionalBases
),
369 directAttributes_(directAttributes
), directMethods_(directMethods
)
372 std::vector
< AnnotatedReference
> const & getDirectMandatoryBases() const
373 { return directMandatoryBases_
; }
375 std::vector
< AnnotatedReference
> const & getDirectOptionalBases() const
376 { return directOptionalBases_
; }
378 std::vector
< Attribute
> const & getDirectAttributes() const
379 { return directAttributes_
; }
381 std::vector
< Method
> const & getDirectMethods() const
382 { return directMethods_
; }
385 virtual SAL_DLLPRIVATE
~InterfaceTypeEntity() throw () override
;
387 std::vector
< AnnotatedReference
> directMandatoryBases_
;
388 std::vector
< AnnotatedReference
> directOptionalBases_
;
389 std::vector
< Attribute
> directAttributes_
;
390 std::vector
< Method
> directMethods_
;
393 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL TypedefEntity final
: public PublishableEntity
{
395 SAL_DLLPRIVATE
TypedefEntity(
396 bool published
, OUString
const & type
,
397 std::vector
< OUString
> const & annotations
):
398 PublishableEntity(SORT_TYPEDEF
, published
, annotations
), type_(type
)
401 const OUString
& getType() const { return type_
; }
404 virtual SAL_DLLPRIVATE
~TypedefEntity() throw () override
;
409 struct SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantValue
{
411 TYPE_BOOLEAN
, TYPE_BYTE
, TYPE_SHORT
, TYPE_UNSIGNED_SHORT
, TYPE_LONG
,
412 TYPE_UNSIGNED_LONG
, TYPE_HYPER
, TYPE_UNSIGNED_HYPER
, TYPE_FLOAT
,
415 ConstantValue(bool value
): type(TYPE_BOOLEAN
), booleanValue(value
) {}
417 ConstantValue(sal_Int8 value
): type(TYPE_BYTE
), byteValue(value
) {}
419 ConstantValue(sal_Int16 value
): type(TYPE_SHORT
), shortValue(value
) {}
421 ConstantValue(sal_uInt16 value
):
422 type(TYPE_UNSIGNED_SHORT
), unsignedShortValue(value
)
425 ConstantValue(sal_Int32 value
): type(TYPE_LONG
), longValue(value
) {}
427 ConstantValue(sal_uInt32 value
):
428 type(TYPE_UNSIGNED_LONG
), unsignedLongValue(value
)
431 ConstantValue(sal_Int64 value
): type(TYPE_HYPER
), hyperValue(value
) {}
433 ConstantValue(sal_uInt64 value
):
434 type(TYPE_UNSIGNED_HYPER
), unsignedHyperValue(value
)
437 ConstantValue(float value
): type(TYPE_FLOAT
), floatValue(value
) {}
439 ConstantValue(double value
): type(TYPE_DOUBLE
), doubleValue(value
) {}
446 sal_Int16 shortValue
;
447 sal_uInt16 unsignedShortValue
;
449 sal_uInt32 unsignedLongValue
;
450 sal_Int64 hyperValue
;
451 sal_uInt64 unsignedHyperValue
;
457 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final
: public PublishableEntity
{
461 OUString
const & theName
, ConstantValue
const & theValue
,
462 std::vector
< OUString
> const & theAnnotations
):
463 name(theName
), value(theValue
), annotations(theAnnotations
)
470 std::vector
< OUString
> annotations
;
473 SAL_DLLPRIVATE
ConstantGroupEntity(
474 bool published
, std::vector
< Member
> const & members
,
475 std::vector
< OUString
> const & annotations
):
476 PublishableEntity(SORT_CONSTANT_GROUP
, published
, annotations
),
480 std::vector
< Member
> const & getMembers() const { return members_
; }
483 virtual SAL_DLLPRIVATE
~ConstantGroupEntity() throw () override
;
485 std::vector
< Member
> members_
;
488 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL SingleInterfaceBasedServiceEntity final
:
489 public PublishableEntity
495 OUString
const & theName
, OUString
const & theType
,
497 name(theName
), type(theType
), rest(theRest
)
508 defaultConstructor(true) {}
511 OUString
const & theName
,
512 std::vector
< Parameter
> const & theParameters
,
513 std::vector
< OUString
> const & theExceptions
,
514 std::vector
< OUString
> const & theAnnotations
):
515 name(theName
), parameters(theParameters
), exceptions(theExceptions
),
516 annotations(theAnnotations
), defaultConstructor(false)
521 std::vector
< Parameter
> parameters
;
523 std::vector
< OUString
> exceptions
;
525 std::vector
< OUString
> annotations
;
527 bool defaultConstructor
;
530 SAL_DLLPRIVATE
SingleInterfaceBasedServiceEntity(
531 bool published
, OUString
const & base
,
532 std::vector
< Constructor
> const & constructors
,
533 std::vector
< OUString
> const & annotations
):
535 SORT_SINGLE_INTERFACE_BASED_SERVICE
, published
, annotations
),
536 base_(base
), constructors_(constructors
)
539 const OUString
& getBase() const { return base_
; }
541 std::vector
< Constructor
> const & getConstructors() const
542 { return constructors_
; }
545 virtual SAL_DLLPRIVATE
~SingleInterfaceBasedServiceEntity() throw () override
;
548 std::vector
< Constructor
> constructors_
;
551 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity final
:
552 public PublishableEntity
557 ATTRIBUTE_MAYBE_VOID
= 0x001,
558 ATTRIBUTE_BOUND
= 0x002,
559 ATTRIBUTE_CONSTRAINED
= 0x004,
560 ATTRIBUTE_TRANSIENT
= 0x008,
561 ATTRIBUTE_READ_ONLY
= 0x010,
562 ATTRIBUTE_MAYBE_AMBIGUOUS
= 0x020,
563 ATTRIBUTE_MAYBE_DEFAULT
= 0x040,
564 ATTRIBUTE_REMOVABLE
= 0x080,
565 ATTRIBUTE_OPTIONAL
= 0x100
569 OUString
const & theName
, OUString
const & theType
,
570 Attributes theAttributes
,
571 std::vector
< OUString
> const & theAnnotations
):
572 name(theName
), type(theType
), attributes(theAttributes
),
573 annotations(theAnnotations
)
580 Attributes attributes
;
582 std::vector
< OUString
> annotations
;
585 SAL_DLLPRIVATE
AccumulationBasedServiceEntity(
587 std::vector
< AnnotatedReference
> const & directMandatoryBaseServices
,
588 std::vector
< AnnotatedReference
> const & directOptionalBaseServices
,
589 std::vector
< AnnotatedReference
> const & directMandatoryBaseInterfaces
,
590 std::vector
< AnnotatedReference
> const & directOptionalBaseInterfaces
,
591 std::vector
< Property
> const & directProperties
,
592 std::vector
< OUString
> const & annotations
):
594 SORT_ACCUMULATION_BASED_SERVICE
, published
, annotations
),
595 directMandatoryBaseServices_(directMandatoryBaseServices
),
596 directOptionalBaseServices_(directOptionalBaseServices
),
597 directMandatoryBaseInterfaces_(directMandatoryBaseInterfaces
),
598 directOptionalBaseInterfaces_(directOptionalBaseInterfaces
),
599 directProperties_(directProperties
)
602 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseServices()
604 { return directMandatoryBaseServices_
; }
606 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseServices()
608 { return directOptionalBaseServices_
; }
610 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseInterfaces()
612 { return directMandatoryBaseInterfaces_
; }
614 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseInterfaces()
616 { return directOptionalBaseInterfaces_
; }
618 std::vector
< Property
> const & getDirectProperties() const
619 { return directProperties_
; }
622 virtual SAL_DLLPRIVATE
~AccumulationBasedServiceEntity() throw () override
;
624 std::vector
< AnnotatedReference
> directMandatoryBaseServices_
;
625 std::vector
< AnnotatedReference
> directOptionalBaseServices_
;
626 std::vector
< AnnotatedReference
> directMandatoryBaseInterfaces_
;
627 std::vector
< AnnotatedReference
> directOptionalBaseInterfaces_
;
628 std::vector
< Property
> directProperties_
;
631 class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity final
:
632 public PublishableEntity
635 SAL_DLLPRIVATE
InterfaceBasedSingletonEntity(
636 bool published
, OUString
const & base
,
637 std::vector
< OUString
> const & annotations
):
639 SORT_INTERFACE_BASED_SINGLETON
, published
, annotations
),
643 const OUString
& getBase() const { return base_
; }
646 virtual SAL_DLLPRIVATE
~InterfaceBasedSingletonEntity() throw () override
;
651 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final
: public PublishableEntity
654 SAL_DLLPRIVATE
ServiceBasedSingletonEntity(
655 bool published
, OUString
const & base
,
656 std::vector
< OUString
> const & annotations
):
657 PublishableEntity(SORT_SERVICE_BASED_SINGLETON
, published
, annotations
),
661 const OUString
& getBase() const { return base_
; }
664 virtual SAL_DLLPRIVATE
~ServiceBasedSingletonEntity() throw () override
;
669 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Provider
: public salhelper::SimpleReferenceObject
{
671 // throws FileFormatException:
672 virtual rtl::Reference
< MapCursor
> createRootCursor() const = 0;
674 // throws FileFormatException:
675 virtual rtl::Reference
< Entity
> findEntity(OUString
const & name
)
679 SAL_DLLPRIVATE
Provider() {}
681 virtual SAL_DLLPRIVATE
~Provider() throw () override
;
684 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Manager final
: public salhelper::SimpleReferenceObject
{
688 // throws FileFormatException, NoSuchFileException:
689 rtl::Reference
< Provider
> addProvider(OUString
const & uri
);
691 // throws FileFormatException:
692 rtl::Reference
< Entity
> findEntity(OUString
const & name
) const;
694 // throws FileFormatException:
695 rtl::Reference
< MapCursor
> createCursor(OUString
const & name
) const;
698 virtual SAL_DLLPRIVATE
~Manager() throw () override
;
700 SAL_DLLPRIVATE
rtl::Reference
< Provider
> loadProvider(
701 OUString
const & uri
);
703 mutable osl::Mutex mutex_
;
704 std::vector
< rtl::Reference
< Provider
> > providers_
;
711 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */