32 mike 1.1 //
33 //END_HISTORY
34
35 #include <cctype>
36 #include <fstream>
37 #include <Pegasus/Common/Pair.h>
38 #include <Pegasus/Common/Destroyer.h>
39 #include <Pegasus/Common/FileSystem.h>
40 #include <Pegasus/Common/Exception.h>
41 #include <Pegasus/Common/XmlReader.h>
42 #include <Pegasus/Common/XmlWriter.h>
43 #include <Pegasus/Common/DeclContext.h>
44 #include "Repository.h"
45
46 #define INDENT_XML_FILES
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 ////////////////////////////////////////////////////////////////////////////////
51 //
52 // Local functions
53 mike 1.1 //
54 ////////////////////////////////////////////////////////////////////////////////
55
56 //------------------------------------------------------------------------------
57 //
58 // This routine matches files in the classes directory (given by path)
59 // that match the second and third arguments, which are eight class names
60 // or asterisks (which are wild cards). All the files in the ./classes
61 // directory are of the form <className.superClassName>. For classes
62 // with no superClass, the superClassName is "#". We consider a couple of
63 // examples. To find all direct subclasses of "MyClass", we invoke it
64 // as follows:
65 //
66 // _GlobClassesDir(path, "*", "MyClass");
67 //
68 // To find the file which contains the class called "MyClass", we invoke
69 // it like this.
70 //
71 // _GlobClassesDir(path, "MyClass", "*");
72 //
73 // Since base classes are of the form "<ClassName>.#", all baseclasses may
74 mike 1.1 // be found with:
75 //
76 // _GlobClassesDir(path, "*", "#");
77 //
78 // Note that the results (the array of filenames which are returned) must
79 // be processed further to get the actual class names. The name of the
80 // class is the filename less the extension. Or this:
81 //
82 // String className = fileName.subString(fileName.find(0, '.'));
83 //
84 //------------------------------------------------------------------------------
85
86 Array<String> _GlobClassesDir(
87 const String& path,
88 const String& className,
89 const String& superClassName)
90 {
91 Array<String> fileNames;
92
93 if (!FileSystem::getDirectoryContents(path, fileNames))
94 throw NoSuchDirectory(path);
95 mike 1.1
96 Array<String> result;
97
98 for (Uint32 i = 0; i < fileNames.getSize(); i++)
99 {
100 const String& tmp = fileNames[i];
101
102 Uint32 dot = tmp.find('.');
103
104 // Ignore files that do not contain a dot:
105
106 if (dot == Uint32(-1))
107 continue;
108
109 String first = tmp.subString(0, dot);
110 String second = tmp.subString(dot + 1);
111
112 if ((className == "*" || first == className) &&
113 (superClassName == "*" || second == superClassName))
114 {
115 result.append(tmp);
116 mike 1.1 }
117 }
118
119 return result;
120 }
121
122 static Boolean _SkipIdentifier(Char16*& p)
123 {
124 if (!*p || !(isalpha(*p) || *p == '_'))
125 return false;
126
127 for (p++; *p; p++)
128 {
129 if (!(isalnum(*p) || *p == '_'))
130 return true;
131 }
132
133 return true;
134 }
135
136 static void _MakeNameSpacePath(
137 mike 1.1 const String& root,
138 const String& nameSpace,
139 String& path)
140 {
141 path = root;
142 path.append('/');
143
144 path.append(nameSpace);
145
146 Char16* p = (Char16*)(path.getData() + root.getLength() + 1);
147
148 while (*p)
149 {
150 // Either we will encounter a slash or an identifier:
151
152 if (*p == '/')
153 {
154 if (p[1] == '/')
155 throw CimException(CimException::INVALID_NAMESPACE);
156
157 *p++ = '#';
158 mike 1.1 }
159 else if (!_SkipIdentifier(p))
160 throw CimException(CimException::INVALID_NAMESPACE);
161 }
162
163 // The last element may NOT be a slash (slashes are translated to
164 // #'s above).
165
166 if (p[-1] == '#')
167 throw CimException(CimException::INVALID_NAMESPACE);
168 }
169
170 void _FindClass(
171 const String& root,
172 const String& nameSpace,
173 const String& className,
174 String& path)
175 {
176 const char CLASSES[] = "/classes/";
177 _MakeNameSpacePath(root, nameSpace, path);
178
179 mike 1.1 if (!FileSystem::isDirectory(path))
180 throw CimException(CimException::INVALID_NAMESPACE);
181
182 path.append(CLASSES);
183
184 Array<String> fileNames = _GlobClassesDir(path, className, "*");
185
186 Uint32 size = fileNames.getSize();
187
188 if (size == 0)
189 throw CimException(CimException::INVALID_CLASS);
190
191 PEGASUS_ASSERT(size == 1);
192 path.append(fileNames[0]);
193 }
194
195 inline Uint32 _min(Uint32 x, Uint32 y)
196 {
197 return x < y ? x : y;
198 }
199
200 mike 1.1 static void _MakeNewClassPath(
201 const String& root,
202 const String& nameSpace,
203 const String& className,
204 const String& superClassName,
205 String& path)
206 {
207 const char CLASSES[] = "/classes/";
208 _MakeNameSpacePath(root, nameSpace, path);
209
210 if (!FileSystem::isDirectory(path))
211 throw CimException(CimException::INVALID_NAMESPACE);
212
213 path.append(CLASSES);
214 path.append(className);
215 path.append('.');
216
217 if (superClassName.getLength() == 0)
218 path.append("#");
219 else
220 path.append(superClassName);
221 mike 1.1 }
222
223 static void _MakeQualfierPath(
224 const String& root,
225 const String& nameSpace,
226 const String& qualifierName,
227 String& path)
228 {
229 const char QUALIFIERS[] = "/qualifiers/";
230 _MakeNameSpacePath(root, nameSpace, path);
231
232 if (!FileSystem::isDirectory(path))
233 throw CimException(CimException::INVALID_NAMESPACE);
234
235 path.append('/');
236 path.append(QUALIFIERS);
237 path.append(qualifierName);
238 }
239
240 template<class Object>
241 void _LoadObject(
242 mike 1.1 const String& path,
243 Object& object)
244 {
245 // Open the file:
246
247 Destroyer<char> destroyer(path.allocateCString());
248 std::ifstream is(destroyer.getPointer());
249
250 if (!is)
251 throw CannotOpenFile(path);
252
253 // Load file into memory:
254
255 Array<Sint8> data;
256 FileSystem::loadFileToMemory(data, path);
257 data.append('\0');
258
259 XmlParser parser((char*)data.getData());
260
261 XmlReader::getObject(parser, object);
262 }
263 mike 1.1
264 template<class Object>
265 void _SaveObject(const String& path, Object& object)
266 {
267 Array<Sint8> out;
268 object.toXml(out);
269 out.append('\0');
270
271 Destroyer<char> destroyer(path.allocateCString());
272
273 #ifdef PEGASUS_OS_TYPE_WINDOWS
274 std::ofstream os(destroyer.getPointer(), std::ios::binary);
275 #else
276 std::ofstream os(destroyer.getPointer());
277 #endif
278
279 if (!os)
280 throw CannotOpenFile(path);
281
282 #ifdef INDENT_XML_FILES
283 XmlWriter::indentedPrint(os, out.getData(), 2);
284 mike 1.1 #else
285 os.write((char*)out.getData(), out.getSize());
286 #endif
287 }
288
289 static void _AppendClassNames(
290 const String& path,
291 const String& className,
292 const String& superClassName,
293 Array<String>& classNames)
294 {
295 Array<String> allFiles;
296
297 if (!FileSystem::getDirectoryContents(path, allFiles))
298 throw NoSuchDirectory(path);
299
300 // Append all the direct sublclasses of the class to the output argument:
301
302 Array<String> fileNames =
303 _GlobClassesDir(path, className, superClassName);
304
305 mike 1.1 for (Uint32 i = 0, n = fileNames.getSize(); i < n; i++)
306 {
307 String& tmp = fileNames[i];
308 Uint32 pos = tmp.find('.');
309
310 PEGASUS_ASSERT(pos != Uint32(-1));
311
312 if (pos != Uint32(-1))
313 tmp.remove(pos);
314
315 classNames.append(tmp);
316 }
317 }
318
319 typedef Pair<String,String> Node;
320
321 static void _AppendSubclassesDeepAux(
322 const Array<Node>& table,
323 const String& className,
324 Array<String>& classNames)
325 {
326 mike 1.1 for (Uint32 i = 0, n = table.getSize(); i < n; i++)
327 {
328 if (className == table[i].second)
329 {
330 classNames.append(table[i].first);
331 _AppendSubclassesDeepAux(table, table[i].first, classNames);
332 }
333 }
334 }
335
336 static void _AppendSubclassesDeep(
337 const String& path,
338 const String& className,
339 Array<String>& classNames)
340 {
341 Array<String> allFiles;
342
343 if (!FileSystem::getDirectoryContents(path, allFiles))
344 throw NoSuchDirectory(path);
345
346 Array<Node> table;
347 mike 1.1 table.reserve(allFiles.getSize());
348
349 for (Uint32 i = 0, n = allFiles.getSize(); i < n; i++)
350 {
351 const String& fileName = allFiles[i];
352
353 Uint32 dot = fileName.find('.');
354
355 if (dot == Uint32(-1))
356 continue;
357
358 String first = fileName.subString(0, dot);
359 String second = fileName.subString(dot + 1);
360
361 if (second == "#")
362 table.append(Node(first, String()));
363 else
364 table.append(Node(first, second));
365 }
366
367 _AppendSubclassesDeepAux(table, className, classNames);
368 mike 1.1 }
369
370 static Boolean _HasSubclasses(
371 const String& root,
372 const String& nameSpace,
373 const String& className)
374 {
375 const char CLASSES[] = "/classes";
376 String path;
377 _MakeNameSpacePath(root, nameSpace, path);
378 path.append(CLASSES);
379
380 Array<String> fileNames = _GlobClassesDir(path, "*", className);
381
382 return fileNames.getSize() != 0;
383 }
384
385 ////////////////////////////////////////////////////////////////////////////////
386 //
387 // RepositoryDeclContext
388 //
389 mike 1.1 ////////////////////////////////////////////////////////////////////////////////
390
391 class RepositoryDeclContext : public DeclContext
392 {
393 public:
394
395 RepositoryDeclContext(Repository* repository);
396
397 virtual ~RepositoryDeclContext();
398
399 virtual QualifierDecl lookupQualifierDecl(
400 const String& nameSpace,
401 const String& qualifierName) const;
402
403 virtual ClassDecl lookupClassDecl(
404 const String& nameSpace,
405 const String& className) const;
406
407 private:
408
409 Repository* _repository;
410 mike 1.1 };
411
412 RepositoryDeclContext::RepositoryDeclContext(Repository* repository)
413 : _repository(repository)
414 {
415
416 }
417
418 RepositoryDeclContext::~RepositoryDeclContext()
419 {
420
421 }
422
423 QualifierDecl RepositoryDeclContext::lookupQualifierDecl(
424 const String& nameSpace,
425 const String& qualifierName) const
426 {
427 // Ignore the exception since this routine is only supposed report
428 // whether it can be found:
429
430 try
431 mike 1.1 {
432 return _repository->getQualifier(nameSpace, qualifierName);
433 }
434 catch (Exception&)
435 {
436 return QualifierDecl();
437 }
438 }
439
440 ClassDecl RepositoryDeclContext::lookupClassDecl(
441 const String& nameSpace,
442 const String& className) const
443 {
444 // Ignore the exception since this routine is only supposed report
445 // whether it can be found:
446
447 try
448 {
449 return _repository->getClass(nameSpace, className, false, true, true);
450 }
451 catch (Exception&)
452 mike 1.1 {
453 return ClassDecl();
454 }
455 }
456
457 ////////////////////////////////////////////////////////////////////////////////
458 //
459 // Repository
460 //
461 ////////////////////////////////////////////////////////////////////////////////
462
463 Repository::Repository(const String& path)
464 {
465 const char REPOSITORY[] = "/repository";
466 _root = path;
467 _root.append(REPOSITORY);
468
469 if (!FileSystem::isDirectory(_root))
470 {
471 if (!FileSystem::makeDirectory(_root))
472 throw CannotCreateDirectory(_root);
473 mike 1.1 }
474
475 _context = new RepositoryDeclContext(this);
476 }
477
478 Repository::~Repository()
479 {
480
481 }
482
483 ClassDecl Repository::getClass(
484 const String& nameSpace,
485 const String& className,
486 Boolean localOnly,
487 Boolean includeQualifiers,
488 Boolean includeClassOrigin,
489 const Array<String>& propertyList)
490 {
491 // Form the path to the class:
492
493 String path;
494 mike 1.1 _FindClass(_root, nameSpace, className, path);
495
496 // Load the class:
497
498 ClassDecl classDecl;
499 _LoadObject(path, classDecl);
500
501 return ClassDecl(classDecl);
502 }
503
504 InstanceDecl Repository::getInstance(
505 const String& nameSpace,
506 const Reference& instanceName,
507 Boolean localOnly,
508 Boolean includeQualifiers,
509 Boolean includeClassOrigin,
510 const Array<String>& propertyList)
511 {
512 throw CimException(CimException::NOT_SUPPORTED);
513 return InstanceDecl();
514 }
515 mike 1.1
516 void Repository::deleteClass(
517 const String& nameSpace,
518 const String& className)
519 {
520 // Get path of class file:
521
522 String path;
523 _FindClass(_root, nameSpace, className, path);
524
525 // Disallow if the class has subclasses:
526
527 if (_HasSubclasses(_root, nameSpace, className))
528 throw CimException(CimException::CLASS_HAS_CHILDREN);
529
530 // ATTN-C: check to see if the class has instances:
531
532 // Remove the class:
533
534 if (!FileSystem::removeFile(path))
535 throw FailedToRemoveFile(path);
536 mike 1.1 }
537
538 void Repository::deleteInstance(
539 const String& nameSpace,
540 const Reference& instanceName)
541 {
542 throw CimException(CimException::NOT_SUPPORTED);
543 }
544
545 void Repository::createClass(
546 const String& nameSpace,
547 ClassDecl& newClass)
548 {
549 // Form the path to the class:
550
551 String path;
552 const String& className = newClass.getClassName();
553 const String& superClassName = newClass.getSuperClassName();
554 _MakeNewClassPath(_root, nameSpace, className, superClassName, path);
555
556 if (FileSystem::exists(path))
557 mike 1.1 throw CimException(CimException::ALREADY_EXISTS);
558
559 // Validate the new class:
560
561 newClass.resolve(_context, nameSpace);
562
563 // Save the class:
564
565 _SaveObject(path, newClass);
566 }
567
568 void Repository::createInstance(
569 const String& nameSpace,
570 const InstanceDecl& newInstance)
571 {
572 throw CimException(CimException::NOT_SUPPORTED);
573 }
574
575 void Repository::modifyClass(
576 const String& nameSpace,
577 ClassDecl& modifiedClass)
578 mike 1.1 {
579 // ATTN: need lots of semantic checking here:
580
581 // Get the old class:
582
583 ClassDecl oldClass = getClass(
584 nameSpace, modifiedClass.getClassName(), false, true, true);
585
586 // Disallow changing the name of the super-class:
587
588 if (modifiedClass.getSuperClassName() != oldClass.getSuperClassName())
589 throw CimException(CimException::INVALID_SUPERCLASS);
590
591 // Delete the old class:
592
593 deleteClass(nameSpace, modifiedClass.getClassName());
594
595 // Create the class again:
596
597 createClass(nameSpace, modifiedClass);
598 }
599 mike 1.1
600 void Repository::modifyInstance(
601 const String& nameSpace,
602 const InstanceDecl& modifiedInstance)
603 {
604 throw CimException(CimException::NOT_SUPPORTED);
605 }
606
607 Array<ClassDecl> Repository::enumerateClasses(
608 const String& nameSpace,
609 const String& className,
610 Boolean deepInheritance,
611 Boolean localOnly,
612 Boolean includeQualifiers,
613 Boolean includeClassOrigin)
614 {
615 Array<String> classNames =
616 enumerateClassNames(nameSpace, className, deepInheritance);
617
618 Array<ClassDecl> result;
619
620 mike 1.1 for (Uint32 i = 0; i < classNames.getSize(); i++)
621 {
622 result.append(getClass(nameSpace, classNames[i], localOnly,
623 includeQualifiers, includeClassOrigin));
624 }
625
626 return result;
627 }
628
629 Array<String> Repository::enumerateClassNames(
630 const String& nameSpace,
631 const String& className,
632 Boolean deepInheritance)
633 {
634 // Build the path to the classes directory:
635
636 const char CLASSES[] = "/classes/";
637 String path;
638 _MakeNameSpacePath(_root, nameSpace, path);
639 path.append(CLASSES);
640
641 mike 1.1 if (!FileSystem::isDirectory(path))
642 throw CimException(CimException::INVALID_NAMESPACE);
643
644 if (deepInheritance)
645 {
646 if (className == String::EMPTY)
647 {
648 Array<String> classNames;
649 _AppendSubclassesDeep(path, String(), classNames);
650 return classNames;
651 }
652 else
653 {
654 Array<String> classNames;
655 _AppendSubclassesDeep(path, className, classNames);
656 return classNames;
657 }
658 }
659 else
660 {
661 if (className == String::EMPTY)
662 mike 1.1 {
663 Array<String> classNames;
664 _AppendClassNames(path, "*", "#", classNames);
665 return classNames;
666 }
667 else
668 {
669 Array<String> classNames;
670 _AppendClassNames(path, "*", className, classNames);
671 return classNames;
672 }
673 }
674
675 // Unreachable:
676 return Array<String>();
677 }
678
679 Array<InstanceDecl> Repository::enumerateInstances(
680 const String& nameSpace,
681 const String& className,
682 Boolean deepInheritance,
683 mike 1.1 Boolean localOnly,
684 Boolean includeQualifiers,
685 Boolean includeClassOrigin,
686 const Array<String>& propertyList)
687 {
688 throw CimException(CimException::NOT_SUPPORTED);
689 return Array<InstanceDecl>();
690 }
691
692 Array<String> Repository::enumerateInstanceNames(
693 const String& nameSpace,
694 const String& className)
695 {
696 throw CimException(CimException::NOT_SUPPORTED);
697 return Array<String>();
698 }
699
700 Array<InstanceDecl> Repository::execQuery(
701 const String& queryLanguage,
702 const String& query)
703 {
704 mike 1.1 throw CimException(CimException::NOT_SUPPORTED);
705 return Array<InstanceDecl>();
706 }
707
708 Array<InstanceDecl> Repository::associators(
709 const String& nameSpace,
710 const Reference& objectName,
711 const String& assocClass,
712 const String& resultClass,
713 const String& role,
714 const String& resultRole,
715 Boolean includeQualifiers,
716 Boolean includeClassOrigin,
717 const Array<String>& propertyList)
718 {
719 throw CimException(CimException::NOT_SUPPORTED);
720 return Array<InstanceDecl>();
721 }
722
723 Array<Reference> Repository::associatorNames(
724 const String& nameSpace,
725 mike 1.1 const Reference& objectName,
726 const String& assocClass,
727 const String& resultClass,
728 const String& role,
729 const String& resultRole)
730 {
731 throw CimException(CimException::NOT_SUPPORTED);
732 return Array<Reference>();
733 }
734
735 Array<InstanceDecl> Repository::references(
736 const String& nameSpace,
737 const Reference& objectName,
738 const String& resultClass,
739 const String& role,
740 Boolean includeQualifiers,
741 Boolean includeClassOrigin,
742 const Array<String>& propertyList)
743 {
744 throw CimException(CimException::NOT_SUPPORTED);
745 return Array<InstanceDecl>();
746 mike 1.1 }
747
748 Array<Reference> Repository::referenceNames(
749 const String& nameSpace,
750 const Reference& objectName,
751 const String& resultClass,
752 const String& role)
753 {
754 throw CimException(CimException::NOT_SUPPORTED);
755 return Array<Reference>();
756 }
757
758 Value Repository::getProperty(
759 const String& nameSpace,
760 const Reference& instanceName,
761 const String& propertyName)
762 {
763 throw CimException(CimException::NOT_SUPPORTED);
764 return Value();
765 }
766
767 mike 1.1 void Repository::setProperty(
768 const String& nameSpace,
769 const Reference& instanceName,
770 const String& propertyName,
771 const Value& newValue)
772 {
773 throw CimException(CimException::NOT_SUPPORTED);
774 }
775
776 QualifierDecl Repository::getQualifier(
777 const String& nameSpace,
778 const String& qualifierName)
779 {
780 // Form the path of the qualifier file:
781
782 String path;
783 _MakeQualfierPath(_root, nameSpace, qualifierName, path);
784
785 // If it does not exist:
786
787 if (!FileSystem::exists(path))
788 mike 1.1 throw CimException(CimException::NOT_FOUND);
789
790 // Load the qualifier:
791
792 QualifierDecl qualifierDecl;
793 _LoadObject(path, qualifierDecl);
794
795 return QualifierDecl(qualifierDecl);
796 }
797
798 void Repository::setQualifier(
799 const String& nameSpace,
800 const QualifierDecl& qualifierDecl)
801 {
802 // Form the path of the qualifier:
803
804 String path;
805 _MakeQualfierPath(_root, nameSpace, qualifierDecl.getName(), path);
806
807 // If the qualifier already exists, delete it:
808
809 mike 1.1 if (FileSystem::exists(path))
810 {
811 if (!FileSystem::removeFile(path))
812 throw FailedToRemoveDirectory(path);
813 }
814
815 // Write the qualifier to file:
816
817 _SaveObject(path, qualifierDecl);
818 }
819
820 void Repository::deleteQualifier(
821 const String& nameSpace,
822 const String& qualifierName)
823 {
824 String path;
825 _MakeQualfierPath(_root, nameSpace, qualifierName, path);
826
827 if (!FileSystem::exists(path))
828 throw CimException(CimException::NOT_FOUND);
829
830 mike 1.1 if (!FileSystem::removeFile(path))
831 throw FailedToRemoveFile(path);
832 }
833
834 Array<QualifierDecl> Repository::enumerateQualifiers(
835 const String& nameSpace)
836 {
837 // Build the path to the qualifiers directory:
838
839 const char QUALIFIERS[] = "/qualifiers/";
840 String path;
841 _MakeNameSpacePath(_root, nameSpace, path);
842 path.append(QUALIFIERS);
843
844 if (!FileSystem::isDirectory(path))
845 throw CimException(CimException::INVALID_NAMESPACE);
846
847 // Get the names of the qualifiers:
848
849 Array<String> qualifierNames;
850
851 mike 1.1 if (!FileSystem::getDirectoryContents(path, qualifierNames))
852 throw NoSuchDirectory(path);
853
854 // Load each qualifier into the result array:
855
856 Array<QualifierDecl> result;
857
858 for (Uint32 i = 0, n = qualifierNames.getSize(); i < n; i++)
859 {
860 QualifierDecl tmp = getQualifier(nameSpace, qualifierNames[i]);
861 result.append(tmp);
862 }
863
864 return result;
865 }
866
867 Value Repository::invokeMethod(
868 const String& nameSpace,
869 const Reference& instanceName,
870 const String& methodName,
871 const Array<Value>& inParameters,
872 mike 1.1 Array<Value>& outParameters)
873 {
874 throw CimException(CimException::NOT_SUPPORTED);
875 return Value();
876 }
877
878 ////////////////////////////////////////////////////////////////////////////////
879 //
880 // New methods
881 //
882 ////////////////////////////////////////////////////////////////////////////////
883
884 void Repository::createNameSpace(const String& nameSpace)
885 {
886 String path;
887 _MakeNameSpacePath(_root, nameSpace, path);
888
889 if (FileSystem::exists(path))
890 throw AlreadyExists(nameSpace);
891
892 if (!FileSystem::makeDirectory(path))
893 mike 1.1 throw CannotCreateDirectory(path);
894
895 // Create "./qualifiers" directory:
896
897 String qualifiersDir = path;
898 qualifiersDir.append("/qualifiers");
899
900 if (!FileSystem::makeDirectory(qualifiersDir))
901 throw CannotCreateDirectory(qualifiersDir);
902
903 // Create "./classes" directory:
904
905 String classesDir = path;
906 classesDir.append("/classes");
907
908 if (!FileSystem::makeDirectory(classesDir))
909 throw CannotCreateDirectory(classesDir);
910
911 // Create "./instances" directory:
912
913 String instancesDir = path;
914 mike 1.1 instancesDir.append("/instances");
915
916 if (!FileSystem::makeDirectory(instancesDir))
917 throw CannotCreateDirectory(instancesDir);
918 }
919
920 Array<String> Repository::enumerateNameSpaces() const
921 {
922 Array<String> result;
923
924 if (!FileSystem::getDirectoryContents(_root, result))
925 throw NoSuchDirectory(_root);
926
927 for (Uint32 i = 0, n = result.getSize(); i < n; i++)
928 {
929 const String& tmp = result[i];
930
931 for (Char16* p = (Char16*)tmp.getData(); *p; p++)
932 {
933 if (*p == '#')
934 *p = '/';
935 mike 1.1 }
936 }
937
938 return result;
|
939 mike 1.3 }
940
941 // Recall flavor defaults: TOSUBCLASS | OVERRIDABLE
942
943 void Repository::createMetaQualifiers(const String& nameSpace)
944 {
945 // Qualifier CimType : string = null,
946 // Scope(property, parameter)
947
948 setQualifier(nameSpace, QualifierDecl("cimtype", String(),
949 Scope::PROPERTY | Scope::REFERENCE | Scope::PARAMETER));
950
951 // Qualifier id : sint32 = null,
952 // Scope(any),
953 // Flavor(toinstance)
954
955 setQualifier(nameSpace, QualifierDecl("id", Sint32(0),
956 Scope::ANY,
957 Flavor::TOINSTANCE));
958
959 // Qualifier OctetString : boolean = false, Scope(property)
960 mike 1.3
961 setQualifier(nameSpace, QualifierDecl("octetstring", false,
962 Scope::PROPERTY));
963
964 // Qualifier Abstract : boolean = false,
965 // Scope(class, association, indication),
966 // Flavor(disableoverride, restricted);
967
968 setQualifier(nameSpace, QualifierDecl("abstract", false,
969 Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
970 Flavor::NONE));
971
972 // Qualifier Aggregate : boolean = false,
973 // Scope(reference),
974 // Flavor(disableoverride, tosubclass);
975
976 setQualifier(nameSpace, QualifierDecl("aggregate", false,
977 Scope::REFERENCE, Flavor::TOSUBCLASS));
978
979 // Qualifier Aggregation : boolean = false,
980 // Scope(association),
981 mike 1.3 // Flavor(disableoverride, tosubclass);
982
983 setQualifier(nameSpace, QualifierDecl("aggregation", false,
984 Scope::ASSOCIATION, Flavor::TOSUBCLASS));
985
986 // Qualifier Alias : string = null,
987 // Scope(property, reference, method),
988 // Flavor(translatable);
989
990 setQualifier(nameSpace, QualifierDecl("alias", String(),
991 Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD,
992 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
993
994 // Qualifier ArrayType : string = "Bag",
995 // Scope(property, parameter);
996
997 setQualifier(nameSpace, QualifierDecl("arraytype", "Bag",
998 Scope::PROPERTY | Scope::PARAMETER));
999
1000 // Qualifier Association : boolean = false,
1001 // Scope(class, association),
1002 mike 1.3 // Flavor(disableoverride);
1003
1004 setQualifier(nameSpace, QualifierDecl("association", false,
1005 Scope::CLASS | Scope::ASSOCIATION,
1006 Flavor::TOSUBCLASS));
1007
1008 // Qualifier BitMap : string[],
1009 // Scope(property, method, parameter);
1010
1011 setQualifier(nameSpace, QualifierDecl("bitmap", Array<String>(),
1012 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1013
1014 // Qualifier BitValues : string[],
1015 // Scope(property, method, parameter),
1016 // Flavor(Translatable);
1017
1018 setQualifier(nameSpace, QualifierDecl("bitvalues", Array<String>(),
1019 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
1020 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1021
1022 // Qualifier Counter : boolean = false,
1023 mike 1.3 // Scope(property, method, parameter);
1024
1025 setQualifier(nameSpace, QualifierDecl("counter", false,
1026 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1027
1028 // Qualifier Delete : boolean = false,
1029 // Scope(association, reference);
1030
1031 setQualifier(nameSpace, QualifierDecl("delete", false,
1032 Scope::ASSOCIATION | Scope::REFERENCE));
1033
1034 // Qualifier Description : string = null,
1035 // Scope(any),
1036 // Flavor(translatable);
1037
1038 setQualifier(nameSpace, QualifierDecl("description", String(),
1039 Scope::ANY,
1040 Flavor::TRANSLATABLE));
1041
1042 // Qualifier DisplayName : string = null,
1043 // Scope(any),
1044 mike 1.3 // Flavor(translatable);
1045
1046 setQualifier(nameSpace, QualifierDecl("displayname", String(),
1047 Scope::ANY,
1048 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1049
1050 // Qualifier Expensive : boolean = false,
1051 // Scope(property, reference, method, class, association);
1052
1053 setQualifier(nameSpace, QualifierDecl("expensive", false,
1054 Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::CLASS |
1055 Scope::ASSOCIATION));
1056
1057 // Qualifier Gauge : boolean = false,
1058 // Scope(property, method, parameter);
1059
1060 setQualifier(nameSpace, QualifierDecl("gauge", false,
1061 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1062
1063 // Qualifier Ifdeleted : boolean = false,
1064 // Scope(association, reference);
1065 mike 1.3
1066 setQualifier(nameSpace, QualifierDecl("ifdeleted", false,
1067 Scope::ASSOCIATION | Scope::REFERENCE));
1068
1069 // Qualifier In : boolean = true,
1070 // Scope(parameter),
1071 // Flavor(disableoverride);
1072
1073 setQualifier(nameSpace, QualifierDecl("in", true,
1074 Scope::PARAMETER,
1075 Flavor::TOSUBCLASS));
1076
1077 // Qualifier Indication : boolean = false,
1078 // Scope(class, indication),
1079 // Flavor(disableoverride);
1080
1081 setQualifier(nameSpace, QualifierDecl("indication", false,
1082 Scope::CLASS | Scope::INDICATION,
1083 Flavor::TOSUBCLASS));
1084
1085 // Qualifier Invisible : boolean = false,
1086 mike 1.3 // Scope(reference, association, class, property, method);
1087
1088 setQualifier(nameSpace, QualifierDecl("invisible", false,
1089 Scope::REFERENCE | Scope::ASSOCIATION | Scope::CLASS | Scope::PROPERTY |
1090 Scope::METHOD));
1091
1092 // Qualifier Key : boolean = false,
1093 // Scope(property, reference),
1094 // Flavor(disableoverride);
1095
1096 setQualifier(nameSpace, QualifierDecl("key", false,
1097 Scope::PROPERTY | Scope::REFERENCE,
1098 Flavor::TOSUBCLASS));
1099
1100 // Qualifier Large : boolean = false,
1101 // Scope(property, class);
1102
1103 setQualifier(nameSpace, QualifierDecl("large", false,
1104 Scope::PROPERTY | Scope::CLASS));
1105
1106 // Qualifier MappingStrings : string[],
1107 mike 1.3 // Scope(class, property, association, indication, reference);
1108
1109 setQualifier(nameSpace, QualifierDecl("mappingstrings", Array<String>(),
1110 Scope::CLASS | Scope::PROPERTY | Scope::ASSOCIATION |
1111 Scope::INDICATION | Scope::REFERENCE));
1112
1113 // Qualifier Max : uint32 = null, Scope(reference);
1114
1115 setQualifier(nameSpace, QualifierDecl("max", Sint32(0),
1116 Scope::PROPERTY | Scope::REFERENCE));
1117
1118 // Qualifier MaxLen : uint32 = null,
1119 // Scope(property, method, parameter);
1120
1121 #if 0
1122 setQualifier(nameSpace, QualifierDecl("maxlen", Uint32(0),
1123 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1124 #else
1125 setQualifier(nameSpace, QualifierDecl("maxlen", Sint32(0),
1126 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1127 #endif
1128 mike 1.3
1129 // Qualifier MaxValue : sint64 = null,
1130 // Scope(property, method, parameter);
1131 // ATTN: XML schema requires sint32!
1132
1133 setQualifier(nameSpace, QualifierDecl("maxvalue", Sint32(0),
1134 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1135
1136 // Qualifier Min : sint32 = null, Scope(reference);
1137
1138 setQualifier(nameSpace, QualifierDecl("min", Sint32(0),
1139 Scope::REFERENCE));
1140
1141 // Qualifier MinValue : sint64 = null,
1142 // Scope(property, method, parameter);
1143 // ATTN: Type expected by XML spec is sint32!
1144
1145 setQualifier(nameSpace, QualifierDecl("minvalue", Sint32(0),
1146 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1147
1148 // Qualifier ModelCorrespondence : string[],
1149 mike 1.3 // Scope(property);
1150
1151 setQualifier(nameSpace, QualifierDecl("modelcorrespondence",
1152 Array<String>(),
1153 Scope::PROPERTY));
1154
1155 // Qualifier NonLocal : string = null,
1156 // Scope(reference);
1157
1158 setQualifier(nameSpace, QualifierDecl("nonlocal", String(),
1159 Scope::REFERENCE));
1160
1161 // Qualifier NullValue : string = null,
1162 // Scope(property),
1163 // Flavor(tosubclass, disableoverride);
1164
1165 setQualifier(nameSpace, QualifierDecl("nullvalue", String(),
1166 Scope::PROPERTY,
1167 Flavor::TOSUBCLASS));
1168
1169 // Qualifier Out : boolean = false,
1170 mike 1.3 // Scope(parameter),
1171 // Flavor(disableoverride);
1172
1173 setQualifier(nameSpace, QualifierDecl("out", false,
1174 Scope::PARAMETER,
1175 Flavor::TOSUBCLASS));
1176
1177 // Qualifier Override : string = null,
1178 // Scope(property, method, reference),
1179 // Flavor(disableoverride);
1180
1181 setQualifier(nameSpace, QualifierDecl("override", String(),
1182 Scope::PROPERTY | Scope::METHOD | Scope::REFERENCE,
1183 Flavor::TOSUBCLASS));
1184
1185 // Qualifier Propagated : string = null,
1186 // Scope(property, reference),
1187 // Flavor(disableoverride);
1188
1189 setQualifier(nameSpace, QualifierDecl("propagated", String(),
1190 Scope::PROPERTY | Scope::REFERENCE,
1191 mike 1.3 Flavor::TOSUBCLASS));
1192
1193 // Qualifier Provider : string = null,
1194 // Scope(any);
1195
1196 setQualifier(nameSpace, QualifierDecl("provider", String(),
1197 Scope::ANY));
1198
1199 // Qualifier Read : boolean = true, Scope(property);
1200
1201 setQualifier(nameSpace, QualifierDecl("read", true,
1202 Scope::PROPERTY));
1203
1204 // Qualifier Required : boolean = false,
1205 // Scope(property);
1206
1207 setQualifier(nameSpace, QualifierDecl("required", false,
1208 Scope::PROPERTY));
1209
1210 // Qualifier Revision : string = null,
1211 // Scope(schema, class, association, indication),
1212 mike 1.3 // Flavor(translatable);
1213 // ATTN: No such scope as Scope::SCHEMA
1214
1215 setQualifier(nameSpace, QualifierDecl("revision", String(),
1216 Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
1217 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1218
1219 // Qualifier Schema : string = null,
1220 // Scope(property, method),
1221 // Flavor(disableoverride, translatable);
1222
1223 setQualifier(nameSpace, QualifierDecl("schema", String(),
1224 Scope::PROPERTY | Scope::METHOD,
1225 Flavor::TOSUBCLASS | Flavor::TRANSLATABLE));
1226
1227 // Qualifier Source : string = null,
1228 // Scope(class, association, indication);
1229
1230 setQualifier(nameSpace, QualifierDecl("source", String(),
1231 Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION));
1232
1233 mike 1.3 // Qualifier SourceType : string = null,
1234 // Scope(class, association, indication,reference);
1235
1236 setQualifier(nameSpace, QualifierDecl("sourcetype", String(),
1237 Scope::CLASS | Scope::ASSOCIATION | Scope:: INDICATION |
1238 Scope::REFERENCE));
1239
1240 // Qualifier Static : boolean = false,
1241 // Scope(property, method), Flavor(disableoverride);
1242
1243 setQualifier(nameSpace, QualifierDecl("static", false,
1244 Scope::PROPERTY | Scope::METHOD,
1245 Flavor::TOSUBCLASS));
1246
1247 // Qualifier Syntax : string = null,
1248 // Scope(property, reference, method, parameter);
1249
1250 setQualifier(nameSpace, QualifierDecl("syntax", String(),
1251 Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::PARAMETER));
1252
1253 // Qualifier SyntaxType : string = null,
1254 mike 1.3 // Scope(property, reference, method, parameter);
1255
1256 setQualifier(nameSpace, QualifierDecl("syntaxtype", String(),
1257 Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::PARAMETER));
1258
1259 // Qualifier Terminal : boolean = false,
1260 // Scope(class);
1261
1262 setQualifier(nameSpace, QualifierDecl("terminal", false,
1263 Scope::CLASS));
1264
1265 // Qualifier TriggerType : string = null,
1266 // Scope(class, property, reference, method, association, indication);
1267
1268 setQualifier(nameSpace, QualifierDecl("triggertype", String(),
1269 Scope::CLASS | Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD |
1270 Scope::ASSOCIATION | Scope::INDICATION));
1271
1272 // Qualifier Units : string = null,
1273 // Scope(property, method, parameter),
1274 // Flavor(translatable);
1275 mike 1.3
1276 setQualifier(nameSpace, QualifierDecl("units", String(),
1277 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
1278 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1279
1280 // Qualifier UnknownValues : string[],
1281 // Scope(property),
1282 // Flavor(disableoverride, tosubclass);
1283
1284 setQualifier(nameSpace, QualifierDecl("unknownvalues", Array<String>(),
1285 Scope::PROPERTY,
1286 Flavor::TOSUBCLASS));
1287
1288 // Qualifier UnsupportedValues : string[],
1289 // Scope(property),
1290 // Flavor(disableoverride, tosubclass);
1291
1292 setQualifier(nameSpace, QualifierDecl("unsupportedvalues", Array<String>(),
1293 Scope::PROPERTY,
1294 Flavor::TOSUBCLASS));
1295
1296 mike 1.3 // Qualifier ValueMap : string[],
1297 // Scope(property, method, parameter);
1298
1299 setQualifier(nameSpace, QualifierDecl("valuemap", Array<String>(),
1300 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
1301
1302 // Qualifier Values : string[],
1303 // Scope(property, method, parameter),
1304 // Flavor(translatable);
1305
1306 setQualifier(nameSpace, QualifierDecl("values", Array<String>(),
1307 Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
1308 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1309
1310 // Qualifier Version : string = null,
1311 // Scope(schema, class, association, indication),
1312 // Flavor(translatable);
1313 // ATTN: No such scope as Scope::SCHEMA
1314
1315 setQualifier(nameSpace, QualifierDecl("version", String(),
1316 Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
1317 mike 1.3 Flavor::DEFAULTS | Flavor::TRANSLATABLE));
1318
1319 // Qualifier Weak : boolean = false,
1320 // Scope(reference),
1321 // Flavor(disableoverride, tosubclass);
1322
1323 setQualifier(nameSpace, QualifierDecl("weak", false,
1324 Scope::REFERENCE,
1325 Flavor::TOSUBCLASS));
1326
1327 // Qualifier Write : boolean = false,
1328 // Scope(property);
1329
1330 setQualifier(nameSpace, QualifierDecl("write", false,
1331 Scope::PROPERTY));
|