51 if(clist && !clist->empty()) {
52 for(OksClass::FList::const_iterator i = clist->begin(); i != clist->end(); ++i)
53 std::cout <<
" " << (*i)->get_name() << std::endl;
56 std::cout <<
" no subclasses\n";
68 s <<
"Usage: oks_diff_schema [-a] [-r] [-m] [-sb] [-all] [-h | --help] [-v] schema_file1 schema_file2\n"
70 " -a print details of attribute differences\n"
71 " -r print details of relationship differences\n"
72 " -m print details of method differences\n"
73 " -sb print all sub classes\n"
74 " -all the same as -a -r -m -sb\n"
76 " -h | --help print this text\n"
79 " Print out differences between two schema files.\n"
82 " 0 - there are no differences between two schema files\n"
86 " 1.." <<
__StartOfBadStatus__ <<
" - number of differences (is limited by the max possible value)\n";
97 for(std::list<OksAttribute *>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
99 const std::string& attributeName = a1->
get_name();
103 <<
" There is no attribute \"" << attributeName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
110 <<
" The ATTRIBUTE \"" << attributeName <<
"\" differed";
112 if(!printAttributeDifferences)
115 int localAttrCount = 0;
117 const char * szTheAttribute =
" The Attribute ";
118 const char * szMultiValues =
"multi-values";
119 const char * szSingleValues =
"single-value";
120 const char * szItCan =
"\" it can ";
121 const char * szNot =
"not ";
122 const char * szBeNull =
"be null\n";
128 << szTheAttribute <<
"Types differed: \n"
134 << szTheAttribute <<
"Ranges differed: \n"
140 << szTheAttribute <<
"Cardinality differed: \n"
146 << szTheAttribute <<
"Initial Values differed: \n"
152 << szTheAttribute <<
"Descriptions differed: \n"
158 << szTheAttribute <<
"Constraints differed: \n"
169 for(std::list<OksAttribute *>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
171 const std::string & attributeName = a2->
get_name();
174 <<
" There is no attribute \"" << attributeName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
185 const char *szRELATIONSHIP =
"RELATIONSHIP ";
191 for(std::list<OksRelationship *>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
193 const std::string & relationshipName = r1->
get_name();
197 <<
" There is no " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n" ;
204 <<
" The " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" differed";
205 if(!printRelationshipDifferences)
208 int localAttrCount = 0;
210 const char * szTheRelationship =
" The Relationship ";
211 const char * szReference =
" reference\n";
212 const char * szZero =
"Zero";
213 const char * szOne =
"One";
214 const char * szMany =
"Many";
215 const char * szComposite =
"composite";
216 const char * szWeak =
"weak";
217 const char * szExclusive =
"exclusive";
218 const char * szShared =
"shared";
219 const char * szDependent =
"dependent";
220 const char * szIndependent =
"independent";
227 << szTheRelationship <<
"Class Types differed: \n"
233 << szTheRelationship <<
"Descriptions differed: \n"
239 << szTheRelationship <<
"Low Cardinality Constraint differed: \n"
245 << szTheRelationship <<
"High Cardinality Constraint differed: \n"
251 << szTheRelationship <<
"Composite Types differed: \n"
257 << szTheRelationship <<
"Composite Exclusive Types differed: \n"
263 << szTheRelationship <<
"Composite Dependent Types differed: \n"
275 for(std::list<OksRelationship *>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
277 const std::string & relationshipName = r2->
get_name();
281 <<
" There is no " << szRELATIONSHIP <<
"\"" << relationshipName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
297 for(std::list<OksMethod *>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
299 const std::string & methodName = m1->
get_name();
303 <<
" There is no METHOD \"" << methodName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
310 <<
" The METHOD \"" << methodName <<
"\" differed";
312 if(!printMethodDifferences)
315 int localAttrCount = 0;
316 const char * szTheMethod =
" The Method ";
322 << szTheMethod <<
"Description differed: \n"
327 const std::list<OksMethodImplementation *> * m1i = m1->
implementations();
328 const std::list<OksMethodImplementation *> * m2i = m2->
implementations();
333 << szTheMethod <<
"Implementations differed: \n"
334 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has implementations\n"
335 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has no implementations\n";
339 << szTheMethod <<
"Implementations differed: \n"
340 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has no implementations\n"
341 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has implementations\n";
343 else if(m1i->size() != m2i->size()) {
345 << szTheMethod <<
"Implementations differed: \n"
346 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it has " << m1i->size() <<
" implementations\n"
347 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it has " << m2i->size() <<
" implementations\n";
350 std::list<OksMethodImplementation *>::const_iterator m1it = m1i->begin();
351 std::list<OksMethodImplementation *>::const_iterator m2it = m2i->begin();
352 unsigned int icount = 0;
353 for(;m1it != m1i->end(); ++m1it, ++m2it) {
360 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
368 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
376 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
393 for(std::list<OksMethod *>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
395 const std::string & methodName = m2->
get_name();
398 <<
" There is no METHOD \"" << methodName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
409 bool printAttributeDifferences =
false;
410 bool printRelationshipDifferences =
false;
411 bool printMethodDifferences =
false;
412 bool printSubClasses =
false;
419 for(
int i = 1; i < argc; i++) {
420 if(!strcmp(argv[i],
"-a"))
421 printAttributeDifferences =
true;
422 else if(!strcmp(argv[i],
"-r"))
423 printRelationshipDifferences =
true;
424 else if(!strcmp(argv[i],
"-m"))
425 printMethodDifferences =
true;
426 else if(!strcmp(argv[i],
"-sb"))
427 printSubClasses =
true;
428 else if(!strcmp(argv[i],
"-all")) {
429 printAttributeDifferences =
true;
430 printRelationshipDifferences =
true;
431 printMethodDifferences =
true;
432 printSubClasses =
true;
434 else if(!strcmp(argv[i],
"-h") || !strcmp(argv[i],
"--help")) {
438 else if(!strcmp(argv[i],
"-v")) {
442 else if(argc == (i + 2) && argv[i][0] !=
'-' && argv[i+1][0] !=
'-') {
447 std::cerr <<
"Unknown parameter: \"" << argv[i] <<
"\"\n\n";
460 const char *szNoClasses =
" No classes were found in \"";
461 const char *szExiting =
", exiting ...\n";
469 if(classes1.empty()) {
470 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile1 <<
"\" database file" << szExiting;
474 if(classes2.empty()) {
475 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile2 <<
"\" database file" << szExiting;
479 OksClass::Map::const_iterator class_iterator1 = classes1.begin();
480 OksClass::Map::const_iterator class_iterator2 = classes2.begin();
482 std::cout << std::endl;
489 for(;class_iterator1 != classes1.end();++class_iterator1) {
490 c1 = class_iterator1->second;
491 const std::string& className = c1->
get_name();
494 std::cout <<
"\n DIFFERENCE " << ++
classDiffsCount <<
". There is no class \"" << className <<
"\" in the \"" <<
schemaFile2 <<
"\" database file.\n";
499 std::cout <<
"TESTING IN CLASSES \"" << className <<
"\"... ";
510 if((*c1 != *c2) ==
false) {
511 std::cout <<
" no differences were found\n";
516 <<
" The CLASSES \"" << className <<
"\" differed:\n";
526 <<
" The Class Descriptions differed: \n"
533 <<
" The Class Abstraction differed: \n"
542 const std::string *spn;
545 for(std::list<std::string *>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
549 <<
" There is no SUPERCLASS \"" << *spn <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
559 for(std::list<std::string *>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
563 <<
" There is no SUPERCLASS \"" << *spn <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
572 if(printSubClasses) {
573 std::cout <<
" ALL SUBCLASS(ES) of the CLASS \"" << className <<
"\"\n";
579 for(;class_iterator2 != classes2.end();++class_iterator2) {
580 if(!kernel1.
find_class(class_iterator2->second->get_name())) {
581 std::cout <<
"\n DIFFERENCE " << ++
classDiffsCount <<
". There is no class \"" << class_iterator2->second->get_name() <<
"\" in the \"" <<
schemaFile1 <<
"\" database file.\n";
585 std::cout <<
"\nFound " <<
classDiffsCount <<
" differences, exiting...\n";
589 std::cerr <<
"Caught oks exception:\n" << ex << std::endl;
593 catch (std::exception & e) {
594 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).
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
const std::list< OksAttribute * > * direct_attributes() const noexcept
const std::list< std::string * > * direct_super_classes() const noexcept
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
std::map< const char *, OksClass *, SortStr > Map
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)