DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_diff_schema.cxx File Reference
#include <fstream>
#include "oks/attribute.hpp"
#include "oks/class.hpp"
#include "oks/kernel.hpp"
#include "oks/method.hpp"
#include "oks/relationship.hpp"
Include dependency graph for oks_diff_schema.cxx:

Go to the source code of this file.

Enumerations

enum  {
  __Success__ = 0 , __StartOfBadStatus__ = 252 , __BadCommandLine__ , __CannotReadFile__ ,
  __ThereAreNoClasses__
}

Functions

static void ReportSubClasses (OksClass *c)
static void printUsage (std::ostream &s)
static void attributesTest (bool printAttributeDifferences, OksClass *c1, OksClass *c2)
static void relationshipsTest (bool printRelationshipDifferences, OksClass *c1, OksClass *c2)
static void methodsTest (bool printMethodDifferences, OksClass *c1, OksClass *c2)
int main (int argc, char **argv)

Variables

int localDiffsCount
int classDiffsCount
char * schemaFile1 = 0
char * schemaFile2 = 0

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
__Success__ 
__StartOfBadStatus__ 
__BadCommandLine__ 
__CannotReadFile__ 
__ThereAreNoClasses__ 

Definition at line 63 of file oks_diff_schema.cxx.

64{
65 __Success__ = 0,
70};
@ __CannotReadFile__
@ __BadCommandLine__
@ __ThereAreNoClasses__
@ __StartOfBadStatus__
@ __Success__

Function Documentation

◆ attributesTest()

void attributesTest ( bool printAttributeDifferences,
OksClass * c1,
OksClass * c2 )
static

Definition at line 104 of file oks_diff_schema.cxx.

105{
106 const std::list<OksAttribute*>* alist = c1->direct_attributes();
107 OksAttribute *a1, *a2;
108
109 if (alist) {
110 for (std::list<OksAttribute*>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
111 OksAttribute* a1 = *ai;
112 const std::string& attributeName = a1->get_name();
113
114 if (!(a2 = c2->find_attribute(attributeName))) {
115 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no attribute \""
116 << attributeName << "\" defined in the \"" << schemaFile2 << "\" database file.\n";
117
118 continue;
119 }
120
121 if (!(*a1 == *a2)) {
122 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " The ATTRIBUTE \"" << attributeName
123 << "\" differed";
124
125 if (!printAttributeDifferences)
126 std::cout << ".\n";
127 else {
128 int localAttrCount = 0;
129
130 const char* szTheAttribute = " The Attribute ";
131 const char* szMultiValues = "multi-values";
132 const char* szSingleValues = "single-value";
133 const char* szItCan = "\" it can ";
134 const char* szNot = "not ";
135 const char* szBeNull = "be null\n";
136
137 std::cout << ":\n";
138
139 if (a1->get_type() != a2->get_type())
140 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
141 << szTheAttribute << "Types differed: \n"
142 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << a1->get_type() << "\"\n"
143 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << a2->get_type() << "\"\n";
144
145 if (a1->get_range() != a2->get_range())
146 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
147 << szTheAttribute << "Ranges differed: \n"
148 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << a1->get_range() << "\"\n"
149 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << a2->get_range() << "\"\n";
150
151 if (a1->get_is_multi_values() != a2->get_is_multi_values())
152 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
153 << szTheAttribute << "Cardinality differed: \n"
154 << " in the FILE \"" << schemaFile1 << "\" it is: \""
155 << (a1->get_is_multi_values() ? szMultiValues : szSingleValues) << "\"\n"
156 << " in the FILE \"" << schemaFile2 << "\" it is: \""
157 << (a2->get_is_multi_values() ? szMultiValues : szSingleValues) << "\"\n";
158
159 if (a1->get_init_value() != a2->get_init_value())
160 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
161 << szTheAttribute << "Initial Values differed: \n"
162 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << a1->get_init_value() << "\"\n"
163 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << a2->get_init_value() << "\"\n";
164
165 if (a1->get_description() != a2->get_description())
166 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
167 << szTheAttribute << "Descriptions differed: \n"
168 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << a1->get_description() << "\"\n"
169 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << a2->get_description() << "\"\n";
170
171 if (a1->get_is_no_null() != a2->get_is_no_null())
172 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
173 << szTheAttribute << "Constraints differed: \n"
174 << " in the FILE \"" << schemaFile1 << szItCan << (a1->get_is_no_null() ? szNot : "")
175 << szBeNull << " in the FILE \"" << schemaFile2 << szItCan
176 << (a2->get_is_no_null() ? szNot : "") << szBeNull;
177 }
178 }
179 }
180 }
181
182 alist = c2->direct_attributes();
183
184 if (alist) {
185 for (std::list<OksAttribute*>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
186 OksAttribute* a2 = *ai;
187 const std::string& attributeName = a2->get_name();
188 if (!(a1 = c1->find_attribute(attributeName))) {
189 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no attribute \""
190 << attributeName << "\" defined in the \"" << schemaFile1 << "\" database file.\n";
191 continue;
192 }
193 }
194 }
195}
OKS attribute class.
Definition attribute.hpp:94
bool get_is_multi_values() const noexcept
const std::string & get_type() const noexcept
Get attribute string type.
const std::string & get_range() const noexcept
Get attribute range.
const std::string & get_name() const noexcept
out stream operator
const std::string & get_init_value() const noexcept
const std::string & get_description() const noexcept
bool get_is_no_null() const noexcept
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Definition class.cpp:985
const std::list< OksAttribute * > * direct_attributes() const noexcept
Definition class.hpp:474
char * schemaFile1
char * schemaFile2
int classDiffsCount
int localDiffsCount

