nss: upgrade to release 3.73
[LibreOffice.git] / include / unoidl / unoidl.hxx
blob9f61b68a4b7e438072657bca35ac125ae57d4489
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 <vector>
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>
25 namespace unoidl {
27 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final {
28 public:
29 SAL_DLLPRIVATE NoSuchFileException(OUString const & uri): uri_(uri) {}
31 SAL_DLLPRIVATE NoSuchFileException(NoSuchFileException const & other):
32 uri_(other.uri_) {}
34 SAL_DLLPRIVATE ~NoSuchFileException() throw ();
36 const OUString& getUri() const { return uri_; }
38 private:
39 NoSuchFileException& operator =(NoSuchFileException const &) = delete;
41 OUString uri_;
44 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final {
45 public:
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_; }
61 private:
62 FileFormatException& operator =(FileFormatException const &) = delete;
64 OUString uri_;
65 OUString detail_;
68 struct AnnotatedReference {
69 AnnotatedReference(
70 OUString const & theName,
71 std::vector< OUString > const & theAnnotations):
72 name(theName), annotations(theAnnotations)
75 OUString name;
77 std::vector< OUString > annotations;
80 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Entity: public salhelper::SimpleReferenceObject {
81 public:
82 enum Sort {
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_; }
92 protected:
93 explicit SAL_DLLPRIVATE Entity(Sort sort): sort_(sort) {}
95 virtual SAL_DLLPRIVATE ~Entity() throw () override;
97 private:
98 Sort sort_;
101 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL MapCursor: public salhelper::SimpleReferenceObject {
102 public:
103 // throws FileFormatException:
104 virtual rtl::Reference< Entity > getNext(OUString * name) = 0;
106 protected:
107 SAL_DLLPRIVATE MapCursor() {}
109 virtual SAL_DLLPRIVATE ~MapCursor() throw() override;
112 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ModuleEntity: public Entity {
113 public:
114 // throws FileFormatException:
115 virtual std::vector< OUString > getMemberNames() const = 0;
117 // throws FileFormatException:
118 virtual rtl::Reference< MapCursor > createCursor() const = 0;
120 protected:
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 {
127 public:
128 bool isPublished() const { return published_; }
130 std::vector< OUString > const & getAnnotations() const
131 { return annotations_; }
133 protected:
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;
142 private:
143 bool published_;
145 std::vector< OUString > annotations_;
148 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final : public PublishableEntity {
149 public:
150 struct Member {
151 Member(
152 OUString const & theName, sal_Int32 theValue,
153 std::vector< OUString > const & theAnnotations):
154 name(theName), value(theValue), annotations(theAnnotations)
157 OUString name;
159 sal_Int32 value;
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),
168 members_(members)
169 { assert(!members.empty()); }
171 std::vector< Member > const & getMembers() const { return members_; }
173 private:
174 virtual SAL_DLLPRIVATE ~EnumTypeEntity() throw () override;
176 std::vector< Member > members_;
179 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final : public PublishableEntity {
180 public:
181 struct Member {
182 Member(OUString const & theName, OUString const & theType,
183 std::vector< OUString > const & theAnnotations):
184 name(theName), type(theType), annotations(theAnnotations)
187 OUString name;
189 OUString type;
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_; }
207 private:
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
217 public:
218 struct Member {
219 Member(
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)
227 OUString name;
229 OUString type;
231 bool parameterized;
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):
240 PublishableEntity(
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_; }
250 private:
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 {
258 public:
259 struct Member {
260 Member(
261 OUString const & theName, OUString const & theType,
262 std::vector< OUString > const & theAnnotations):
263 name(theName), type(theType), annotations(theAnnotations)
266 OUString name;
268 OUString type;
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_; }
286 private:
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 {
294 public:
295 struct Attribute {
296 Attribute(
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()); }
307 OUString name;
309 OUString type;
311 bool bound;
313 bool readOnly;
315 std::vector< OUString > getExceptions;
317 std::vector< OUString > setExceptions;
319 std::vector< OUString > annotations;
322 struct Method {
323 struct Parameter {
324 enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT };
326 Parameter(
327 OUString const & theName, OUString const & theType,
328 Direction theDirection):
329 name(theName), type(theType), direction(theDirection)
332 OUString name;
334 OUString type;
336 Direction direction;
339 Method(
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)
348 OUString name;
350 OUString returnType;
352 std::vector< Parameter > parameters;
354 std::vector< OUString > exceptions;
356 std::vector< OUString > annotations;
359 SAL_DLLPRIVATE InterfaceTypeEntity(
360 bool published,
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_; }
384 private:
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 {
394 public:
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_; }
403 private:
404 virtual SAL_DLLPRIVATE ~TypedefEntity() throw () override;
406 OUString type_;
409 struct SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantValue {
410 enum Type {
411 TYPE_BOOLEAN, TYPE_BYTE, TYPE_SHORT, TYPE_UNSIGNED_SHORT, TYPE_LONG,
412 TYPE_UNSIGNED_LONG, TYPE_HYPER, TYPE_UNSIGNED_HYPER, TYPE_FLOAT,
413 TYPE_DOUBLE };
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) {}
441 Type type;
443 union {
444 bool booleanValue;
445 sal_Int8 byteValue;
446 sal_Int16 shortValue;
447 sal_uInt16 unsignedShortValue;
448 sal_Int32 longValue;
449 sal_uInt32 unsignedLongValue;
450 sal_Int64 hyperValue;
451 sal_uInt64 unsignedHyperValue;
452 float floatValue;
453 double doubleValue;
457 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final : public PublishableEntity {
458 public:
459 struct Member {
460 Member(
461 OUString const & theName, ConstantValue const & theValue,
462 std::vector< OUString > const & theAnnotations):
463 name(theName), value(theValue), annotations(theAnnotations)
466 OUString name;
468 ConstantValue value;
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),
477 members_(members)
480 std::vector< Member > const & getMembers() const { return members_; }
482 private:
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
491 public:
492 struct Constructor {
493 struct Parameter {
494 Parameter(
495 OUString const & theName, OUString const & theType,
496 bool theRest):
497 name(theName), type(theType), rest(theRest)
500 OUString name;
502 OUString type;
504 bool rest;
507 Constructor():
508 defaultConstructor(true) {}
510 Constructor(
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)
519 OUString name;
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):
534 PublishableEntity(
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_; }
544 private:
545 virtual SAL_DLLPRIVATE ~SingleInterfaceBasedServiceEntity() throw () override;
547 OUString base_;
548 std::vector< Constructor > constructors_;
551 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity final :
552 public PublishableEntity
554 public:
555 struct Property {
556 enum Attributes {
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
568 Property(
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)
576 OUString name;
578 OUString type;
580 Attributes attributes;
582 std::vector< OUString > annotations;
585 SAL_DLLPRIVATE AccumulationBasedServiceEntity(
586 bool published,
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):
593 PublishableEntity(
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()
603 const
604 { return directMandatoryBaseServices_; }
606 std::vector< AnnotatedReference > const & getDirectOptionalBaseServices()
607 const
608 { return directOptionalBaseServices_; }
610 std::vector< AnnotatedReference > const & getDirectMandatoryBaseInterfaces()
611 const
612 { return directMandatoryBaseInterfaces_; }
614 std::vector< AnnotatedReference > const & getDirectOptionalBaseInterfaces()
615 const
616 { return directOptionalBaseInterfaces_; }
618 std::vector< Property > const & getDirectProperties() const
619 { return directProperties_; }
621 private:
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
634 public:
635 SAL_DLLPRIVATE InterfaceBasedSingletonEntity(
636 bool published, OUString const & base,
637 std::vector< OUString > const & annotations):
638 PublishableEntity(
639 SORT_INTERFACE_BASED_SINGLETON, published, annotations),
640 base_(base)
643 const OUString& getBase() const { return base_; }
645 private:
646 virtual SAL_DLLPRIVATE ~InterfaceBasedSingletonEntity() throw () override;
648 OUString base_;
651 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final : public PublishableEntity
653 public:
654 SAL_DLLPRIVATE ServiceBasedSingletonEntity(
655 bool published, OUString const & base,
656 std::vector< OUString > const & annotations):
657 PublishableEntity(SORT_SERVICE_BASED_SINGLETON, published, annotations),
658 base_(base)
661 const OUString& getBase() const { return base_; }
663 private:
664 virtual SAL_DLLPRIVATE ~ServiceBasedSingletonEntity() throw () override;
666 OUString base_;
669 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Provider: public salhelper::SimpleReferenceObject {
670 public:
671 // throws FileFormatException:
672 virtual rtl::Reference< MapCursor > createRootCursor() const = 0;
674 // throws FileFormatException:
675 virtual rtl::Reference< Entity > findEntity(OUString const & name)
676 const = 0;
678 protected:
679 SAL_DLLPRIVATE Provider() {}
681 virtual SAL_DLLPRIVATE ~Provider() throw () override;
684 class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Manager final : public salhelper::SimpleReferenceObject {
685 public:
686 Manager() {}
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;
697 private:
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_;
709 #endif
711 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */