feisty meow concerns codebase  2.140
version_checker.h
Go to the documentation of this file.
1 #ifndef VERSION_CHECKER_CLASS
2 #define VERSION_CHECKER_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : check_version *
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 
18 #include <basis/astring.h>
19 #include <basis/contracts.h>
21 
22 namespace versions {
23 
25 
26 class version_checker : public virtual basis::root_object
27 {
28 public:
29  version_checker(const basis::astring &library_file_name, const structures::version &expected,
30  const basis::astring &version_complaint);
32 
47  virtual ~version_checker();
48 
49  bool good_version() const;
51 
56  static basis::astring module_name(const void *module_handle);
58 
59  // base requirements.
60  DEFINE_CLASS_NAME("version_checker");
61  basis::astring text_form() const;
62 
63  static bool loaded(const basis::astring &library_file_name);
65  static void *get_handle(const basis::astring &library_file_name);
67 
69  static basis::astring get_name(const void *to_find);
71 
73  static structures::version retrieve_version(const basis::astring &pathname);
75 
78  static bool get_record(const basis::astring &pathname, structures::version_record &to_fill);
80 
86  static bool retrieve_version_info(const basis::astring &filename,
87  basis::byte_array &to_fill);
89 
90  static bool get_language(basis::byte_array &version_chunk, basis::un_short &high,
91  basis::un_short &low);
93 
96  void complain_wrong_version(const basis::astring &library_file_name,
97  const structures::version &expected_version,
98  const structures::version &version_found) const;
100 
101  void complain_cannot_load(const basis::astring &library_file_name) const;
103 
104 private:
105  basis::astring *_library_file_name;
106  structures::version *_expected_version;
107  basis::astring *_version_complaint;
108 
109  // forbidden.
111  version_checker &operator =(const version_checker &);
112 };
113 
114 } //namespace.
115 
116 #endif
117 
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
Holds all information about a file's versioning.
Holds a file's version identifier.
Provides version checking for shared libraries.
void complain_cannot_load(const basis::astring &library_file_name) const
Reports that the dll could not be loaded.
bool good_version() const
Performs the actual version check.
virtual ~version_checker()
Destructor releases any resources.
static bool get_record(const basis::astring &pathname, structures::version_record &to_fill)
Retrieves a version record for the file at "pathname".
static bool retrieve_version_info(const basis::astring &filename, basis::byte_array &to_fill)
Retrieves the version info for the "filename" into the array "to_fill".
static bool get_language(basis::byte_array &version_chunk, basis::un_short &high, basis::un_short &low)
Gets the language identifier out of the "version_chunk".
static basis::astring get_name(const void *to_find)
returns the name of the HMODULE specified by "to_find".
DEFINE_CLASS_NAME("version_checker")
static basis::astring module_name(const void *module_handle)
returns the module name where this object resides; only sensible on win32.
void complain_wrong_version(const basis::astring &library_file_name, const structures::version &expected_version, const structures::version &version_found) const
Reports that the file has the wrong version.
static bool loaded(const basis::astring &library_file_name)
returns true if the "library_file_name" is currently loaded.
basis::astring text_form() const
version_checker(const basis::astring &library_file_name, const structures::version &expected, const basis::astring &version_complaint)
Constructs a checking object and ensures the version is appropriate.
static structures::version retrieve_version(const basis::astring &pathname)
Returns the version given a "pathname" to the DLL or EXE file.
static void * get_handle(const basis::astring &library_file_name)
retrieves the module handle for the "library_file_name".
unsigned short un_short
Abbreviated name for unsigned short integers.
Definition: definitions.h:64