◆ main()

int main ( int argc,
char ** argv )

Definition at line 436 of file oks_diff_schema.cxx.

437{
438 bool printAttributeDifferences = false;
439 bool printRelationshipDifferences = false;
440 bool printMethodDifferences = false;
441 bool printSubClasses = false;
442
443 if (argc == 1) {
444 printUsage(std::cerr);
445 return __BadCommandLine__;
446 }
447
448 for (int i = 1; i < argc; i++) {
449 if (!strcmp(argv[i], "-a"))
450 printAttributeDifferences = true;
451 else if (!strcmp(argv[i], "-r"))
452 printRelationshipDifferences = true;
453 else if (!strcmp(argv[i], "-m"))
454 printMethodDifferences = true;
455 else if (!strcmp(argv[i], "-sb"))
456 printSubClasses = true;
457 else if (!strcmp(argv[i], "-all")) {
458 printAttributeDifferences = true;
459 printRelationshipDifferences = true;
460 printMethodDifferences = true;
461 printSubClasses = true;
462 } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
463 printUsage(std::cout);
464 return __Success__;
465 } else if (!strcmp(argv[i], "-v")) {
466 std::cout << "OKS kernel version " << OksKernel::GetVersion() << std::endl;
467 return __Success__;
468 } else if (argc == (i + 2) && argv[i][0] != '-' && argv[i + 1][0] != '-') {
469 schemaFile1 = argv[i++];
470 schemaFile2 = argv[i++];
471 } else {
472 std::cerr << "Unknown parameter: \"" << argv[i] << "\"\n\n";
473
474 printUsage(std::cerr);
475 return __BadCommandLine__;
476 }
477 }
478
479 OksKernel kernel1;
480 OksKernel kernel2;
481
482 try {
483
484 const char* szNoClasses = " No classes were found in \"";
485 const char* szExiting = ", exiting ...\n";
486
487 kernel1.load_file(schemaFile1);
488 kernel2.load_file(schemaFile2);
489
490 const OksClass::Map& classes1 = kernel1.classes();
491 const OksClass::Map& classes2 = kernel2.classes();
492
493 if (classes1.empty()) {
494 std::cerr << "ERROR:" << szNoClasses << schemaFile1 << "\" database file" << szExiting;
496 }
497
498 if (classes2.empty()) {
499 std::cerr << "ERROR:" << szNoClasses << schemaFile2 << "\" database file" << szExiting;
501 }
502
503 OksClass::Map::const_iterator class_iterator1 = classes1.begin();
504 OksClass::Map::const_iterator class_iterator2 = classes2.begin();
505
506 std::cout << std::endl;
507
508 classDiffsCount = 0;
509
510 OksClass *c1, *c2;
511
512 for (; class_iterator1 != classes1.end(); ++class_iterator1) {
513 c1 = class_iterator1->second;
514 const std::string& className = c1->get_name();
515
516 if (!(c2 = kernel2.find_class(className))) {
517 std::cout << "\n DIFFERENCE " << ++classDiffsCount << ". There is no class \"" << className << "\" in the \""
518 << schemaFile2 << "\" database file.\n";
519
520 continue;
521 }
522
523 std::cout << "TESTING IN CLASSES \"" << className << "\"... ";
524 std::cout.flush();
525
526 //
527 // Operators '==' and '!=' have completly different implementation:
528 // - operator== is optimised for performance and
529 // checks addresses of classes and their names only
530 // - operator!= checks all class properties
531 //
532
533 if ((*c1 != *c2) == false) {
534 std::cout << " no differences were found\n";
535 continue;
536 }
537
538 std::cout << std::endl
539 << " DIFFERENCE " << ++classDiffsCount << '.' << " The CLASSES \"" << className << "\" differed:\n";
540
541 localDiffsCount = 0;
542
543 attributesTest(printAttributeDifferences, c1, c2);
544 relationshipsTest(printRelationshipDifferences, c1, c2);
545 methodsTest(printMethodDifferences, c1, c2);
546
547 if (c1->get_description() != c2->get_description()) {
548 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " The Class Descriptions differed: \n"
549 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << c1->get_description() << "\"\n"
550 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << c2->get_description() << "\"\n";
551 }
552
553 if (c1->get_is_abstract() != c2->get_is_abstract()) {
554 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " The Class Abstraction differed: \n"
555 << " in the FILE \"" << schemaFile1 << "\" it is: \""
556 << (c1->get_is_abstract() ? "abstract" : "not abstract") << "\"\n"
557 << " in the FILE \"" << schemaFile2 << "\" it is: \""
558 << (c2->get_is_abstract() ? "abstract" : "not abstract") << "\"\n";
559 }
560
561 { /* DIRECT SUPERCLASSES TEST */
562
563 const std::list<std::string*>* slist = c1->direct_super_classes();
564 const std::string* spn;
565
566 if (slist) {
567 for (std::list<std::string*>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
568 spn = *spi;
569 if (!c2->find_super_class(*spn)) {
570 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no SUPERCLASS \"" << *spn
571 << "\" defined in the \"" << schemaFile2 << "\" database file.\n";
572
573 continue;
574 }
575 }
576 }
577
578 slist = c2->direct_super_classes();
579
580 if (slist) {
581 for (std::list<std::string*>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
582 spn = *spi;
583 if (!c1->find_super_class(*spn)) {
584 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no SUPERCLASS \"" << *spn
585 << "\" defined in the \"" << schemaFile1 << "\" database file.\n";
586
587 continue;
588 }
589 }
590 }
591 } /* END OF DIRECT SUPERCLASSES TEST */
592
593 if (printSubClasses) {
594 std::cout << " ALL SUBCLASS(ES) of the CLASS \"" << className << "\"\n";
595 std::cout << " in the FILE \"" << schemaFile1 << "\"\n";
597 std::cout << " in the FILE \"" << schemaFile2 << "\"\n";
599 }
600 }
601
602 for (; class_iterator2 != classes2.end(); ++class_iterator2) {
603 if (!kernel1.find_class(class_iterator2->second->get_name())) {
604 std::cout << "\n DIFFERENCE " << ++classDiffsCount << ". There is no class \""
605 << class_iterator2->second->get_name() << "\" in the \"" << schemaFile1 << "\" database file.\n";
606 }
607 }
608
609 std::cout << "\nFound " << classDiffsCount << " differences, exiting...\n";
610 }
611
612 catch (oks::exception& ex) {
613 std::cerr << "Caught oks exception:\n" << ex << std::endl;
614 return __CannotReadFile__;
615 }
616
617 catch (std::exception& e) {
618 std::cerr << "Caught standard C++ exception: " << e.what() << std::endl;
619 return __CannotReadFile__;
620 }
621
623}
The OKS class.
Definition class.hpp:223
bool get_is_abstract() const noexcept
Definition class.hpp:392
OksClass * find_super_class(const std::string &) const noexcept
Definition class.cpp:708
const std::string & get_name() const noexcept
Definition class.hpp:374
const std::string & get_description() const noexcept
Definition class.hpp:378
const std::list< std::string * > * direct_super_classes() const noexcept
Definition class.hpp:417
std::map< const char *, OksClass *, SortStr > Map
Definition class.hpp:252
Provides interface to the OKS kernel.
Definition kernel.hpp:615
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
Definition kernel.cpp:1625
const OksClass::Map & classes() const
Get classes.
Definition kernel.hpp:1711
static const char * GetVersion()
Get OKS version. The method returns string containing CVS tag and date of OKS build.
Definition kernel.cpp:274
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
Definition kernel.hpp:1754
static void relationshipsTest(bool printRelationshipDifferences, OksClass *c1, OksClass *c2)
static void ReportSubClasses(OksClass *c)
static void methodsTest(bool printMethodDifferences, OksClass *c1, OksClass *c2)
static void attributesTest(bool printAttributeDifferences, OksClass *c1, OksClass *c2)
static void printUsage(std::ostream &s)

