JX Application Framework
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
jTypes.h File Reference
#include <limits.h>
#include <float.h>
#include <iostream>
#include <compare>
Include dependency graph for jTypes.h:
This graph shows which files directly or indirectly include this file:

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
 

Typedef Documentation

◆ JCoordinate

using JCoordinate = long

◆ JCursorPosition

using JCursorPosition = unsigned long

◆ JDualHashValue

◆ JFileVersion

using JFileVersion = unsigned long

◆ JFloat

using JFloat = double

◆ JHashValue

using JHashValue = JUWord

Defines standard hash value types, e.g. for use in JHashTable.

◆ JIndex

using JIndex = unsigned long

◆ JInt32

using JInt32 = std::conditional_t<sizeof( signed long) == 4, signed long, signed int>

◆ JInt64

using JInt64 = std::conditional_t<sizeof( signed long long) == 8, signed long long, signed long>

◆ JInteger

using JInteger = long

Defines portable types

◆ JSignedIndex

using JSignedIndex = long

◆ JSignedOffset

using JSignedOffset = long

◆ JSize

using JSize = unsigned long

◆ JUInt

using JUInt = unsigned long

◆ JUInt32

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.

◆ JUInt64

using JUInt64 = std::conditional_t<sizeof(unsigned long long) == 8, unsigned long long, unsigned long>

◆ JUnsignedOffset

using JUnsignedOffset = unsigned long

◆ JUtf8Byte

using JUtf8Byte = char

◆ JUWord

using JUWord = unsigned long

◆ JWord

using JWord = signed long

Function Documentation

◆ JBoolFromString()

JBoolRefHolder JBoolFromString ( bool v)
inline

◆ JBoolToString()

JBoolConstRefHolder JBoolToString ( bool const &  v)
inline

◆ JIntToWeakOrdering()

std::weak_ordering JIntToWeakOrdering ( const int  r)
inline

◆ operator<<()

std::ostream & operator<< ( std::ostream &  output,
JBoolConstRefHolder const &  data 
)

◆ operator>>()

std::istream & operator>> ( std::istream &  input,
JBoolRefHolder const &  data 
)

Variable Documentation

◆ kJBinaryFile

figure out what to do !const JFStreamOpenMode kJBinaryFile = std::ios::in | std::ios::out | kJBinaryModifier

Hides compiler dependent std::iostream information.

◆ kJCoordinateMax

const JCoordinate kJCoordinateMax = LONG_MAX

◆ kJCoordinateMin

const JCoordinate kJCoordinateMin = LONG_MIN

◆ kJFileVersionMax

const JFileVersion kJFileVersionMax = ULONG_MAX

◆ kJFileVersionMin

const JFileVersion kJFileVersionMin = 0

◆ kJFloatExponentMax

const long kJFloatExponentMax = DBL_MAX_10_EXP

◆ kJFloatExponentMin

const long kJFloatExponentMin = DBL_MIN_10_EXP

◆ kJFloatMax

const JFloat kJFloatMax = DBL_MAX

◆ kJFloatMin

const JFloat kJFloatMin = DBL_MIN

◆ kJIndexMax

const JIndex kJIndexMax = ULONG_MAX

◆ kJIndexMin

const JIndex kJIndexMin = 0

◆ kJInt32Max

const JInt32 kJInt32Max = sizeof(signed long) == 4 ? JInt32(LONG_MAX) : INT_MAX

◆ kJInt32Min

const JInt32 kJInt32Min = sizeof(signed long) == 4 ? JInt32(LONG_MIN) : INT_MIN

◆ kJInt64Max

const JInt64 kJInt64Max = sizeof(signed long long) == 8 ? JInt64(LLONG_MAX) : LONG_MAX

◆ kJInt64Min

const JInt64 kJInt64Min = sizeof(signed long long) == 8 ? JInt64(LLONG_MIN) : LONG_MIN

◆ kJIntegerMax

const JInteger kJIntegerMax = LONG_MAX

◆ kJIntegerMin

const JInteger kJIntegerMin = LONG_MIN

◆ kJSignedIndexMax

const JSignedIndex kJSignedIndexMax = LONG_MAX

◆ kJSignedIndexMin

const JSignedIndex kJSignedIndexMin = LONG_MIN

◆ kJSignedOffsetMax

const JSignedOffset kJSignedOffsetMax = LONG_MAX

◆ kJSignedOffsetMin

const JSignedOffset kJSignedOffsetMin = LONG_MIN

◆ kJSizeMax

const JSize kJSizeMax = ULONG_MAX

◆ kJSizeMin

const JSize kJSizeMin = 0

◆ kJTextFile

const JFStreamOpenMode kJTextFile = std::ios::in | std::ios::out

◆ kJUInt32Max

const JUInt32 kJUInt32Max = sizeof(unsigned long) == 4 ? JUInt32(ULONG_MAX) : UINT_MAX

◆ kJUInt32Min

const JUInt32 kJUInt32Min = 0

◆ kJUInt64Max

const JUInt64 kJUInt64Max = sizeof(unsigned long long) == 8 ? JUInt64(ULLONG_MAX) : ULONG_MAX

◆ kJUInt64Min

const JUInt64 kJUInt64Min = 0

◆ kJUIntMax

const JUInt kJUIntMax = ULONG_MAX

◆ kJUIntMin

const JUInt kJUIntMin = 0

◆ kJUnsignedOffsetMax

const JUnsignedOffset kJUnsignedOffsetMax = ULONG_MAX

◆ kJUnsignedOffsetMin

const JUnsignedOffset kJUnsignedOffsetMin = 0

◆ kJUtf8ByteMax

const JUtf8Byte kJUtf8ByteMax = CHAR_MAX

◆ kJUtf8ByteMin

const JUtf8Byte kJUtf8ByteMin = CHAR_MIN