1 #ifndef DEFINITIONS_GROUP
2 #define DEFINITIONS_GROUP
4 /*****************************************************************************\
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 1991-$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 \*****************************************************************************/
18 //! @file "definitions.h" Constants and objects used throughout HOOPLE.
20 Defines a set of useful universal constants (for our chosen universe) and
21 a set of aliases for convenient abstract and concrete data types.
22 This is the lowest-level header in hoople and should not include any others.
31 //! The value representing a pointer to nothing, or nothing itself.
34 //! A fundamental constant measuring the number of bits in a byte.
35 #define BITS_PER_BYTE 8
37 //! An approximation of the fundamental circular constant.
38 #define PI_APPROX 3.14159265358
42 // Data Structures & Functions
44 //! This macro just eats what it's passed; it marks unused formal parameters.
45 #define formal(parameter)
47 //! A fairly important unit which is seldom defined...
48 typedef unsigned char abyte;
49 /* ridiculous! all to shut microsoft up about ambiguous byte definitions,
50 which seems like a bug.
52 byte(unsigned char b = 0) : c_data(b) {}
53 // byte(char b) : c_data(b) {}
54 operator unsigned char() const { return c_data; }
55 operator char() const { return c_data; }
56 operator int() const { return c_data; }
57 operator unsigned int() const { return c_data; }
58 operator bool() const { return (bool)c_data; }
59 byte operator &(byte and_with) { return c_data & and_with; }
60 byte operator |(byte or_with) { return c_data & or_with; }
65 #if defined(UNICODE) && defined(__WIN32__)
66 //! the flexichar type is always appropriate to hold data for win32 calls.
67 typedef wchar_t flexichar;
69 // this version simply defangs any conversions.
70 typedef char flexichar;
73 //! Abbreviated name for unsigned integers.
74 typedef unsigned int un_int;
75 //! Abbreviated name for unsigned short integers.
76 typedef unsigned short un_short;
77 //! Abbreviated name for unsigned long integers.
78 typedef unsigned long un_long;
80 // some maximum and minimum values that are helpful.
82 //! Maximum 32-bit integer value.
83 #define MAXINT32 0x7fffffff
86 //! Minimum 32-bit integer value.
87 #define MININT32 0x80000000
90 //! Maximum 32-bit integer value.
91 #define MAXINT16 0x7fff
94 //! Minimum 32-bit integer value.
95 #define MININT16 0x8000
98 //! Maximum byte-based character value.
102 //! Minimum byte-based character value.
106 //! Maximum unsigned byte value.
110 //! Minimum unsigned byte value.
114 // Provide definitions for integers with platform independent specific sizes.
115 // Note that these may have to be adjusted for 64 bit platforms.
117 typedef unsigned char uint8;
118 typedef signed short int16;
119 typedef unsigned short uint16;
120 typedef signed int int32;
121 typedef unsigned int uint32;
125 // useful time constants.
127 // the _ms suffix indicates that these are measured in milliseconds.
128 const int SECOND_ms = 1000; //!< Number of milliseconds in a second.
129 const int MINUTE_ms = 60 * SECOND_ms; //!< Number of milliseconds in a minute.
130 const int HOUR_ms = 60 * MINUTE_ms; //!< Number of milliseconds in an hour.
131 const int DAY_ms = 24 * HOUR_ms; //!< Number of milliseconds in a day.
133 // the _s suffix indicates that these are measured in seconds.
134 const int MINUTE_s = 60; //!< Number of seconds in a minute.
135 const int HOUR_s = 60 * MINUTE_s; //!< Number of seconds in an hour.
136 const int DAY_s = 24 * HOUR_s; //!< Number of seconds in a day.
140 // useful general constants.
142 const int KILOBYTE = 1024; //!< Number of bytes in a kilobyte.
143 const int MEGABYTE = KILOBYTE * KILOBYTE; //!< Number of bytes in a megabyte.
144 const int GIGABYTE = MEGABYTE * KILOBYTE; //!< Number of bytes in a gigabyte.
145 const double TERABYTE = double(GIGABYTE) * double(KILOBYTE);
146 //double TERABYTE() { return double(GIGABYTE) * double(KILOBYTE); }
147 //!< Number of bytes in a terabyte.
148 // /*!< Implemented as a function to avoid annoying link errors for double
149 // floating point constants in some compilers. */
153 // Super basic objects...
155 //! lowest level object for all hoople objects. supports run-time type id.
160 virtual ~root_object() {}
165 // compiler specific dumping ground for global settings...
168 // turns off annoying complaints from visual c++.
169 #pragma warning(disable : 4251 4275 4003 4800 4355 4786 4290 4996 4407)
170 #pragma warning(error : 4172)
171 // 4251 and 4275 turn off warnings regarding statically linked code
172 // not being marked with dll import/export flags.
173 // 4003 turns off warnings about insufficient number of parameters passed
175 // 4800 turns off the warning about conversion from int to bool not being
177 // 4355 turns off the warning re 'this' used in base member init list.
178 // 4786 turns off the warning about 'identifier' truncated to 'number'
179 // characters in the debug information which frequenly happens when
180 // STL pair and set templates are expanded.
181 // 4172 is made an error because this warning is emitted for a dangerous
182 // condition; the address of a local variable is being returned, making
183 // the returned object junk in almost all cases.
184 // 4996 turns off warnings about deprecated functions, which are mostly
185 // nonsense, since these are mainly the core posix functions.
186 #endif // ms visual c++.
192 #endif // outer guard.