◆ methodsTest()

void methodsTest ( bool printMethodDifferences,
OksClass * c1,
OksClass * c2 )
static

Definition at line 323 of file oks_diff_schema.cxx.

324{
325 const std::list<OksMethod*>* mlist = c1->direct_methods();
326 OksMethod *m1, *m2;
327
328 if (mlist) {
329 for (std::list<OksMethod*>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
330 OksMethod* m1 = *mi;
331 const std::string& methodName = m1->get_name();
332
333 if (!(m2 = c2->find_method(methodName))) {
334 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no METHOD \"" << methodName
335 << "\" defined in the \"" << schemaFile2 << "\" database file.\n";
336
337 continue;
338 }
339
340 if (!(*m1 == *m2)) {
341 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " The METHOD \"" << methodName
342 << "\" differed";
343
344 if (!printMethodDifferences)
345 std::cout << ".\n";
346 else {
347 int localAttrCount = 0;
348 const char* szTheMethod = " The Method ";
349
350 std::cout << ":\n";
351
352 if (m1->get_description() != m2->get_description())
353 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount << szTheMethod
354 << "Description differed: \n"
355 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << m1->get_description() << "\"\n"
356 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << m2->get_description() << "\"\n";
357
358 const std::list<OksMethodImplementation*>* m1i = m1->implementations();
359 const std::list<OksMethodImplementation*>* m2i = m2->implementations();
360
361 if (m1i || m2i) {
362 if (m2i == 0) {
363 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount << szTheMethod
364 << "Implementations differed: \n"
365 << " in the FILE \"" << schemaFile1 << "\" it has implementations\n"
366 << " in the FILE \"" << schemaFile2 << "\" it has no implementations\n";
367 } else if (m1i == 0) {
368 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount << szTheMethod
369 << "Implementations differed: \n"
370 << " in the FILE \"" << schemaFile1 << "\" it has no implementations\n"
371 << " in the FILE \"" << schemaFile2 << "\" it has implementations\n";
372 } else if (m1i->size() != m2i->size()) {
373 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount << szTheMethod
374 << "Implementations differed: \n"
375 << " in the FILE \"" << schemaFile1 << "\" it has " << m1i->size() << " implementations\n"
376 << " in the FILE \"" << schemaFile2 << "\" it has " << m2i->size() << " implementations\n";
377 } else {
378 std::list<OksMethodImplementation*>::const_iterator m1it = m1i->begin();
379 std::list<OksMethodImplementation*>::const_iterator m2it = m2i->begin();
380 unsigned int icount = 0;
381 for (; m1it != m1i->end(); ++m1it, ++m2it) {
382 icount++;
383 OksMethodImplementation* i1 = *m1it;
384 OksMethodImplementation* i2 = *m2it;
385
386 if (i1->get_language() != i2->get_language()) {
387 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
388 << szTheMethod << "Implementations " << icount << " differed: \n"
389 << " in the FILE \"" << schemaFile1 << "\" it's language is \"" << i1->get_language()
390 << "\"\n"
391 << " in the FILE \"" << schemaFile2 << "\" it's language is \"" << i2->get_language()
392 << "\"\n";
393 }
394
395 if (i1->get_prototype() != i2->get_prototype()) {
396 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
397 << szTheMethod << "Implementations " << icount << " differed: \n"
398 << " in the FILE \"" << schemaFile1 << "\" it's prototype is \"" << i1->get_prototype()
399 << "\"\n"
400 << " in the FILE \"" << schemaFile2 << "\" it's prototype is \"" << i2->get_prototype()
401 << "\"\n";
402 }
403
404 if (i1->get_body() != i2->get_body()) {
405 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
406 << szTheMethod << "Implementations " << icount << " differed: \n"
407 << " in the FILE \"" << schemaFile1 << "\" it's body is \"" << i1->get_body() << "\"\n"
408 << " in the FILE \"" << schemaFile2 << "\" it's body is \"" << i2->get_body()
409 << "\"\n";
410 }
411 }
412 }
413 }
414 }
415 }
416 }
417 }
418
419 mlist = c2->direct_methods();
420
421 if (mlist) {
422 for (std::list<OksMethod*>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
423 OksMethod* m2 = *mi;
424 const std::string& methodName = m2->get_name();
425 if (!(m1 = c1->find_method(methodName))) {
426 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no METHOD \"" << methodName
427 << "\" defined in the \"" << schemaFile1 << "\" database file.\n";
428
429 continue;
430 }
431 }
432 }
433}
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1302
const std::list< OksMethod * > * direct_methods() const noexcept
Definition class.hpp:671
OKS method implementation class.
Definition method.hpp:39
const std::string & get_body() const noexcept
Definition method.hpp:101
const std::string & get_language() const noexcept
Definition method.hpp:69
const std::string & get_prototype() const noexcept
Definition method.hpp:86
OKS method class.
Definition method.hpp:147
const std::string & get_description() const noexcept
Definition method.hpp:201
const std::list< OksMethodImplementation * > * implementations() const noexcept
Definition method.hpp:215
const std::string & get_name() const noexcept
Definition method.hpp:185

