SourceForge.net Logo
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PmtVersion Class Reference

Create, maintain and manipulate a version SPmtString for an application. More...

#include <PmtVersion.h>

Collaboration diagram for PmtVersion:

[legend]
List of all members.

Public Types

enum  Utility { Alpha = 0, Beta, Production, Default }

Public Methods

 PmtVersion (SPmtString _version="")
 Contructor which sets version from SPmtString. More...

PmtVersion & setVersion (SPmtString _version="")
 Sets version members from <SPmtString>. More...

PmtVersion & ourVersion ()
 Sets the version memeber from the major, minor, utility, level and remainder members. More...

PmtVersion & nextVersion ()
 Sets the current version to the next version appropriate to the current utility (e.g. 2.0 ---> 2.1, or 2.1-beta22 --> to 2.1-beta23). More...

PmtVersion & nextVersion (Utility _utility)
 Sets the current version to the next version appropriate to the requested utility. More...

const SPmtStringgetVersionStr () const
 Returns the version. More...

void setVersionStr (const SPmtString &ver)
 Sets the version. More...

const unsigned getMajor () const
 Returns the major version. More...

void setMajor (const unsigned major)
 Sets the major version. More...

const unsigned getMinor () const
 Returns the minor version. More...

void setMinor (const unsigned minor)
 Sets the minor version. More...

const Utility getUtility () const
 Returns the utility. More...

void setUtility (const Utility utility)
 Sets the utility. More...

const unsigned getLevel () const
 Returns the test level. More...

void setLevel (const unsigned level)
 Sets the test level. More...

const SPmtStringgetRemainder () const
 Returns the remainder. More...

void setRemainder (const SPmtString &remainder)
 Sets the remainder. More...


Static Public Methods

unsigned getNumber (SPmtString &_version)
 Returns first number found in input SPmtString and strips this number from the referenced SPmtString on return. More...

void getUtility (SPmtString &_version, Utility &_util, unsigned &_test)
 Returns the utility, test level and remainder of the input version <SPmtString>. More...

bool goodVersion (const SPmtString _version)
 Returns true / false depending on the goodness of the version <SPmtString>. More...

int parseVersion (const SPmtString _version, unsigned &_major, unsigned &_minor, Utility &_utility, unsigned &_level, SPmtString &_remainder)
 Breaks the input version SPmtString into its constituant parts and assigns the result to the reference paremeters. More...

SPmtStringmakeVersion (const unsigned _major, const unsigned _minor, const Utility _utility, const unsigned _level, const SPmtString _remainder)
 Returns a version SPmtString made from the input parameters. More...


Static Public Attributes

char * utilityStrings [] = {"alpha", "beta", "production", NULL}

Detailed Description

Create, maintain and manipulate a version SPmtString for an application.

This class was written in order to allow the application writer to define and consistantly maintain a version number for an application. When used in conjuntion with the "release" make target and VersionNumber.hh header which the release target assumes, consistancy can be maintained across various releases of the application.

The concept of an application version SPmtString is enforced by this class. The canonnical version SPmtString has the following parts:

     a major version number
     a minor version number
     a utility level ("alpha", "beta" or "" for production)
a test level for utilities alpha and beta.

Valid Version Strings:

            2.3-alpha3-remainder (alpha utility test level 3)
            1.7-beta             (beta utility testlevel 0 by default)
            3.2                  (production utility)


Member Enumeration Documentation

enum PmtVersion::Utility
 

Enumeration values:
Alpha 
Beta 
Production 
Default 


Constructor & Destructor Documentation

PmtVersion::PmtVersion SPmtString    _version = "" [inline]
 

Contructor which sets version from SPmtString.

Parameters:
_version  String to use to set members


Member Function Documentation

const unsigned PmtVersion::getLevel   const [inline]
 

Returns the test level.

const unsigned PmtVersion::getMajor   const [inline]
 

Returns the major version.

const unsigned PmtVersion::getMinor   const [inline]
 

Returns the minor version.

unsigned PmtVersion::getNumber SPmtString   _version [static]
 

Returns first number found in input SPmtString and strips this number from the referenced SPmtString on return.

