feisty meow concerns codebase 2.140
version_record.h
Go to the documentation of this file.
1#ifndef VERSION_STRUCTURE_GROUP
2#define VERSION_STRUCTURE_GROUP
3
4/*****************************************************************************\
5* *
6* Name : version & version_record *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 1996-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
24#include "string_array.h"
25
26#include <basis/astring.h>
27#include <basis/contracts.h>
28
29namespace structures {
30
32
38class version : public virtual basis::packable, public virtual basis::orderable
39{
40public:
41 version();
42
43 version(const structures::string_array &version_info);
45
48 version(const basis::astring &formatted_string);
50
53 version(int major, int minor, int rev = 0, int build = 0);
55
56 version(const version &to_copy);
58
59 virtual ~version();
60
61 version &operator =(const version &to_copy);
63
65
66 virtual basis::astring text_form() const;
67
68 bool equal_to(const equalizable &to_test) const;
70
73 bool less_than(const orderable &to_test) const;
75
79 int components() const;
81
82 basis::astring get_component(int index) const;
84
87 void set_component(int index, const basis::astring &to_set);
89
93
97
102 basis::astring flex_text_form(version_style style = DOTS, int including = -1) const;
104
109 static version from_text(const basis::astring &to_convert);
111
112 virtual int packed_size() const;
113 virtual void pack(basis::byte_array &target) const;
114 virtual bool unpack(basis::byte_array &source);
115
117
118 // the following methods mainly help on win32 platforms, where the version
119 // components are always simple short integers. there are only ever four
120 // of these. if one adheres to that same scheme on other platforms, then
121 // these functions may be helpful. otherwise, with the mixed alphanumeric
122 // versions one sees on unix, these are not so great.
123
124 int v_major() const;
126
129 int v_minor() const;
131 int v_revision() const;
133
141 int v_build() const;
143
153 bool compatible(const version &that) const;
155
160 bool bogus() const;
162
165
166 static void *__global_module_handle();
168
171//hmmm: storage here is still missing!
172
173private:
174 structures::string_array *_components;
175};
176
178
180
182class version_record : public virtual basis::root_object
183{
184public:
185 virtual ~version_record();
186
187 DEFINE_CLASS_NAME("version_record");
188
190 // returns a view of the fields in this record.
191
192 // these describe a particular file:
193 basis::astring description; // the purpose of this file.
194 version file_version; // the version number for this file.
195 basis::astring internal_name; // the internal name of the file.
196 basis::astring original_name; // name of file before possible renamings.
197
198 // these describe the project that the file belongs to:
199 basis::astring product_name; // the product this file belongs to.
200 version product_version; // the version of the product.
201
202 // these describe the creators of the file:
203 basis::astring company_name; // name of the company that created the file.
204
205 // legal matters:
206 basis::astring copyright; // copyright info for this file.
207 basis::astring trademarks; // trademarks related to the file.
208
209 // extra pieces not stored in record (yet).
210 basis::astring web_address; // the location of the company on the web.
211};
212
214
215} //namespace.
216
217#endif
218
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
A base for objects that can be alphabetically (lexicographically) ordered.
Definition contracts.h:57
A base class for objects that can pack into an array of bytes.
Definition byte_array.h:87
An array of strings with some additional helpful methods.
Holds all information about a file's versioning.
DEFINE_CLASS_NAME("version_record")
basis::astring text_form() const
Holds a file's version identifier.
virtual basis::astring text_form() const
virtual void pack(basis::byte_array &target) const
Creates a packed form of the packable object in "packed_form".
static version from_text(const basis::astring &to_convert)
returns a version structure parsed from "to_convert".
basis::astring get_component(int index) const
returns the component at the specified index.
int components() const
reports the number of components that make up this version.
virtual int packed_size() const
Estimates the space needed for the packed structure.
void set_component(int index, const basis::astring &to_set)
sets the component at "index" to "to_set".
static void * __global_module_handle()
a static resource required to identify the actual win32 module that this lives in.
bool bogus() const
returns true if the version held here is clearly bogus.
bool equal_to(const equalizable &to_test) const
compares two versions for exact equality.
bool less_than(const orderable &to_test) const
reports if this version is less than "to_test".
int v_minor() const
minor version number.
int v_major() const
major version number.
int v_build() const
build number.
int v_revision() const
revision level.
bool compatible(const version &that) const
returns true if this is compatible with "that" version on win32.
version()
constructs a blank version.
version & operator=(const version &to_copy)
assigns this to the "to_copy".
virtual bool unpack(basis::byte_array &source)
Restores the packable from the "packed_form".
basis::astring flex_text_form(version_style style=DOTS, int including=-1) const
returns a textual form of the version number.
DEFINE_CLASS_NAME("version")
A dynamic container class that holds any kind of object via pointers.
Definition amorph.h:55