◆ printUsage()

void printUsage ( std::ostream & s)
static

Definition at line 73 of file oks_diff_schema.cxx.

74{
75 s << "Usage: oks_diff_schema [-a] [-r] [-m] [-sb] [-all] [-h | --help] [-v] schema_file1 schema_file2\n"
76 "Options:\n"
77 " -a print details of attribute differences\n"
78 " -r print details of relationship differences\n"
79 " -m print details of method differences\n"
80 " -sb print all sub classes\n"
81 " -all the same as -a -r -m -sb\n"
82 " -v print version\n"
83 " -h | --help print this text\n"
84 "\n"
85 "Description:\n"
86 " Print out differences between two schema files.\n"
87 "\n"
88 "Return Status:\n"
89 " 0 - there are no differences between two schema files\n"
90 " "
92 << " - bad command line\n"
93 " "
95 << " - cannot load database file(s)\n"
96 " "
98 << " - loaded file has no any class\n"
99 " 1.."
100 << __StartOfBadStatus__ << " - number of differences (is limited by the max possible value)\n";
101}

◆ relationshipsTest()

void relationshipsTest ( bool printRelationshipDifferences,
OksClass * c1,
OksClass * c2 )
static

Definition at line 198 of file oks_diff_schema.cxx.

199{
200 const char* szRELATIONSHIP = "RELATIONSHIP ";
201
202 const std::list<OksRelationship*>* rlist = c1->direct_relationships();
203 OksRelationship *r1, *r2;
204
205 if (rlist) {
206 for (std::list<OksRelationship*>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
207 OksRelationship* r1 = *ri;
208 const std::string& relationshipName = r1->get_name();
209
210 if (!(r2 = c2->find_relationship(relationshipName))) {
211 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no " << szRELATIONSHIP << "\""
212 << relationshipName << "\" defined in the \"" << schemaFile2 << "\" database file.\n";
213
214 continue;
215 }
216
217 if (!(*r1 == *r2)) {
218 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " The " << szRELATIONSHIP << "\""
219 << relationshipName << "\" differed";
220 if (!printRelationshipDifferences)
221 std::cout << ".\n";
222 else {
223 int localAttrCount = 0;
224
225 const char* szTheRelationship = " The Relationship ";
226 const char* szReference = " reference\n";
227 const char* szZero = "Zero";
228 const char* szOne = "One";
229 const char* szMany = "Many";
230 const char* szComposite = "composite";
231 const char* szWeak = "weak";
232 const char* szExclusive = "exclusive";
233 const char* szShared = "shared";
234 const char* szDependent = "dependent";
235 const char* szIndependent = "independent";
236
237 std::cout << ":\n";
238
239 if (r1->get_type() != r2->get_type())
240 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
241 << szTheRelationship << "Class Types differed: \n"
242 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << r1->get_type() << "\"\n"
243 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << r2->get_type() << "\"\n";
244
245 if (r1->get_description() != r2->get_description())
246 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
247 << szTheRelationship << "Descriptions differed: \n"
248 << " in the FILE \"" << schemaFile1 << "\" it is: \"" << r1->get_description() << "\"\n"
249 << " in the FILE \"" << schemaFile2 << "\" it is: \"" << r2->get_description() << "\"\n";
250
252 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
253 << szTheRelationship << "Low Cardinality Constraint differed: \n"
254 << " in the FILE \"" << schemaFile1 << "\" it is: \""
256 ? szZero
257 : (r1->get_low_cardinality_constraint() == OksRelationship::One ? szOne : szMany))
258 << "\"\n"
259 << " in the FILE \"" << schemaFile2 << "\" it is: \""
261 ? szZero
262 : (r2->get_low_cardinality_constraint() == OksRelationship::One ? szOne : szMany))
263 << "\"\n";
264
266 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
267 << szTheRelationship << "High Cardinality Constraint differed: \n"
268 << " in the FILE \"" << schemaFile1 << "\" it is: \""
270 ? szZero
271 : (r1->get_high_cardinality_constraint() == OksRelationship::One ? szOne : szMany))
272 << "\"\n"
273 << " in the FILE \"" << schemaFile2 << "\" it is: \""
275 ? szZero
276 : (r2->get_high_cardinality_constraint() == OksRelationship::One ? szOne : szMany))
277 << "\"\n";
278
279 if (r1->get_is_composite() != r2->get_is_composite())
280 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
281 << szTheRelationship << "Composite Types differed: \n"
282 << " in the FILE \"" << schemaFile1 << "\" it is "
283 << (r1->get_is_composite() ? szComposite : szWeak) << szReference << " in the FILE \""
284 << schemaFile2 << "\" it is " << (r2->get_is_composite() ? szComposite : szWeak) << szReference;
285
286 if (r1->get_is_exclusive() != r2->get_is_exclusive())
287 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
288 << szTheRelationship << "Composite Exclusive Types differed: \n"
289 << " in the FILE \"" << schemaFile1 << "\" it is "
290 << (r1->get_is_exclusive() ? szExclusive : szShared) << szReference << " in the FILE \""
291 << schemaFile2 << "\" it is " << (r2->get_is_exclusive() ? szExclusive : szShared) << szReference;
292
293 if (r1->get_is_dependent() != r2->get_is_dependent())
294 std::cout << " " << classDiffsCount << '.' << localDiffsCount << '.' << ++localAttrCount
295 << szTheRelationship << "Composite Dependent Types differed: \n"
296 << " in the FILE \"" << schemaFile1 << "\" it is "
297 << (r1->get_is_dependent() ? szDependent : szIndependent) << szReference << " in the FILE \""
298 << schemaFile2 << "\" it is " << (r2->get_is_dependent() ? szDependent : szIndependent)
299 << szReference;
300 }
301 }
302 }
303 }
304
305 rlist = c2->direct_relationships();
306
307 if (rlist) {
308 for (std::list<OksRelationship*>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
309 OksRelationship* r2 = *ri;
310 const std::string& relationshipName = r2->get_name();
311
312 if (!(r1 = c1->find_relationship(relationshipName))) {
313 std::cout << " " << classDiffsCount << '.' << ++localDiffsCount << " There is no " << szRELATIONSHIP << "\""
314 << relationshipName << "\" defined in the \"" << schemaFile1 << "\" database file.\n";
315
316 continue;
317 }
318 }
319 }
320}
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
Definition class.cpp:1142
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:572
bool get_is_exclusive() const noexcept
bool get_is_composite() const noexcept
bool get_is_dependent() const noexcept
const std::string & get_name() const noexcept
CardinalityConstraint get_high_cardinality_constraint() const noexcept
Get relationship high cardinality constraint.
const std::string & get_description() const noexcept
CardinalityConstraint get_low_cardinality_constraint() const noexcept
Get relationship low cardinality constraint.
const std::string & get_type() const noexcept

◆ ReportSubClasses()

void ReportSubClasses ( OksClass * c)
static

Definition at line 52 of file oks_diff_schema.cxx.

53{
54 const OksClass::FList* clist = c->all_sub_classes();
55
56 if (clist && !clist->empty()) {
57 for (OksClass::FList::const_iterator i = clist->begin(); i != clist->end(); ++i)
58 std::cout << " " << (*i)->get_name() << std::endl;
59 } else
60 std::cout << " no subclasses\n";
61}
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:254

Variable Documentation

◆ classDiffsCount

int classDiffsCount

Definition at line 47 of file oks_diff_schema.cxx.

◆ localDiffsCount

int localDiffsCount

Definition at line 46 of file oks_diff_schema.cxx.

◆ schemaFile1

char* schemaFile1 = 0

Definition at line 48 of file oks_diff_schema.cxx.

◆ schemaFile2

char* schemaFile2 = 0

Definition at line 49 of file oks_diff_schema.cxx.