Parameters:
_version  properly formatted version SPmtString stripped of number on return
Returns:
unsigned -- first number in input <SPmtString>
Exceptions:
BadVersionError 
Example:
           #include <stream.h>
           #include "PmtVersion.h"
         
           main()
           {
             SPmtString gs = "21.0-beta1-remainer4";
             cout << gs << " ";
         
             unsigned nbr = PmtVersion::getNumber (gs);
         
             cout << nbr << " " << gs << endl;
           }

will produce the following output:

           21.0-beta1-remainer4 21 0-beta1-remainer4

const SPmtString& PmtVersion::getRemainder   const [inline]
 

Returns the remainder.

const Utility PmtVersion::getUtility   const [inline]
 

Returns the utility.

void PmtVersion::getUtility SPmtString   _version,
Utility   _util,
unsigned &    _test
[static]
 

Returns the utility, test level and remainder of the input version <SPmtString>.

Parameters:
_remainder  on input must hold a valid version <SPmtString>
on output will hold the remainder
_util  on output will hold the Utility enum
_test  on output will hold the test level.
Exceptions:
BadVersionError 

const SPmtString& PmtVersion::getVersionStr   const [inline]
 

Returns the version.

bool PmtVersion::goodVersion const SPmtString    _version [static]
 

Returns true / false depending on the goodness of the version <SPmtString>.

Parameters:
_version  version SPmtString to be validated
Returns:
bool true / false depending on the goodness of the version <SPmtString>.

SPmtString & PmtVersion::makeVersion const unsigned    _major,
const unsigned    _minor,
const Utility    _utility,
const unsigned    _level,
const SPmtString    _remainder
[static]
 

Returns a version SPmtString made from the input parameters.

Parameters:
_major  major version number
_minor  minor version number
_utility  alpha, beta or null <SPmtString>
_level  utility level
_remainder  freeform descriptive <SPmtString>
Returns:
version SPmtString of form [major].[minor]-[utility][remainder]</returns>

PmtVersion & PmtVersion::nextVersion Utility    _utility
 

Sets the current version to the next version appropriate to the requested utility.

For example if the current version is 2.0 and utility = beta is requested then the version becomes 2.1-beta1, while if 2.1-beta2 is current and production is requested the version becomes 2.1.

Parameters:
_utility  next version utility level
Exceptions:
InternalError 
BadUtilityError 
Returns:
*this

PmtVersion & PmtVersion::nextVersion  
 

Sets the current version to the next version appropriate to the current utility (e.g. 2.0 ---> 2.1, or 2.1-beta22 --> to 2.1-beta23).

PmtVersion & PmtVersion::ourVersion   [inline]
 

Sets the version memeber from the major, minor, utility, level and remainder members.

int PmtVersion::parseVersion const SPmtString    _version,
unsigned &    _major,
unsigned &    _minor,
Utility   _utility,
unsigned &    _level,
SPmtString   _remainder
[static]
 

Breaks the input version SPmtString into its constituant parts and assigns the result to the reference paremeters.

Parameters:
_version  on input holds the version SPmtString to be parsed
_major  on output holds the major version number
_minor  on output holds the minor version number
_utility  on output holds the utility enum
_level  on output holds the test level number
_remainder  on output holds the remainder <SPmtString>.
Returns:
void

void PmtVersion::setLevel const unsigned    level [inline]
 

Sets the test level.

void PmtVersion::setMajor const unsigned    major [inline]
 

Sets the major version.

void PmtVersion::setMinor const unsigned    minor [inline]
 

Sets the minor version.

void PmtVersion::setRemainder const SPmtString   remainder [inline]
 

Sets the remainder.

void PmtVersion::setUtility const Utility    utility [inline]
 

Sets the utility.

PmtVersion & PmtVersion::setVersion SPmtString    _version = "" [inline]
 

Sets version members from <SPmtString>.

Parameters:
_version  String to set as version
Exceptions:
InternalError 
BadUtilityError 

void PmtVersion::setVersionStr const SPmtString   ver [inline]
 

Sets the version.


Member Data Documentation

char * PmtVersion::utilityStrings = {"alpha", "beta", "production", NULL} [static]
 


The documentation for this class was generated from the following files:
Last Updated: March 12, 2003 (rlr)
Copyright © 2003 Eastman Kodak Company All Rights Reserved.