version_record.h

Go to the documentation of this file.
00001 #ifndef VERSION_STRUCTURE_GROUP
00002 #define VERSION_STRUCTURE_GROUP
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : version & version_record                                          *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00024 #include "istring.h"
00025 #include "object_base.h"
00026 #include "packable.h"
00027 
00029 
00035 class version : public packable, public virtual object_base
00036 {
00037 public:
00038   version();  
00039 
00040   version(const string_array &version_info);
00042 
00045   version(const istring &formatted_string);
00047 
00050   version(int major, int minor, int rev = 0, int build = 0);
00052 
00053   version(const version &to_copy);
00055 
00056   virtual ~version();
00057 
00058   version &operator =(const version &to_copy);
00060 
00061   IMPLEMENT_CLASS_NAME("version");
00062 
00063   virtual istring text_form() const;
00064 
00065   bool operator == (const version &to_test) const;
00067 
00070   bool operator < (const version &to_test) const;
00072 
00076   inline bool operator != (const version &to_test) const
00077           { return !(*this == to_test); }
00079 
00081   int components() const;
00083 
00084   istring get_component(int index) const;
00086 
00089   void set_component(int index, const istring &to_set);
00091 
00093   enum version_places { MAJOR, MINOR, REVISION, BUILD };
00095 
00097   enum version_style { DOTS, COMMAS, DETAILED };
00099 
00104   istring flex_text_form(version_style style = DOTS, int including = -1) const;
00106 
00111   static version from_text(const istring &to_convert);
00113 
00114   void pack(byte_array &target) const;
00115   bool unpack(byte_array &source);
00116 
00118 
00119   // the following methods mainly help on win32 platforms, where the version
00120   // components are always simple short integers.  there are only ever four
00121   // of these.  if one adheres to that same scheme on other platforms, then
00122   // these functions may be helpful.  otherwise, with the mixed alphanumeric
00123   // versions one sees on unix, these are not so great.
00124 
00125   int v_major() const;
00127 
00130   int v_minor() const;
00132   int v_revision() const;
00134 
00142   int v_build() const;
00144 
00154   bool compatible(const version &that) const;
00156 
00161   bool bogus() const;
00163 
00165   // end win32 specific methods.
00167 
00168 private:
00169   string_array *_components;  
00170 };
00171 
00173 
00175 
00177 class version_record : public virtual object_base
00178 {
00179 public:
00180   virtual ~version_record();
00181 
00182   IMPLEMENT_CLASS_NAME("version_record");
00183 
00184   istring text_form() const;
00185     // returns a view of the fields in this record. 
00186 
00187   // these describe a particular file:
00188   istring description;  // the purpose of this file.
00189   version file_version;  // the version number for this file.
00190   istring internal_name;  // the internal name of the file.
00191   istring original_name;  // name of file before possible renamings.
00192 
00193   // these describe the project that the file belongs to:
00194   istring product_name;  // the product this file belongs to.
00195   version product_version;  // the version of the product.
00196 
00197   // these describe the creators of the file:
00198   istring company_name;  // name of the company that created the file.
00199 
00200   // legal matters:
00201   istring copyright;  // copyright info for this file.
00202   istring trademarks;  // trademarks related to the file.
00203 
00204   // extra pieces not stored in record (yet).
00205   istring web_address;  // the location of the company on the web.
00206 };
00207 
00208 #endif
00209 

Generated on Sat Aug 30 04:31:43 2008 for HOOPLE Libraries by  doxygen 1.5.1