/* * * Copyright (c) 1996 * Knowledge Science Institute, University of Calgary * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. The Knowledge Science Institute makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * */ #include #include const unsigned long MajorMask = 0xFF000000, MinorMask = 0x00FF0000, PatchMask = 0x0000FF00, PlatformMask = 0x000000FF, VersionMask = 0xFFFFFF00; const int MajorShift = 24, MinorShift = 16, PatchShift = 8, PlatformShift = 0; Version::Version(unsigned char major, unsigned char minor, unsigned char patch, Platform_type platform) { V = (major<<(unsigned long)MajorShift) | (minor<<(unsigned long)MinorShift) | (patch<<(unsigned long)PatchShift) | ((unsigned char)platform); } Version::operator string() { char buf[80]; char* b=buf; b += sprintf(b,"%u.%u",(unsigned int)getMajorVersion(),(unsigned int)getMinorVersion()); unsigned int patch = getPatchVersion(); if (patch) b += sprintf(b,".%u",patch); Platform_type plat = getPlatform(); char* platStr; if (plat!=Unspecified) { switch (plat) { case MacOS: platStr = "Mac OS"; break; case XWindows: platStr = "X Windows"; break; case Motif: platStr = "Motif"; break; case MSWin32: platStr = "MS Windows 32 bit"; break; case MSWin16: platStr = "MS Windows 16 bit"; break; default: platStr = "Unrecognized"; break; } sprintf(b," (%s)",platStr); } return string(buf); } bool Version::operator==(Version v) {return (V&VersionMask)==(v&VersionMask);} bool Version::operator< (Version v) {return (V&VersionMask)< (v&VersionMask);} unsigned char Version::getMajorVersion() {return (unsigned char)(V>>MajorShift);} unsigned char Version::getMinorVersion() {return (unsigned char)(V>>MinorShift);} unsigned char Version::getPatchVersion() {return (unsigned char)(V>>PatchShift);} Version::Platform_type Version::getPlatform() {return (Platform_type)(V&PlatformMask);} unsigned char Version::setMajorVersion(unsigned char x) { unsigned char ret=getMajorVersion(); V &= ~MajorMask; V |= (((unsigned long)x)<