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;
60 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"
92 <<
" - bad command line\n"
95 <<
" - cannot load database file(s)\n"
98 <<
" - loaded file has no any class\n"
110 for (std::list<OksAttribute*>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
112 const std::string& attributeName = a1->
get_name();
116 << attributeName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
125 if (!printAttributeDifferences)
128 int localAttrCount = 0;
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";
141 << szTheAttribute <<
"Types differed: \n"
147 << szTheAttribute <<
"Ranges differed: \n"
153 << szTheAttribute <<
"Cardinality differed: \n"
154 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it is: \""
156 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it is: \""
161 << szTheAttribute <<
"Initial Values differed: \n"
167 << szTheAttribute <<
"Descriptions differed: \n"
173 << szTheAttribute <<
"Constraints differed: \n"
175 << szBeNull <<
" in the FILE \"" <<
schemaFile2 << szItCan
185 for (std::list<OksAttribute*>::const_iterator ai = alist->begin(); ai != alist->end(); ++ai) {
187 const std::string& attributeName = a2->
get_name();
190 << attributeName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
200 const char* szRELATIONSHIP =
"RELATIONSHIP ";
206 for (std::list<OksRelationship*>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
208 const std::string& relationshipName = r1->
get_name();
212 << relationshipName <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
219 << relationshipName <<
"\" differed";
220 if (!printRelationshipDifferences)
223 int localAttrCount = 0;
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";
241 << szTheRelationship <<
"Class Types differed: \n"
247 << szTheRelationship <<
"Descriptions differed: \n"
253 << szTheRelationship <<
"Low Cardinality Constraint differed: \n"
254 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it is: \""
259 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it is: \""
267 << szTheRelationship <<
"High Cardinality Constraint differed: \n"
268 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it is: \""
273 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it is: \""
281 << szTheRelationship <<
"Composite Types differed: \n"
283 << (r1->
get_is_composite() ? szComposite : szWeak) << szReference <<
" in the FILE \""
288 << szTheRelationship <<
"Composite Exclusive Types differed: \n"
290 << (r1->
get_is_exclusive() ? szExclusive : szShared) << szReference <<
" in the FILE \""
295 << szTheRelationship <<
"Composite Dependent Types differed: \n"
297 << (r1->
get_is_dependent() ? szDependent : szIndependent) << szReference <<
" in the FILE \""
308 for (std::list<OksRelationship*>::const_iterator ri = rlist->begin(); ri != rlist->end(); ++ri) {
310 const std::string& relationshipName = r2->
get_name();
314 << relationshipName <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
329 for (std::list<OksMethod*>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
331 const std::string& methodName = m1->
get_name();
335 <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
344 if (!printMethodDifferences)
347 int localAttrCount = 0;
348 const char* szTheMethod =
" The Method ";
354 <<
"Description differed: \n"
358 const std::list<OksMethodImplementation*>* m1i = m1->
implementations();
359 const std::list<OksMethodImplementation*>* m2i = m2->
implementations();
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) {
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()) {
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";
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) {
388 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
397 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
406 << szTheMethod <<
"Implementations " << icount <<
" differed: \n"
422 for (std::list<OksMethod*>::const_iterator mi = mlist->begin(); mi != mlist->end(); ++mi) {
424 const std::string& methodName = m2->
get_name();
427 <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
438 bool printAttributeDifferences =
false;
439 bool printRelationshipDifferences =
false;
440 bool printMethodDifferences =
false;
441 bool printSubClasses =
false;
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")) {
465 }
else if (!strcmp(argv[i],
"-v")) {
468 }
else if (argc == (i + 2) && argv[i][0] !=
'-' && argv[i + 1][0] !=
'-') {
472 std::cerr <<
"Unknown parameter: \"" << argv[i] <<
"\"\n\n";
484 const char* szNoClasses =
" No classes were found in \"";
485 const char* szExiting =
", exiting ...\n";
493 if (classes1.empty()) {
494 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile1 <<
"\" database file" << szExiting;
498 if (classes2.empty()) {
499 std::cerr <<
"ERROR:" << szNoClasses <<
schemaFile2 <<
"\" database file" << szExiting;
503 OksClass::Map::const_iterator class_iterator1 = classes1.begin();
504 OksClass::Map::const_iterator class_iterator2 = classes2.begin();
506 std::cout << std::endl;
512 for (; class_iterator1 != classes1.end(); ++class_iterator1) {
513 c1 = class_iterator1->second;
514 const std::string& className = c1->
get_name();
517 std::cout <<
"\n DIFFERENCE " << ++
classDiffsCount <<
". There is no class \"" << className <<
"\" in the \""
523 std::cout <<
"TESTING IN CLASSES \"" << className <<
"\"... ";
533 if ((*c1 != *c2) ==
false) {
534 std::cout <<
" no differences were found\n";
538 std::cout << std::endl
539 <<
" DIFFERENCE " << ++
classDiffsCount <<
'.' <<
" The CLASSES \"" << className <<
"\" differed:\n";
555 <<
" in the FILE \"" <<
schemaFile1 <<
"\" it is: \""
557 <<
" in the FILE \"" <<
schemaFile2 <<
"\" it is: \""
564 const std::string* spn;
567 for (std::list<std::string*>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
571 <<
"\" defined in the \"" <<
schemaFile2 <<
"\" database file.\n";
581 for (std::list<std::string*>::const_iterator spi = slist->begin(); spi != slist->end(); ++spi) {
585 <<
"\" defined in the \"" <<
schemaFile1 <<
"\" database file.\n";
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";
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";
609 std::cout <<
"\nFound " <<
classDiffsCount <<
" differences, exiting...\n";
613 std::cerr <<
"Caught oks exception:\n" << ex << std::endl;
617 catch (std::exception& e) {
618 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
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
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::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
int main(int argc, char *argv[])
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)