58 if(clist && !clist->empty()) {
59 for(OksClass::FList::const_iterator i = clist->begin(); i != clist->end(); ++i)
60 std::cout <<
" " << (*i)->get_name() << std::endl;
63 std::cout <<
" no subclasses\n";
75 s <<
"Usage: oks_diff_schema [-a] [-r] [-m] [-sb] [-all] [-h | --help] [-v] schema_file1 schema_file2\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"
83 " -h | --help print this text\n"
86 " Print out differences between two schema files.\n"
89 " 0 - there are no differences between two schema files\n"
93 " 1.." <<
__StartOfBadStatus__ <<
" - number of differences (is limited by the max possible value)\n";
104 for(std::list<OksAttribute *>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
106 const std::string& attributeName = a1->
get_name();
110 <<
" There is no attribute \"" << attributeName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
117 <<
" The ATTRIBUTE \"" << attributeName <<
"\" differed";
119 if(!printAttributeDifferences)
122 int localAttrCount = 0;
124 const char * szTheAttribute =
" The Attribute ";
125 const char * szMultiValues =
"multi-values";
126 const char * szSingleValues =
"single-value";
127 const char * szItCan =
"\" it can ";
128 const char * szNot =
"not ";
129 const char * szBeNull =
"be null\n";
135 << szTheAttribute <<
"Types differed: \n"
141 << szTheAttribute <<
"Ranges differed: \n"
147 << szTheAttribute <<
"Cardinality differed: \n"
153 << szTheAttribute <<
"Initial Values differed: \n"
159 << szTheAttribute <<
"Descriptions differed: \n"
165 << szTheAttribute <<
"Constraints differed: \n"
176 for(std::list<OksAttribute *>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
178 const std::string & attributeName = a2->
get_name();
181 <<
" There is no attribute \"" << attributeName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
192 const char *szRELATIONSHIP =
"RELATIONSHIP ";
198 for(std::list<OksRelationship *>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
200 const std::string & relationshipName = r1->
get_name();
204 <<
" There is no " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n" ;
211 <<
" The " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" differed";
212 if(!printRelationshipDifferences)
215 int localAttrCount = 0;
217 const char * szTheRelationship =
" The Relationship ";
218 const char * szReference =
" reference\n";
219 const char * szZero =
"Zero";
220 const char * szOne =
"One";
221 const char * szMany =
"Many";
222 const char * szComposite =
"composite";
223 const char * szWeak =
"weak";
224 const char * szExclusive =
"exclusive";
225 const char * szShared =
"shared";
226 const char * szDependent =
"dependent";
227 const char * szIndependent =
"independent";
234 << szTheRelationship <<
"Class Types differed: \n"
240 << szTheRelationship <<
"Descriptions differed: \n"
246 << szTheRelationship <<
"Low Cardinality Constraint differed: \n"
252 << szTheRelationship <<
"High Cardinality Constraint differed: \n"
258 << szTheRelationship <<
"Composite Types differed: \n"
264 << szTheRelationship <<
"Composite Exclusive Types differed: \n"
270 << szTheRelationship <<
"Composite Dependent Types differed: \n"
282 for(std::list<OksRelationship *>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
284 const std::string & relationshipName = r2->
get_name();
288 <<
" There is no " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
304 for(std::list<OksMethod *>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
306 const std::string & methodName = m1->
get_name();
310 <<
" There is no METHOD \"" << methodName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
317 <<
" The METHOD \"" << methodName <<
"\" differed";
319 if(!printMethodDifferences)
322 int localAttrCount = 0;
323 const char * szTheMethod =
" The Method ";
329 << szTheMethod <<
"Description differed: \n"
334 const std::list<OksMethodImplementation *> * m1i = m1->
implementations();
335 const std::list<OksMethodImplementation *> * m2i = m2->
implementations();
340 << szTheMethod <<
"Implementations differed: \n"
341 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has implementations\n"
342 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has no implementations\n";
346 << szTheMethod <<
"Implementations differed: \n"
347 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has no implementations\n"
348 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has implementations\n";
350 else if(m1i->size() != m2i->size()) {
352 << szTheMethod <<
"Implementations differed: \n"
353 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has " << m1i->size() <<
" implementations\n"
354 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has " << m2i->size() <<
" implementations\n";
357 std::list<OksMethodImplementation *>::const_iterator m1it = m1i->begin();
358 std::list<OksMethodImplementation *>::const_iterator m2it = m2i->begin();
359 unsigned int icount = 0;
360 for(;m1it != m1i->end(); ++m1it, ++m2it) {
367 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
375 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
383 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
400 for(std::list<OksMethod *>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
402 const std::string & methodName = m2->
get_name();
405 <<
" There is no METHOD \"" << methodName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
416 bool printAttributeDifferences =
false;
417 bool printRelationshipDifferences =
false;
418 bool printMethodDifferences =
false;
419 bool printSubClasses =
false;
426 for(
int i = 1; i < argc; i++) {
427 if(!strcmp(argv[i],
"-a"))
428 printAttributeDifferences =
true;
429 else if(!strcmp(argv[i],
"-r"))
430 printRelationshipDifferences =
true;
431 else if(!strcmp(argv[i],
"-m"))
432 printMethodDifferences =
true;
433 else if(!strcmp(argv[i],
"-sb"))
434 printSubClasses =
true;
435 else if(!strcmp(argv[i],
"-all")) {
436 printAttributeDifferences =
true;
437 printRelationshipDifferences =
true;
438 printMethodDifferences =
true;
439 printSubClasses =
true;
441 else if(!strcmp(argv[i],
"-h") || !strcmp(argv[i],
"--help")) {
445 else if(!strcmp(argv[i],
"-v")) {
449 else if(argc == (i + 2) && argv[i][0] !=
'-' && argv[i+1][0] !=
'-') {
454 std::cerr <<
"Unknown parameter: \"" << argv[i] <<
"\"\n\n";
467 const char *szNoClasses =
" No classes were found in \"";
468 const char *szExiting =
", exiting ...\n";
476 if(classes1.empty()) {
477 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile1 <<
"\" database file" << szExiting;
481 if(classes2.empty()) {
482 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile2 <<
"\" database file" << szExiting;
486 OksClass::Map::const_iterator class_iterator1 = classes1.begin();
487 OksClass::Map::const_iterator class_iterator2 = classes2.begin();
489 std::cout << std::endl;
496 for(;class_iterator1 != classes1.end();++class_iterator1) {
497 c1 = class_iterator1->second;
498 const std::string& className = c1->
get_name();
501 std::cout <<
"\n DIFFERENCE " << ++
classDiffsCount <<
". There is no class \"" << className <<
"\" in the \"" <<
schemaFile2 <<
"\" database file.\n";
506 std::cout <<
"TESTING IN CLASSES \"" << className <<
"\"... ";
517 if((*c1 != *c2) ==
false) {
518 std::cout <<
" no differences were found\n";
523 <<
" The CLASSES \"" << className <<
"\" differed:\n";
533 <<
" The Class Descriptions differed: \n"
540 <<
" The Class Abstraction differed: \n"
549 const std::string *spn;
552 for(std::list<std::string *>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
556 <<
" There is no SUPERCLASS \"" << *spn <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
566 for(std::list<std::string *>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
570 <<
" There is no SUPERCLASS \"" << *spn <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
579 if(printSubClasses) {
580 std::cout <<
" ALL SUBCLASS(ES) of the CLASS \"" << className <<
"\"\n";
586 for(;class_iterator2 != classes2.end();++class_iterator2) {
587 if(!kernel1.
find_class(class_iterator2->second->get_name())) {
588 std::cout <<
"\n DIFFERENCE " << ++
classDiffsCount <<
". There is no class \"" << class_iterator2->second->get_name() <<
"\" in the \"" <<
schemaFile1 <<
"\" database file.\n";
592 std::cout <<
"\nFound " <<
classDiffsCount <<
" differences, exiting...\n";
596 std::cerr <<
"Caught oks exception:\n" << ex << std::endl;
600 catch (std::exception & e) {
601 std::cerr <<
"Caught standard C++ exception: " << e.what() << std::endl;
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
bool get_is_abstract() const noexcept
OksClass * find_super_class(const std::string &) const noexcept
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
const std::string & get_name() const noexcept
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
const std::list< OksRelationship * > * direct_relationships() const noexcept
const std::string & get_description() const noexcept
const std::list< OksMethod * > * direct_methods() const noexcept
std::map< const char *, OksClass *, SortStr > Map
const std::list< OksAttribute * > * direct_attributes() const noexcept
const std::list< std::string * > * direct_super_classes() const noexcept
Provides interface to the OKS kernel.
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
const OksClass::Map & classes() const
Get classes.
static const char * GetVersion()
Get OKS version. The method returns string containing CVS tag and date of OKS build.
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
OKS method implementation class.
const std::string & get_body() const noexcept
const std::string & get_language() const noexcept
const std::string & get_prototype() const noexcept
const std::string & get_description() const noexcept
const std::list< OksMethodImplementation * > * implementations() const noexcept
const std::string & get_name() const noexcept
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
static void relationshipsTest(bool printRelationshipDifferences, OksClass *c1, OksClass *c2)
static void ReportSubClasses(OksClass *c)
int main(int argc, char **argv)
static void methodsTest(bool printMethodDifferences, OksClass *c1, OksClass *c2)
static void attributesTest(bool printAttributeDifferences, OksClass *c1, OksClass *c2)
static void printUsage(std::ostream &s)