Fix typos
[LibreOffice.git] / include / unoidl / unoidl.hxx
blob7791fcd41c913214435bdd7235ab20c0b9cbd1b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef INCLUDED_UNOIDL_UNOIDL_HXX
11 #define INCLUDED_UNOIDL_UNOIDL_HXX
13 #include <sal/config.h>
15 #include <cassert>
16 #include <utility>
17 #include <vector>
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>
26 namespace unoidl {
28 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final {
29 public:
30 SAL_DLLPRIVATE NoSuchFileException(OUString uri): uri_(std::move(uri)) {}
32 SAL_DLLPRIVATE NoSuchFileException(NoSuchFileException const & other):
33 uri_(other.uri_) {}
35 SAL_DLLPRIVATE ~NoSuchFileException() noexcept;
37 const OUString& getUri() const { return uri_; }
39 private:
40 NoSuchFileException& operator =(NoSuchFileException const &) = delete;
42 OUString uri_;
45 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final {
46 public:
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_; }
62 private:
63 FileFormatException& operator =(FileFormatException const &) = delete;
65 OUString uri_;
66 OUString detail_;
69 struct AnnotatedReference {
70 AnnotatedReference(
71 OUString theName,
72 std::vector< OUString > && theAnnotations):
73 name(std::move(theName)), annotations(std::move(theAnnotations))
76 OUString name;
78 std::vector< OUString > annotations;
81 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Entity: public salhelper::SimpleReferenceObject {
82 public:
83 enum Sort {
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_; }
93 protected:
94 explicit SAL_DLLPRIVATE Entity(Sort sort): sort_(sort) {}
96 virtual SAL_DLLPRIVATE ~Entity() noexcept override;
98 private:
99 Sort sort_;
102 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL MapCursor: public salhelper::SimpleReferenceObject {
103 public:
104 // throws FileFormatException:
105 virtual rtl::Reference< Entity > getNext(OUString * name) = 0;
107 protected:
108 SAL_DLLPRIVATE MapCursor() {}
110 virtual SAL_DLLPRIVATE ~MapCursor() noexcept override;
113 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ModuleEntity: public Entity {
114 public:
115 // throws FileFormatException:
116 virtual std::vector< OUString > getMemberNames() const = 0;
118 // throws FileFormatException:
119 virtual rtl::Reference< MapCursor > createCursor() const = 0;
121 protected:
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 {
128 public:
129 bool isPublished() const { return published_; }
131 std::vector< OUString > const & getAnnotations() const
132 { return annotations_; }
134 protected:
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;
143 private:
144 bool published_;
146 std::vector< OUString > annotations_;
149 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final : public PublishableEntity {
150 public:
151 struct Member {
152 Member(
153 OUString theName, sal_Int32 theValue,
154 std::vector< OUString >&& theAnnotations):
155 name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations))
158 OUString name;
160 sal_Int32 value;
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_; }
174 private:
175 virtual SAL_DLLPRIVATE ~EnumTypeEntity() noexcept override;
177 std::vector< Member > members_;
180 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final : public PublishableEntity {
181 public:
182 struct Member {
183 Member(OUString theName, OUString theType,
184 std::vector< OUString >&& theAnnotations):
185 name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations))
188 OUString name;
190 OUString type;
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_; }
208 private:
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
218 public:
219 struct Member {
220 Member(
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))
228 OUString name;
230 OUString type;
232 bool parameterized;
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):
241 PublishableEntity(
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_; }
251 private:
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 {
259 public:
260 struct Member {
261 Member(
262 OUString theName, OUString theType,
263 std::vector< OUString >&& theAnnotations):
264 name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations))
267 OUString name;
269 OUString type;
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_; }
287 private:
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 {
295 public:
296 struct Attribute {
297 Attribute(
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()); }
308 OUString name;
310 OUString type;
312 bool bound;
314 bool readOnly;
316 std::vector< OUString > getExceptions;
318 std::vector< OUString > setExceptions;
320 std::vector< OUString > annotations;
323 struct Method {
324 struct Parameter {
325 enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT };
327 Parameter(
328 OUString theName, OUString theType,
329 Direction theDirection):
330 name(std::move(theName)), type(std::move(theType)), direction(theDirection)
333 OUString name;
335 OUString type;
337 Direction direction;
340 Method(
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))
349 OUString name;
351 OUString returnType;
353 std::vector< Parameter > parameters;
355 std::vector< OUString > exceptions;
357 std::vector< OUString > annotations;
360 SAL_DLLPRIVATE InterfaceTypeEntity(
361 bool published,
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_; }
386 private:
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 {
396 public:
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_; }
405 private:
406 virtual SAL_DLLPRIVATE ~TypedefEntity() noexcept override;
408 OUString type_;
411 struct SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantValue {
412 enum Type {
413 TYPE_BOOLEAN, TYPE_BYTE, TYPE_SHORT, TYPE_UNSIGNED_SHORT, TYPE_LONG,
414 TYPE_UNSIGNED_LONG, TYPE_HYPER, TYPE_UNSIGNED_HYPER, TYPE_FLOAT,
415 TYPE_DOUBLE };
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) {}
443 Type type;
445 union {
446 bool booleanValue;
447 sal_Int8 byteValue;
448 sal_Int16 shortValue;
449 sal_uInt16 unsignedShortValue;
450 sal_Int32 longValue;
451 sal_uInt32 unsignedLongValue;
452 sal_Int64 hyperValue;
453 sal_uInt64 unsignedHyperValue;
454 float floatValue;
455 double doubleValue;
459 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final : public PublishableEntity {
460 public:
461 struct Member {
462 Member(
463 OUString theName, ConstantValue const & theValue,
464 std::vector< OUString >&& theAnnotations):
465 name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations))
468 OUString name;
470 ConstantValue value;
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_; }
484 private:
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
493 public:
494 struct Constructor {
495 struct Parameter {
496 Parameter(
497 OUString theName, OUString theType,
498 bool theRest):
499 name(std::move(theName)), type(std::move(theType)), rest(theRest)
502 OUString name;
504 OUString type;
506 bool rest;
509 Constructor():
510 defaultConstructor(true) {}
512 Constructor(
513 OUString theName,
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)
523 OUString name;
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):
538 PublishableEntity(
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_; }
548 private:
549 virtual SAL_DLLPRIVATE ~SingleInterfaceBasedServiceEntity() noexcept override;
551 OUString base_;
552 std::vector< Constructor > constructors_;
555 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity final :
556 public PublishableEntity
558 public:
559 struct Property {
560 enum Attributes {
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
572 Property(
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))
580 OUString name;
582 OUString type;
584 Attributes attributes;
586 std::vector< OUString > annotations;
589 SAL_DLLPRIVATE AccumulationBasedServiceEntity(
590 bool published,
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):
597 PublishableEntity(
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()
607 const
608 { return directMandatoryBaseServices_; }
610 std::vector< AnnotatedReference > const & getDirectOptionalBaseServices()
611 const
612 { return directOptionalBaseServices_; }
614 std::vector< AnnotatedReference > const & getDirectMandatoryBaseInterfaces()
615 const
616 { return directMandatoryBaseInterfaces_; }
618 std::vector< AnnotatedReference > const & getDirectOptionalBaseInterfaces()
619 const
620 { return directOptionalBaseInterfaces_; }
622 std::vector< Property > const & getDirectProperties() const
623 { return directProperties_; }
625 private:
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
638 public:
639 SAL_DLLPRIVATE InterfaceBasedSingletonEntity(
640 bool published, OUString base,
641 std::vector< OUString >&& annotations):
642 PublishableEntity(
643 SORT_INTERFACE_BASED_SINGLETON, published, std::move(annotations)),
644 base_(std::move(base))
647 const OUString& getBase() const { return base_; }
649 private:
650 virtual SAL_DLLPRIVATE ~InterfaceBasedSingletonEntity() noexcept override;
652 OUString base_;
655 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final : public PublishableEntity
657 public:
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_; }
667 private:
668 virtual SAL_DLLPRIVATE ~ServiceBasedSingletonEntity() noexcept override;
670 OUString base_;
673 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Provider: public salhelper::SimpleReferenceObject {
674 public:
675 // throws FileFormatException:
676 virtual rtl::Reference< MapCursor > createRootCursor() const = 0;
678 // throws FileFormatException:
679 virtual rtl::Reference< Entity > findEntity(OUString const & name)
680 const = 0;
682 protected:
683 SAL_DLLPRIVATE Provider() {}
685 virtual SAL_DLLPRIVATE ~Provider() noexcept override;
688 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Manager final : public salhelper::SimpleReferenceObject {
689 public:
690 Manager() {}
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;
701 private:
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_;
713 #endif
715 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */