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>
19 #include <osl/mutex.hxx>
20 #include <rtl/ref.hxx>
21 #include <rtl/ustring.hxx>
22 #include <sal/types.h>
23 #include <salhelper/simplereferenceobject.hxx>
24 #include <unoidl/detail/dllapi.hxx>
28 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final
{
30 SAL_DLLPRIVATE
NoSuchFileException(OUString uri
): uri_(std::move(uri
)) {}
32 SAL_DLLPRIVATE
NoSuchFileException(NoSuchFileException
const & other
):
35 SAL_DLLPRIVATE
~NoSuchFileException() noexcept
;
37 const OUString
& getUri() const { return uri_
; }
40 NoSuchFileException
& operator =(NoSuchFileException
const &) = delete;
45 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final
{
47 SAL_DLLPRIVATE
FileFormatException(
48 OUString uri
, OUString detail
):
49 uri_(std::move(uri
)), detail_(std::move(detail
))
52 SAL_DLLPRIVATE
FileFormatException(FileFormatException
const & other
):
53 uri_(other
.uri_
), detail_(other
.detail_
)
56 SAL_DLLPRIVATE
~FileFormatException() noexcept
;
58 const OUString
& getUri() const { return uri_
; }
60 const OUString
& getDetail() const { return detail_
; }
63 FileFormatException
& operator =(FileFormatException
const &) = delete;
69 struct AnnotatedReference
{
72 std::vector
< OUString
> && theAnnotations
):
73 name(std::move(theName
)), annotations(std::move(theAnnotations
))
78 std::vector
< OUString
> annotations
;
81 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Entity
: public salhelper::SimpleReferenceObject
{
84 SORT_MODULE
, SORT_ENUM_TYPE
, SORT_PLAIN_STRUCT_TYPE
,
85 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, SORT_EXCEPTION_TYPE
,
86 SORT_INTERFACE_TYPE
, SORT_TYPEDEF
, SORT_CONSTANT_GROUP
,
87 SORT_SINGLE_INTERFACE_BASED_SERVICE
, SORT_ACCUMULATION_BASED_SERVICE
,
88 SORT_INTERFACE_BASED_SINGLETON
, SORT_SERVICE_BASED_SINGLETON
91 Sort
getSort() const { return sort_
; }
94 explicit SAL_DLLPRIVATE
Entity(Sort sort
): sort_(sort
) {}
96 virtual SAL_DLLPRIVATE
~Entity() noexcept override
;
102 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL MapCursor
: public salhelper::SimpleReferenceObject
{
104 // throws FileFormatException:
105 virtual rtl::Reference
< Entity
> getNext(OUString
* name
) = 0;
108 SAL_DLLPRIVATE
MapCursor() {}
110 virtual SAL_DLLPRIVATE
~MapCursor() noexcept override
;
113 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ModuleEntity
: public Entity
{
115 // throws FileFormatException:
116 virtual std::vector
< OUString
> getMemberNames() const = 0;
118 // throws FileFormatException:
119 virtual rtl::Reference
< MapCursor
> createCursor() const = 0;
122 SAL_DLLPRIVATE
ModuleEntity(): Entity(SORT_MODULE
) {}
124 virtual SAL_DLLPRIVATE
~ModuleEntity() noexcept override
;
127 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PublishableEntity
: public Entity
{
129 bool isPublished() const { return published_
; }
131 std::vector
< OUString
> const & getAnnotations() const
132 { return annotations_
; }
135 SAL_DLLPRIVATE
PublishableEntity(
136 Sort sort
, bool published
,
137 std::vector
< OUString
>&& annotations
):
138 Entity(sort
), published_(published
), annotations_(std::move(annotations
))
141 virtual SAL_DLLPRIVATE
~PublishableEntity() noexcept override
;
146 std::vector
< OUString
> annotations_
;
149 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final
: public PublishableEntity
{
153 OUString theName
, sal_Int32 theValue
,
154 std::vector
< OUString
>&& theAnnotations
):
155 name(std::move(theName
)), value(theValue
), annotations(std::move(theAnnotations
))
162 std::vector
< OUString
> annotations
;
165 SAL_DLLPRIVATE
EnumTypeEntity(
166 bool published
, std::vector
< Member
>&& members
,
167 std::vector
< OUString
>&& annotations
):
168 PublishableEntity(SORT_ENUM_TYPE
, published
, std::move(annotations
)),
169 members_(std::move(members
))
170 { assert(!members_
.empty()); }
172 std::vector
< Member
> const & getMembers() const { return members_
; }
175 virtual SAL_DLLPRIVATE
~EnumTypeEntity() noexcept override
;
177 std::vector
< Member
> members_
;
180 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final
: public PublishableEntity
{
183 Member(OUString theName
, OUString theType
,
184 std::vector
< OUString
>&& theAnnotations
):
185 name(std::move(theName
)), type(std::move(theType
)), annotations(std::move(theAnnotations
))
192 std::vector
< OUString
> annotations
;
195 SAL_DLLPRIVATE
PlainStructTypeEntity(
196 bool published
, OUString directBase
,
197 std::vector
< Member
>&& directMembers
,
198 std::vector
< OUString
> && annotations
):
199 PublishableEntity(SORT_PLAIN_STRUCT_TYPE
, published
, std::move(annotations
)),
200 directBase_(std::move(directBase
)), directMembers_(std::move(directMembers
))
203 const OUString
& getDirectBase() const { return directBase_
; }
205 std::vector
< Member
> const & getDirectMembers() const
206 { return directMembers_
; }
209 virtual SAL_DLLPRIVATE
~PlainStructTypeEntity() noexcept override
;
211 OUString directBase_
;
212 std::vector
< Member
> directMembers_
;
215 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity final
:
216 public PublishableEntity
221 OUString theName
, OUString theType
,
222 bool theParameterized
,
223 std::vector
< OUString
>&& theAnnotations
):
224 name(std::move(theName
)), type(std::move(theType
)), parameterized(theParameterized
),
225 annotations(std::move(theAnnotations
))
234 std::vector
< OUString
> annotations
;
237 SAL_DLLPRIVATE
PolymorphicStructTypeTemplateEntity(
238 bool published
, std::vector
< OUString
>&& typeParameters
,
239 std::vector
< Member
>&& members
,
240 std::vector
< OUString
>&& annotations
):
242 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, published
, std::move(annotations
)),
243 typeParameters_(std::move(typeParameters
)), members_(std::move(members
))
246 std::vector
< OUString
> const & getTypeParameters() const
247 { return typeParameters_
; }
249 std::vector
< Member
> const & getMembers() const { return members_
; }
252 virtual SAL_DLLPRIVATE
~PolymorphicStructTypeTemplateEntity() noexcept override
;
254 std::vector
< OUString
> typeParameters_
;
255 std::vector
< Member
> members_
;
258 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity final
: public PublishableEntity
{
262 OUString theName
, OUString theType
,
263 std::vector
< OUString
>&& theAnnotations
):
264 name(std::move(theName
)), type(std::move(theType
)), annotations(std::move(theAnnotations
))
271 std::vector
< OUString
> annotations
;
274 SAL_DLLPRIVATE
ExceptionTypeEntity(
275 bool published
, OUString directBase
,
276 std::vector
< Member
>&& directMembers
,
277 std::vector
< OUString
>&& annotations
):
278 PublishableEntity(SORT_EXCEPTION_TYPE
, published
, std::move(annotations
)),
279 directBase_(std::move(directBase
)), directMembers_(std::move(directMembers
))
282 const OUString
& getDirectBase() const { return directBase_
; }
284 std::vector
< Member
> const & getDirectMembers() const
285 { return directMembers_
; }
288 virtual SAL_DLLPRIVATE
~ExceptionTypeEntity() noexcept override
;
290 OUString directBase_
;
291 std::vector
< Member
> directMembers_
;
294 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity final
: public PublishableEntity
{
298 OUString theName
, OUString theType
,
299 bool theBound
, bool theReadOnly
,
300 std::vector
< OUString
>&& theGetExceptions
,
301 std::vector
< OUString
>&& theSetExceptions
,
302 std::vector
< OUString
>&& theAnnotations
):
303 name(std::move(theName
)), type(std::move(theType
)), bound(theBound
),
304 readOnly(theReadOnly
), getExceptions(std::move(theGetExceptions
)),
305 setExceptions(std::move(theSetExceptions
)), annotations(std::move(theAnnotations
))
306 { assert(!theReadOnly
|| setExceptions
.empty()); }
316 std::vector
< OUString
> getExceptions
;
318 std::vector
< OUString
> setExceptions
;
320 std::vector
< OUString
> annotations
;
325 enum Direction
{ DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_IN_OUT
};
328 OUString theName
, OUString theType
,
329 Direction theDirection
):
330 name(std::move(theName
)), type(std::move(theType
)), direction(theDirection
)
341 OUString theName
, OUString theReturnType
,
342 std::vector
< Parameter
>&& theParameters
,
343 std::vector
< OUString
>&& theExceptions
,
344 std::vector
< OUString
>&& theAnnotations
):
345 name(std::move(theName
)), returnType(std::move(theReturnType
)), parameters(std::move(theParameters
)),
346 exceptions(std::move(theExceptions
)), annotations(std::move(theAnnotations
))
353 std::vector
< Parameter
> parameters
;
355 std::vector
< OUString
> exceptions
;
357 std::vector
< OUString
> annotations
;
360 SAL_DLLPRIVATE
InterfaceTypeEntity(
362 std::vector
< AnnotatedReference
>&& directMandatoryBases
,
363 std::vector
< AnnotatedReference
>&& directOptionalBases
,
364 std::vector
< Attribute
>&& directAttributes
,
365 std::vector
< Method
>&& directMethods
,
366 std::vector
< OUString
>&& annotations
):
367 PublishableEntity(SORT_INTERFACE_TYPE
, published
, std::move(annotations
)),
368 directMandatoryBases_(std::move(directMandatoryBases
)),
369 directOptionalBases_(std::move(directOptionalBases
)),
370 directAttributes_(std::move(directAttributes
)),
371 directMethods_(std::move(directMethods
))
374 std::vector
< AnnotatedReference
> const & getDirectMandatoryBases() const
375 { return directMandatoryBases_
; }
377 std::vector
< AnnotatedReference
> const & getDirectOptionalBases() const
378 { return directOptionalBases_
; }
380 std::vector
< Attribute
> const & getDirectAttributes() const
381 { return directAttributes_
; }
383 std::vector
< Method
> const & getDirectMethods() const
384 { return directMethods_
; }
387 virtual SAL_DLLPRIVATE
~InterfaceTypeEntity() noexcept override
;
389 std::vector
< AnnotatedReference
> directMandatoryBases_
;
390 std::vector
< AnnotatedReference
> directOptionalBases_
;
391 std::vector
< Attribute
> directAttributes_
;
392 std::vector
< Method
> directMethods_
;
395 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL TypedefEntity final
: public PublishableEntity
{
397 SAL_DLLPRIVATE
TypedefEntity(
398 bool published
, OUString type
,
399 std::vector
< OUString
>&& annotations
):
400 PublishableEntity(SORT_TYPEDEF
, published
, std::move(annotations
)), type_(std::move(type
))
403 const OUString
& getType() const { return type_
; }
406 virtual SAL_DLLPRIVATE
~TypedefEntity() noexcept override
;
411 struct SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantValue
{
413 TYPE_BOOLEAN
, TYPE_BYTE
, TYPE_SHORT
, TYPE_UNSIGNED_SHORT
, TYPE_LONG
,
414 TYPE_UNSIGNED_LONG
, TYPE_HYPER
, TYPE_UNSIGNED_HYPER
, TYPE_FLOAT
,
417 ConstantValue(bool value
): type(TYPE_BOOLEAN
), booleanValue(value
) {}
419 ConstantValue(sal_Int8 value
): type(TYPE_BYTE
), byteValue(value
) {}
421 ConstantValue(sal_Int16 value
): type(TYPE_SHORT
), shortValue(value
) {}
423 ConstantValue(sal_uInt16 value
):
424 type(TYPE_UNSIGNED_SHORT
), unsignedShortValue(value
)
427 ConstantValue(sal_Int32 value
): type(TYPE_LONG
), longValue(value
) {}
429 ConstantValue(sal_uInt32 value
):
430 type(TYPE_UNSIGNED_LONG
), unsignedLongValue(value
)
433 ConstantValue(sal_Int64 value
): type(TYPE_HYPER
), hyperValue(value
) {}
435 ConstantValue(sal_uInt64 value
):
436 type(TYPE_UNSIGNED_HYPER
), unsignedHyperValue(value
)
439 ConstantValue(float value
): type(TYPE_FLOAT
), floatValue(value
) {}
441 ConstantValue(double value
): type(TYPE_DOUBLE
), doubleValue(value
) {}
448 sal_Int16 shortValue
;
449 sal_uInt16 unsignedShortValue
;
451 sal_uInt32 unsignedLongValue
;
452 sal_Int64 hyperValue
;
453 sal_uInt64 unsignedHyperValue
;
459 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final
: public PublishableEntity
{
463 OUString theName
, ConstantValue
const & theValue
,
464 std::vector
< OUString
>&& theAnnotations
):
465 name(std::move(theName
)), value(theValue
), annotations(std::move(theAnnotations
))
472 std::vector
< OUString
> annotations
;
475 SAL_DLLPRIVATE
ConstantGroupEntity(
476 bool published
, std::vector
< Member
>&& members
,
477 std::vector
< OUString
>&& annotations
):
478 PublishableEntity(SORT_CONSTANT_GROUP
, published
, std::move(annotations
)),
479 members_(std::move(members
))
482 std::vector
< Member
> const & getMembers() const { return members_
; }
485 virtual SAL_DLLPRIVATE
~ConstantGroupEntity() noexcept override
;
487 std::vector
< Member
> members_
;
490 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL SingleInterfaceBasedServiceEntity final
:
491 public PublishableEntity
497 OUString theName
, OUString theType
,
499 name(std::move(theName
)), type(std::move(theType
)), rest(theRest
)
510 defaultConstructor(true) {}
514 std::vector
< Parameter
>&& theParameters
,
515 std::vector
< OUString
>&& theExceptions
,
516 std::vector
< OUString
>&& theAnnotations
):
517 name(std::move(theName
)), parameters(std::move(theParameters
)),
518 exceptions(std::move(theExceptions
)),
519 annotations(std::move(theAnnotations
)),
520 defaultConstructor(false)
525 std::vector
< Parameter
> parameters
;
527 std::vector
< OUString
> exceptions
;
529 std::vector
< OUString
> annotations
;
531 bool defaultConstructor
;
534 SAL_DLLPRIVATE
SingleInterfaceBasedServiceEntity(
535 bool published
, OUString base
,
536 std::vector
< Constructor
>&& constructors
,
537 std::vector
< OUString
>&& annotations
):
539 SORT_SINGLE_INTERFACE_BASED_SERVICE
, published
, std::move(annotations
)),
540 base_(std::move(base
)), constructors_(std::move(constructors
))
543 const OUString
& getBase() const { return base_
; }
545 std::vector
< Constructor
> const & getConstructors() const
546 { return constructors_
; }
549 virtual SAL_DLLPRIVATE
~SingleInterfaceBasedServiceEntity() noexcept override
;
552 std::vector
< Constructor
> constructors_
;
555 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity final
:
556 public PublishableEntity
561 ATTRIBUTE_MAYBE_VOID
= 0x001,
562 ATTRIBUTE_BOUND
= 0x002,
563 ATTRIBUTE_CONSTRAINED
= 0x004,
564 ATTRIBUTE_TRANSIENT
= 0x008,
565 ATTRIBUTE_READ_ONLY
= 0x010,
566 ATTRIBUTE_MAYBE_AMBIGUOUS
= 0x020,
567 ATTRIBUTE_MAYBE_DEFAULT
= 0x040,
568 ATTRIBUTE_REMOVABLE
= 0x080,
569 ATTRIBUTE_OPTIONAL
= 0x100
573 OUString theName
, OUString theType
,
574 Attributes theAttributes
,
575 std::vector
< OUString
>&& theAnnotations
):
576 name(std::move(theName
)), type(std::move(theType
)), attributes(theAttributes
),
577 annotations(std::move(theAnnotations
))
584 Attributes attributes
;
586 std::vector
< OUString
> annotations
;
589 SAL_DLLPRIVATE
AccumulationBasedServiceEntity(
591 std::vector
< AnnotatedReference
>&& directMandatoryBaseServices
,
592 std::vector
< AnnotatedReference
>&& directOptionalBaseServices
,
593 std::vector
< AnnotatedReference
>&& directMandatoryBaseInterfaces
,
594 std::vector
< AnnotatedReference
>&& directOptionalBaseInterfaces
,
595 std::vector
< Property
>&& directProperties
,
596 std::vector
< OUString
>&& annotations
):
598 SORT_ACCUMULATION_BASED_SERVICE
, published
, std::move(annotations
)),
599 directMandatoryBaseServices_(std::move(directMandatoryBaseServices
)),
600 directOptionalBaseServices_(std::move(directOptionalBaseServices
)),
601 directMandatoryBaseInterfaces_(std::move(directMandatoryBaseInterfaces
)),
602 directOptionalBaseInterfaces_(std::move(directOptionalBaseInterfaces
)),
603 directProperties_(std::move(directProperties
))
606 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseServices()
608 { return directMandatoryBaseServices_
; }
610 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseServices()
612 { return directOptionalBaseServices_
; }
614 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseInterfaces()
616 { return directMandatoryBaseInterfaces_
; }
618 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseInterfaces()
620 { return directOptionalBaseInterfaces_
; }
622 std::vector
< Property
> const & getDirectProperties() const
623 { return directProperties_
; }
626 virtual SAL_DLLPRIVATE
~AccumulationBasedServiceEntity() noexcept override
;
628 std::vector
< AnnotatedReference
> directMandatoryBaseServices_
;
629 std::vector
< AnnotatedReference
> directOptionalBaseServices_
;
630 std::vector
< AnnotatedReference
> directMandatoryBaseInterfaces_
;
631 std::vector
< AnnotatedReference
> directOptionalBaseInterfaces_
;
632 std::vector
< Property
> directProperties_
;
635 class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity final
:
636 public PublishableEntity
639 SAL_DLLPRIVATE
InterfaceBasedSingletonEntity(
640 bool published
, OUString base
,
641 std::vector
< OUString
>&& annotations
):
643 SORT_INTERFACE_BASED_SINGLETON
, published
, std::move(annotations
)),
644 base_(std::move(base
))
647 const OUString
& getBase() const { return base_
; }
650 virtual SAL_DLLPRIVATE
~InterfaceBasedSingletonEntity() noexcept override
;
655 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final
: public PublishableEntity
658 SAL_DLLPRIVATE
ServiceBasedSingletonEntity(
659 bool published
, OUString base
,
660 std::vector
< OUString
>&& annotations
):
661 PublishableEntity(SORT_SERVICE_BASED_SINGLETON
, published
, std::move(annotations
)),
662 base_(std::move(base
))
665 const OUString
& getBase() const { return base_
; }
668 virtual SAL_DLLPRIVATE
~ServiceBasedSingletonEntity() noexcept override
;
673 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Provider
: public salhelper::SimpleReferenceObject
{
675 // throws FileFormatException:
676 virtual rtl::Reference
< MapCursor
> createRootCursor() const = 0;
678 // throws FileFormatException:
679 virtual rtl::Reference
< Entity
> findEntity(OUString
const & name
)
683 SAL_DLLPRIVATE
Provider() {}
685 virtual SAL_DLLPRIVATE
~Provider() noexcept override
;
688 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Manager final
: public salhelper::SimpleReferenceObject
{
692 // throws FileFormatException, NoSuchFileException:
693 rtl::Reference
< Provider
> addProvider(OUString
const & uri
);
695 // throws FileFormatException:
696 rtl::Reference
< Entity
> findEntity(OUString
const & name
) const;
698 // throws FileFormatException:
699 rtl::Reference
< MapCursor
> createCursor(OUString
const & name
) const;
702 virtual SAL_DLLPRIVATE
~Manager() noexcept override
;
704 SAL_DLLPRIVATE
rtl::Reference
< Provider
> loadProvider(
705 OUString
const & uri
);
707 mutable osl::Mutex mutex_
;
708 std::vector
< rtl::Reference
< Provider
> > providers_
;
715 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */