BasicTypes.h

// BasicTypes.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2019

#pragma once
#ifndef Ceda_cxUtils_BasicTypes_H
#define Ceda_cxUtils_BasicTypes_H

#include "BaseDefines.h"
#include "xchar.h"
#include <cstdint>

namespace ceda
{

/*
typedef signed char        int8_t;
typedef short              int16_t;
typedef int                int32_t;
typedef long long          int64_t;
typedef unsigned char      uint8_t;
typedef unsigned short     uint16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

#define INT8_MIN         (-127i8 - 1)
#define INT16_MIN        (-32767i16 - 1)
#define INT32_MIN        (-2147483647i32 - 1)
#define INT64_MIN        (-9223372036854775807i64 - 1)
#define INT8_MAX         127i8
#define INT16_MAX        32767i16
#define INT32_MAX        2147483647i32
#define INT64_MAX        9223372036854775807i64
#define UINT8_MAX        0xffui8
#define UINT16_MAX       0xffffui16
#define UINT32_MAX       0xffffffffui32
#define UINT64_MAX       0xffffffffffffffffui64
*/

//#define CEDA_SUPPORT_INT128

// Note:
// char is never the same type as either unsigned char or signed char, even though it has the 
// same range and representation as one of them.
// Therefore it is assumed char is a distinct type from both int8 and uint8

typedef std::int8_t int8;
typedef std::uint8_t uint8;

typedef std::int16_t int16;
typedef std::uint16_t uint16;

typedef std::int32_t int32;
typedef std::uint32_t uint32;

typedef std::int64_t int64;
typedef std::uint64_t uint64;

#if defined __SIZEOF_INT128__
    // GCC 4.6 and later has a __int128 / unsigned __int128 defined as a built-in type. available on x86-64 and armv8a
    using int128 = __int128_t;
    using uint128 = __uint128_t;
#elif defined CEDA_SUPPORT_INT128
    typedef std::int128_t int128;
    typedef std::uint128_t uint128;
#endif

typedef uint8 octet_t;

typedef std::intptr_t ssize_t;
typedef std::uintptr_t usize_t;

inline int ssize_t_to_int(ssize_t x)
{
    return (int) x;
}

typedef float float32;
typedef double float64;

template <typename T> class xvector;

template <typename T> class basic_xstring;

typedef basic_xstring<char8> string8;
typedef basic_xstring<char16> string16;
typedef basic_xstring<xchar> xstring;

template <typename T> class BasicSubString;

typedef BasicSubString<char8> SubString8;
typedef BasicSubString<char16> SubString16;
typedef BasicSubString<xchar> SubString;

template <typename K, typename V> class xmap;
template <typename T> class xset;

class xostream;
class Archive;

template <typename T> struct ptr;
template <typename T> class pref;
template <typename T> class cref;

} // namespace ceda

#endif // include guard