JX Application Framework
|
#include <limits.h>
#include <float.h>
#include <iostream>
#include <compare>
Classes | |
struct | JBoolRefHolder |
struct | JBoolConstRefHolder |
Typedefs | |
using | JInteger = long |
using | JUInt = unsigned long |
using | JFloat = double |
using | JSize = unsigned long |
using | JIndex = unsigned long |
using | JSignedIndex = long |
using | JUnsignedOffset = unsigned long |
using | JSignedOffset = long |
using | JCoordinate = long |
using | JFileVersion = unsigned long |
using | JUtf8Byte = char |
using | JCursorPosition = unsigned long |
using | JUInt32 = std::conditional_t< sizeof(unsigned long)==4, unsigned long, unsigned int > |
using | JInt32 = std::conditional_t< sizeof(signed long)==4, signed long, signed int > |
using | JUInt64 = std::conditional_t< sizeof(unsigned long long)==8, unsigned long long, unsigned long > |
using | JInt64 = std::conditional_t< sizeof(signed long long)==8, signed long long, signed long > |
using | JUWord = unsigned long |
using | JWord = signed long |
using | JHashValue = JUWord |
using | JDualHashValue = JWord |
Functions | |
std::ostream & | operator<< (std::ostream &output, JBoolConstRefHolder const &data) |
std::istream & | operator>> (std::istream &input, JBoolRefHolder const &data) |
JBoolConstRefHolder | JBoolToString (bool const &v) |
JBoolRefHolder | JBoolFromString (bool &v) |
std::weak_ordering | JIntToWeakOrdering (const int r) |
Variables | |
const JInteger | kJIntegerMin = LONG_MIN |
const JInteger | kJIntegerMax = LONG_MAX |
const JUInt | kJUIntMin = 0 |
const JUInt | kJUIntMax = ULONG_MAX |
const JFloat | kJFloatMin = DBL_MIN |
const JFloat | kJFloatMax = DBL_MAX |
const long | kJFloatExponentMin = DBL_MIN_10_EXP |
const long | kJFloatExponentMax = DBL_MAX_10_EXP |
const JSize | kJSizeMin = 0 |
const JSize | kJSizeMax = ULONG_MAX |
const JIndex | kJIndexMin = 0 |
const JIndex | kJIndexMax = ULONG_MAX |
const JSignedIndex | kJSignedIndexMin = LONG_MIN |
const JSignedIndex | kJSignedIndexMax = LONG_MAX |
const JUnsignedOffset | kJUnsignedOffsetMin = 0 |
const JUnsignedOffset | kJUnsignedOffsetMax = ULONG_MAX |
const JSignedOffset | kJSignedOffsetMin = LONG_MIN |
const JSignedOffset | kJSignedOffsetMax = LONG_MAX |
const JCoordinate | kJCoordinateMin = LONG_MIN |
const JCoordinate | kJCoordinateMax = LONG_MAX |
const JFileVersion | kJFileVersionMin = 0 |
const JFileVersion | kJFileVersionMax = ULONG_MAX |
const JUtf8Byte | kJUtf8ByteMin = CHAR_MIN |
const JUtf8Byte | kJUtf8ByteMax = CHAR_MAX |
const JUInt32 | kJUInt32Min = 0 |
const JUInt32 | kJUInt32Max = sizeof(unsigned long) == 4 ? JUInt32(ULONG_MAX) : UINT_MAX |
const JInt32 | kJInt32Min = sizeof(signed long) == 4 ? JInt32(LONG_MIN) : INT_MIN |
const JInt32 | kJInt32Max = sizeof(signed long) == 4 ? JInt32(LONG_MAX) : INT_MAX |
const JUInt64 | kJUInt64Min = 0 |
const JUInt64 | kJUInt64Max = sizeof(unsigned long long) == 8 ? JUInt64(ULLONG_MAX) : ULONG_MAX |
const JInt64 | kJInt64Min = sizeof(signed long long) == 8 ? JInt64(LLONG_MIN) : LONG_MIN |
const JInt64 | kJInt64Max = sizeof(signed long long) == 8 ? JInt64(LLONG_MAX) : LONG_MAX |
figure out what to do !const JFStreamOpenMode | kJBinaryFile = std::ios::in | std::ios::out | kJBinaryModifier |
const JFStreamOpenMode | kJTextFile = std::ios::in | std::ios::out |
using JCoordinate = long |
using JCursorPosition = unsigned long |
using JDualHashValue = JWord |
using JFileVersion = unsigned long |
using JHashValue = JUWord |
Defines standard hash value types, e.g. for use in JHashTable.
using JIndex = unsigned long |
using JInt32 = std::conditional_t<sizeof( signed long) == 4, signed long, signed int> |
using JInt64 = std::conditional_t<sizeof( signed long long) == 8, signed long long, signed long> |
using JInteger = long |
Defines portable types
using JSignedIndex = long |
using JSignedOffset = long |
using JSize = unsigned long |
using JUInt = unsigned long |
using JUInt32 = std::conditional_t<sizeof(unsigned long) == 4, unsigned long, unsigned int> |
J?Int... types
These types provide fixed and machine-specific sized signed and unsigned integral types for algorithms which require explicit knowledge of the size of their integers, or simply a guarantee that they are exactly one machine word. The JInt... types are signed, while the JUInt... quantities are unsigned. The suffix indicates the actual width of the type in bits.
Specifically, JUInt32 provides an unsigned integer guaranteed to be 32 bits on all supported machines, a bit like the FORTRAN (gasp!) N style idiom; it is similar to an unsigned version of a FORTRAN INTEGER*4. Similarly, JUInt64 provides a 64-bit integer, but *only on machines which provide such a native type. Thus it does not always exist and must be tested for with the preprocessor. Normally one only needs to do this to ensure that a variable is a machine word, which is provided automatically through the JUWord type and always exists. JInt32, JInt64, and JWord are their signed bretheren.
Considerations:
All unix machines seem to define an int as 32 bits, regardless of wordsize, while a long is the machine's native wordsize, 32 bits on 32-bit architectures and 64 on 64-bit processors like the Alpha. This is consistent with the traditional (i.e. before 64-bit processor) C programmer's assumption that pointers and longs can convert back and forth without loss of information.
MetroWerks uses 16-bit ints (perhaps the original Mac had 16-bit words?), so on the Mac (at least) we'll need to use a long.
For strict ANSI compliance it can be a good idea to use a signed integer when the quantity may be interpreted as either a signed or unsigned value. The reason for this is that if a signed integral quantity is converted to an unsigned quantity ANSI guarantees that it behaves exactly as you think it should, i.e. as though the signed quantity was stored in two's complement representation and the bit pattern was simply re-interpreted as an unsigned integer.
By contrast, ANSI does not guarantee that the reverse is true. An unsigned quantity converted to a signed quantity overflows when its value is too large to fit into the signed quantity, and the result is undefined. The fact that every C programmer on the planet behaves as though ANSI mandates the usual unix/two's complement behavior of re-interpreting the bit pattern as a two's complement value apparently did not sway the standards committee, and code which depends on such behavior is not strictly portable. On the other hand, I wonder how many C compliers would dare to break this behavior.
using JUInt64 = std::conditional_t<sizeof(unsigned long long) == 8, unsigned long long, unsigned long> |
using JUnsignedOffset = unsigned long |
using JUtf8Byte = char |
using JUWord = unsigned long |
using JWord = signed long |
|
inline |
|
inline |
|
inline |
std::ostream & operator<< | ( | std::ostream & | output, |
JBoolConstRefHolder const & | data | ||
) |
std::istream & operator>> | ( | std::istream & | input, |
JBoolRefHolder const & | data | ||
) |
figure out what to do !const JFStreamOpenMode kJBinaryFile = std::ios::in | std::ios::out | kJBinaryModifier |
Hides compiler dependent std::iostream information.
const JCoordinate kJCoordinateMax = LONG_MAX |
const JCoordinate kJCoordinateMin = LONG_MIN |
const JFileVersion kJFileVersionMax = ULONG_MAX |
const JFileVersion kJFileVersionMin = 0 |
const long kJFloatExponentMax = DBL_MAX_10_EXP |
const long kJFloatExponentMin = DBL_MIN_10_EXP |
const JFloat kJFloatMax = DBL_MAX |
const JFloat kJFloatMin = DBL_MIN |
const JIndex kJIndexMax = ULONG_MAX |
const JIndex kJIndexMin = 0 |
const JInteger kJIntegerMax = LONG_MAX |
const JInteger kJIntegerMin = LONG_MIN |
const JSignedIndex kJSignedIndexMax = LONG_MAX |
const JSignedIndex kJSignedIndexMin = LONG_MIN |
const JSignedOffset kJSignedOffsetMax = LONG_MAX |
const JSignedOffset kJSignedOffsetMin = LONG_MIN |
const JSize kJSizeMax = ULONG_MAX |
const JSize kJSizeMin = 0 |
const JFStreamOpenMode kJTextFile = std::ios::in | std::ios::out |
const JUInt32 kJUInt32Min = 0 |
const JUInt64 kJUInt64Min = 0 |
const JUInt kJUIntMax = ULONG_MAX |
const JUInt kJUIntMin = 0 |
const JUnsignedOffset kJUnsignedOffsetMax = ULONG_MAX |
const JUnsignedOffset kJUnsignedOffsetMin = 0 |
const JUtf8Byte kJUtf8ByteMax = CHAR_MAX |
const JUtf8Byte kJUtf8ByteMin = CHAR_MIN |