Squashed 'deps/ox/' content from commit a5166e0
git-subtree-dir: deps/ox git-subtree-split: a5166e03bbaea2f200cfc730c69579c3d50ae2a7
This commit is contained in:
		
							
								
								
									
										38
									
								
								src/ox/std/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/ox/std/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
cmake_minimum_required(VERSION 2.8)
 | 
			
		||||
 | 
			
		||||
add_library(
 | 
			
		||||
	OxStd
 | 
			
		||||
		memops.cpp
 | 
			
		||||
		random.cpp
 | 
			
		||||
		strops.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
set_property(
 | 
			
		||||
	TARGET
 | 
			
		||||
		OxStd
 | 
			
		||||
	PROPERTY
 | 
			
		||||
		POSITION_INDEPENDENT_CODE ON
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
install(
 | 
			
		||||
	FILES
 | 
			
		||||
		bitops.hpp
 | 
			
		||||
		byteswap.hpp
 | 
			
		||||
		memops.hpp
 | 
			
		||||
		random.hpp
 | 
			
		||||
		string.hpp
 | 
			
		||||
		strops.hpp
 | 
			
		||||
		std.hpp
 | 
			
		||||
		types.hpp
 | 
			
		||||
	DESTINATION
 | 
			
		||||
		include/ox/std
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
install(TARGETS OxStd
 | 
			
		||||
        LIBRARY DESTINATION lib/ox
 | 
			
		||||
        ARCHIVE DESTINATION lib/ox
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if(OX_RUN_TESTS STREQUAL "ON")
 | 
			
		||||
	add_subdirectory(test)
 | 
			
		||||
endif()
 | 
			
		||||
							
								
								
									
										19
									
								
								src/ox/std/bitops.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/ox/std/bitops.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
 | 
			
		||||
inline uint64_t rotateLeft(uint64_t i, int shift) {
 | 
			
		||||
	return (i << shift) | (i >> (64 - shift));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										145
									
								
								src/ox/std/byteswap.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										145
									
								
								src/ox/std/byteswap.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,145 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
namespace std {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
inline int16_t byteSwap(int16_t i) {
 | 
			
		||||
	return (i << 8) | (i >> 8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline int32_t byteSwap(int32_t i) {
 | 
			
		||||
	return ((i >> 24) & 0x000000ff) |
 | 
			
		||||
	       ((i >>  8) & 0x0000ff00) |
 | 
			
		||||
	       ((i <<  8) & 0x00ff0000) |
 | 
			
		||||
	       ((i << 24) & 0xff000000);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline int64_t byteSwap(int64_t i) {
 | 
			
		||||
	return ((i >> 56) & 0x00000000000000ff) |
 | 
			
		||||
	       ((i >> 40) & 0x000000000000ff00) |
 | 
			
		||||
	       ((i >> 24) & 0x0000000000ff0000) |
 | 
			
		||||
	       ((i >>  8) & 0x00000000ff000000) |
 | 
			
		||||
	       ((i <<  8) & 0x000000ff00000000) |
 | 
			
		||||
	       ((i << 24) & 0x0000ff0000000000) |
 | 
			
		||||
	       ((i << 40) & 0x00ff000000000000) |
 | 
			
		||||
	       ((i << 56) & 0xff00000000000000);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline uint16_t byteSwap(uint16_t i) {
 | 
			
		||||
	return (i << 8) | (i >> 8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline uint32_t byteSwap(uint32_t i) {
 | 
			
		||||
	return ((i >> 24) & 0x000000ff) |
 | 
			
		||||
	       ((i >>  8) & 0x0000ff00) |
 | 
			
		||||
	       ((i <<  8) & 0x00ff0000) |
 | 
			
		||||
	       ((i << 24) & 0xff000000);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline uint64_t byteSwap(uint64_t i) {
 | 
			
		||||
	return ((i >> 56) & 0x00000000000000ff) |
 | 
			
		||||
	       ((i >> 40) & 0x000000000000ff00) |
 | 
			
		||||
	       ((i >> 24) & 0x0000000000ff0000) |
 | 
			
		||||
	       ((i >>  8) & 0x00000000ff000000) |
 | 
			
		||||
	       ((i <<  8) & 0x000000ff00000000) |
 | 
			
		||||
	       ((i << 24) & 0x0000ff0000000000) |
 | 
			
		||||
	       ((i << 40) & 0x00ff000000000000) |
 | 
			
		||||
	       ((i << 56) & 0xff00000000000000);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline int8_t bigEndianAdapt(int8_t i) {
 | 
			
		||||
	return i;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline int16_t bigEndianAdapt(int16_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline int32_t bigEndianAdapt(int32_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline int64_t bigEndianAdapt(int64_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline uint8_t bigEndianAdapt(uint8_t i) {
 | 
			
		||||
	return i;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline uint16_t bigEndianAdapt(uint16_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline uint32_t bigEndianAdapt(uint32_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Takes an int and byte swaps if the platform is big endian.
 | 
			
		||||
 */
 | 
			
		||||
inline uint64_t bigEndianAdapt(uint64_t i) {
 | 
			
		||||
#ifdef __BIG_ENDIAN__
 | 
			
		||||
	return byteSwap(i);
 | 
			
		||||
#else
 | 
			
		||||
	return i;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										41
									
								
								src/ox/std/memops.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/ox/std/memops.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#include "memops.hpp"
 | 
			
		||||
 | 
			
		||||
int ox_memcmp(const void *ptr1, const void *ptr2, size_t size) {
 | 
			
		||||
	int retval = 0;
 | 
			
		||||
	auto block1 = ((uint8_t*) ptr1);
 | 
			
		||||
	auto block2 = ((uint8_t*) ptr2);
 | 
			
		||||
	for (size_t i = 0; i < size; i++) {
 | 
			
		||||
		if (block1[i] < block2[i]) {
 | 
			
		||||
			retval = -1;
 | 
			
		||||
			break;
 | 
			
		||||
		} else if (block1[i] > block2[i]) {
 | 
			
		||||
			retval = 1;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *ox_memcpy(void *dest, const void *src, int64_t size) {
 | 
			
		||||
	char *srcBuf = (char*) src;
 | 
			
		||||
	char *dstBuf = (char*) dest;
 | 
			
		||||
	for (int64_t i = 0; i < size; i++) {
 | 
			
		||||
		dstBuf[i] = (char) srcBuf[i];
 | 
			
		||||
	}
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *ox_memset(void *ptr, int val, int64_t size) {
 | 
			
		||||
	char *buf = (char*) ptr;
 | 
			
		||||
	for (int64_t i = 0; i < size; i++) {
 | 
			
		||||
		buf[i] = val;
 | 
			
		||||
	}
 | 
			
		||||
	return ptr;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								src/ox/std/memops.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/ox/std/memops.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
 | 
			
		||||
int ox_memcmp(const void *ptr1, const void *ptr2, size_t size);
 | 
			
		||||
 | 
			
		||||
void *ox_memcpy(void *src, const void *dest, int64_t size);
 | 
			
		||||
 | 
			
		||||
void *ox_memset(void *ptr, int val, int64_t size);
 | 
			
		||||
							
								
								
									
										40
									
								
								src/ox/std/random.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/ox/std/random.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "bitops.hpp"
 | 
			
		||||
#include "random.hpp"
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
 | 
			
		||||
RandomSeed Random::DEFAULT_SEED = {540932923848, 540932540932};
 | 
			
		||||
 | 
			
		||||
Random::Random(RandomSeed seed) {
 | 
			
		||||
	m_seed[0] = seed[0];
 | 
			
		||||
	m_seed[1] = seed[1];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint64_t Random::gen() {
 | 
			
		||||
	// An implementation of the Xoroshiro128+ algorithm
 | 
			
		||||
	auto s0 = m_seed[0];
 | 
			
		||||
	auto s1 = m_seed[1];
 | 
			
		||||
	auto retval = s0 + s1;
 | 
			
		||||
 | 
			
		||||
	s1 ^= s0;
 | 
			
		||||
	m_seed[0] = ox::rotateLeft(s0, 55) ^ s1 ^ (s1 << 14);
 | 
			
		||||
	m_seed[1] = ox::rotateLeft(s1, 36);
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint64_t ox_rand() {
 | 
			
		||||
	static ox::Random rand;
 | 
			
		||||
	return rand.gen();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								src/ox/std/random.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/ox/std/random.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
uint64_t ox_rand();
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
 | 
			
		||||
typedef uint64_t RandomSeed[2];
 | 
			
		||||
 | 
			
		||||
class Random {
 | 
			
		||||
	public:
 | 
			
		||||
		static RandomSeed DEFAULT_SEED;
 | 
			
		||||
 | 
			
		||||
	private:
 | 
			
		||||
		RandomSeed m_seed;
 | 
			
		||||
 | 
			
		||||
	public:
 | 
			
		||||
		Random(RandomSeed seed = DEFAULT_SEED);
 | 
			
		||||
 | 
			
		||||
		uint64_t gen();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								src/ox/std/std.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/ox/std/std.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "bitops.hpp"
 | 
			
		||||
#include "byteswap.hpp"
 | 
			
		||||
#include "memops.hpp"
 | 
			
		||||
#include "random.hpp"
 | 
			
		||||
#include "strops.hpp"
 | 
			
		||||
#include "string.hpp"
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
							
								
								
									
										128
									
								
								src/ox/std/string.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								src/ox/std/string.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,128 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "memops.hpp"
 | 
			
		||||
#include "strops.hpp"
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
 | 
			
		||||
// Bounded String
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
class bstring {
 | 
			
		||||
	private:
 | 
			
		||||
		uint8_t m_buff[buffLen];
 | 
			
		||||
 | 
			
		||||
	public:
 | 
			
		||||
		bstring();
 | 
			
		||||
 | 
			
		||||
		bstring(const char *str);
 | 
			
		||||
 | 
			
		||||
		const bstring &operator=(const char *str);
 | 
			
		||||
 | 
			
		||||
		const bstring &operator=(char *str);
 | 
			
		||||
 | 
			
		||||
		bool operator==(const bstring &other);
 | 
			
		||||
 | 
			
		||||
		char *data();
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Returns the number of characters in this string.
 | 
			
		||||
		 */
 | 
			
		||||
		size_t len();
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Returns the number of bytes used for this string.
 | 
			
		||||
		 */
 | 
			
		||||
		size_t size();
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Returns the capacity of bytes for this string.
 | 
			
		||||
		 */
 | 
			
		||||
		size_t cap();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<size_t size>
 | 
			
		||||
bstring<size>::bstring() {
 | 
			
		||||
	m_buff[0] = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t size>
 | 
			
		||||
bstring<size>::bstring(const char *str) {
 | 
			
		||||
	*this = str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t size>
 | 
			
		||||
const bstring<size> &bstring<size>::operator=(const char *str) {
 | 
			
		||||
	size_t strLen = ox_strlen(str) + 1;
 | 
			
		||||
	if (cap() < strLen) {
 | 
			
		||||
		strLen = cap();
 | 
			
		||||
	}
 | 
			
		||||
	ox_memcpy(m_buff, str, strLen);
 | 
			
		||||
	// make sure last element is a null terminator
 | 
			
		||||
	m_buff[cap() - 1] = 0;
 | 
			
		||||
	return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t size>
 | 
			
		||||
const bstring<size> &bstring<size>::operator=(char *str) {
 | 
			
		||||
	return *this = (const char*) str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
bool bstring<buffLen>::operator==(const bstring<buffLen> &other) {
 | 
			
		||||
	bool retval = true;
 | 
			
		||||
	size_t i = 0;
 | 
			
		||||
	while (i < buffLen && (m_buff[i] || other.m_buff[i])) {
 | 
			
		||||
		if (m_buff[i] != other.m_buff[i]) {
 | 
			
		||||
			retval = false;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
char *bstring<buffLen>::data() {
 | 
			
		||||
	return (char*) m_buff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
size_t bstring<buffLen>::len() {
 | 
			
		||||
	size_t length = 0;
 | 
			
		||||
	for (size_t i = 0; i < buffLen; i++) {
 | 
			
		||||
		uint8_t b = m_buff[i];
 | 
			
		||||
		if (b) {
 | 
			
		||||
			if ((b & 128) == 0) { // normal ASCII character
 | 
			
		||||
				length++;
 | 
			
		||||
			} else if ((b & (256 << 6)) == (256 << 6)) { // start of UTF-8 character
 | 
			
		||||
				length++;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return length;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
size_t bstring<buffLen>::size() {
 | 
			
		||||
	size_t i;
 | 
			
		||||
	for (i = 0; i < buffLen && m_buff[i]; i++);
 | 
			
		||||
	return i + 1; // add one for null terminator
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<size_t buffLen>
 | 
			
		||||
size_t bstring<buffLen>::cap() {
 | 
			
		||||
	return buffLen;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										91
									
								
								src/ox/std/strops.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								src/ox/std/strops.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "strops.hpp"
 | 
			
		||||
 | 
			
		||||
int ox_strcmp(const char *str1, const char *str2) {
 | 
			
		||||
	auto retval = 0;
 | 
			
		||||
	auto i = 0;
 | 
			
		||||
	while (str1[i] || str2[i]) {
 | 
			
		||||
		if (str1[i] < str2[i]) {
 | 
			
		||||
			retval = -1;
 | 
			
		||||
			break;
 | 
			
		||||
		} else if (str1[i] > str2[i]) {
 | 
			
		||||
			retval = 1;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ox_strlen(const char *str1) {
 | 
			
		||||
	int len;
 | 
			
		||||
	for (len = 0; str1[len]; len++);
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ox_strlen(char *str1) {
 | 
			
		||||
	int len;
 | 
			
		||||
	for (len = 0; str1[len]; len++);
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *ox_strchr(const char *str, int character, size_t maxLen) {
 | 
			
		||||
	for (size_t i = 0; i <= maxLen; i++) {
 | 
			
		||||
		if (str[i] == character) {
 | 
			
		||||
			return &str[i];
 | 
			
		||||
		} else if (str[i] == 0) {
 | 
			
		||||
			return nullptr;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *ox_strchr(char *str, int character, size_t maxLen) {
 | 
			
		||||
	for (size_t i = 0; i < maxLen; i++) {
 | 
			
		||||
		if (str[i] == character) {
 | 
			
		||||
			return &str[i];
 | 
			
		||||
		} else if (str[i] == 0) {
 | 
			
		||||
			return nullptr;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ox_lastIndexOf(const char *str, int character, int maxLen) {
 | 
			
		||||
	int retval = -1;
 | 
			
		||||
	for (int i = 0; i < maxLen && str[i]; i++) {
 | 
			
		||||
		if (str[i] == character) {
 | 
			
		||||
			retval = i;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ox_lastIndexOf(char *str, int character, int maxLen) {
 | 
			
		||||
	int retval = -1;
 | 
			
		||||
	for (int i = 0; i < maxLen && str[i]; i++) {
 | 
			
		||||
		if (str[i] == character) {
 | 
			
		||||
			retval = i;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ox_atoi(const char *str) {
 | 
			
		||||
	int total = 0;
 | 
			
		||||
	int multiplier = 1;
 | 
			
		||||
 | 
			
		||||
	for (auto i = ox_strlen(str) - 1; i != -1; i--) {
 | 
			
		||||
		total += (str[i] - '0') * multiplier;
 | 
			
		||||
		multiplier *= 10;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return total;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								src/ox/std/strops.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/ox/std/strops.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "types.hpp"
 | 
			
		||||
 | 
			
		||||
int ox_strcmp(const char *str1, const char *str2);
 | 
			
		||||
 | 
			
		||||
int ox_strlen(const char *str1);
 | 
			
		||||
 | 
			
		||||
int ox_strlen(char *str1);
 | 
			
		||||
 | 
			
		||||
const char *ox_strchr(const char *str, int character, size_t maxLen = 0xFFFFFFFF);
 | 
			
		||||
 | 
			
		||||
char *ox_strchr(char *str, int character, size_t maxLen = 0xFFFFFFFF);
 | 
			
		||||
 | 
			
		||||
int ox_lastIndexOf(const char *str, int character, int maxLen = 0xFFFFFFFF);
 | 
			
		||||
 | 
			
		||||
int ox_lastIndexOf(char *str, int character, int maxLen = 0xFFFFFFFF);
 | 
			
		||||
 | 
			
		||||
int ox_atoi(const char *str);
 | 
			
		||||
							
								
								
									
										61
									
								
								src/ox/std/test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/ox/std/test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
cmake_minimum_required(VERSION 2.8)
 | 
			
		||||
 | 
			
		||||
add_executable(
 | 
			
		||||
	StdTest
 | 
			
		||||
		tests.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(StdTest OxStd)
 | 
			
		||||
 | 
			
		||||
add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN")
 | 
			
		||||
add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG")
 | 
			
		||||
add_test("Test\\ ox_memcmp\\ ABCDEFG\\ ==\\ ABCDEFG" StdTest "ABCDEFG == ABCDEFG")
 | 
			
		||||
add_test("Test\\ ox_memcmp\\ ABCDEFGHI\\ ==\\ ABCDEFG" StdTest "ABCDEFGHI == ABCDEFG")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# StrOps Tests
 | 
			
		||||
 | 
			
		||||
add_executable(
 | 
			
		||||
	StrOpsTest
 | 
			
		||||
		strops_test.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(StrOpsTest OxStd)
 | 
			
		||||
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ asdf\\ !=\\ hijk" StrOpsTest "asdf < hijk")
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ hijk\\ !=\\ asdf" StrOpsTest "hijk > asdf")
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ read\\ !=\\ resize" StrOpsTest "read < resize")
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ resize\\ !=\\ read" StrOpsTest "resize > read")
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ resize\\ ==\\ resize" StrOpsTest "resize == resize")
 | 
			
		||||
add_test("Test\\ ox_strcmp\\ resize\\ ==\\ resize" StrOpsTest " == ")
 | 
			
		||||
add_test("Test\\ ox_strchr\\ 0" StrOpsTest "ox_strchr 0")
 | 
			
		||||
add_test("Test\\ ox_lastIndexOf\\ aaaa\\ a" StrOpsTest "ox_lastIndexOf aaaa a")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# Byte Swap Tests
 | 
			
		||||
 | 
			
		||||
add_executable(
 | 
			
		||||
	ByteSwapTest
 | 
			
		||||
		byteswap_test.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(ByteSwapTest OxStd)
 | 
			
		||||
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x00ff" ByteSwapTest bigEndianAdapt<uint16_t> 0x00ff)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0xff00" ByteSwapTest bigEndianAdapt<uint16_t> 0xff00)
 | 
			
		||||
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x000000ff" ByteSwapTest bigEndianAdapt<uint32_t> 0x000000ff)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x0000ff00" ByteSwapTest bigEndianAdapt<uint32_t> 0x0000ff00)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x00ff0000" ByteSwapTest bigEndianAdapt<uint32_t> 0x00ff0000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0xff000000" ByteSwapTest bigEndianAdapt<uint32_t> 0xff000000)
 | 
			
		||||
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x00000000000000ff" ByteSwapTest bigEndianAdapt<uint64_t> 0x00000000000000ff)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x000000000000ff00" ByteSwapTest bigEndianAdapt<uint64_t> 0x000000000000ff00)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x0000000000ff0000" ByteSwapTest bigEndianAdapt<uint64_t> 0x0000000000ff0000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x00000000ff000000" ByteSwapTest bigEndianAdapt<uint64_t> 0x00000000ff000000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x000000ff00000000" ByteSwapTest bigEndianAdapt<uint64_t> 0x000000ff00000000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x0000ff0000000000" ByteSwapTest bigEndianAdapt<uint64_t> 0x0000ff0000000000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0x00ff000000000000" ByteSwapTest bigEndianAdapt<uint64_t> 0x00ff000000000000)
 | 
			
		||||
add_test("Test\\ bigEndianAdapt\\ 0xff00000000000000" ByteSwapTest bigEndianAdapt<uint64_t> 0xff00000000000000)
 | 
			
		||||
							
								
								
									
										39
									
								
								src/ox/std/test/byteswap_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/ox/std/test/byteswap_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <ox/std/std.hpp>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
using namespace ox::std;
 | 
			
		||||
 | 
			
		||||
template<typename T>
 | 
			
		||||
int testBigEndianAdapt(string str) {
 | 
			
		||||
	auto i = (T) stoull(str, nullptr, 16);
 | 
			
		||||
	return !(bigEndianAdapt(bigEndianAdapt(i)) == i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
map<string, int(*)(string)> tests = {
 | 
			
		||||
	{
 | 
			
		||||
		{ "bigEndianAdapt<uint16_t>", testBigEndianAdapt<uint16_t> },
 | 
			
		||||
		{ "bigEndianAdapt<uint32_t>", testBigEndianAdapt<uint32_t> },
 | 
			
		||||
		{ "bigEndianAdapt<uint64_t>", testBigEndianAdapt<uint64_t> },
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(int argc, const char **args) {
 | 
			
		||||
	int retval = -1;
 | 
			
		||||
	if (argc > 1) {
 | 
			
		||||
		auto testName = args[1];
 | 
			
		||||
		string testArg = args[2];
 | 
			
		||||
		if (tests.find(testName) != tests.end()) {
 | 
			
		||||
			retval = tests[testName](testArg);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								src/ox/std/test/strops_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								src/ox/std/test/strops_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <ox/std/std.hpp>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
map<string, function<int()>> tests = {
 | 
			
		||||
	{
 | 
			
		||||
		"asdf < hijk",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("asdf", "hijk") < 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"hijk > asdf",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("hijk", "asdf") > 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"resize > read",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("resize", "read") > 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"read < resize",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("read", "resize") < 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"resize == resize",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("resize", "resize") == 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		" == ",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_strcmp("", "") == 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"ox_strchr 0",
 | 
			
		||||
		[]() {
 | 
			
		||||
			auto testStr = "asdf";
 | 
			
		||||
			return !(ox_strchr(testStr, 0, 4) == &testStr[4]);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"ox_lastIndexOf aaaa a",
 | 
			
		||||
		[]() {
 | 
			
		||||
			int retval = 0;
 | 
			
		||||
			auto testStr = "aaaa";
 | 
			
		||||
			retval |= !(ox_lastIndexOf((char*) testStr, 'a', ox_strlen(testStr)) == 3);
 | 
			
		||||
			retval |= !(ox_lastIndexOf((const char*) testStr, 'a', ox_strlen(testStr)) == 3);
 | 
			
		||||
			return retval;
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(int argc, const char **args) {
 | 
			
		||||
	if (argc > 1) {
 | 
			
		||||
		auto testName = args[1];
 | 
			
		||||
		if (tests.find(testName) != tests.end()) {
 | 
			
		||||
			return tests[testName]();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										50
									
								
								src/ox/std/test/tests.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/ox/std/test/tests.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <ox/std/std.hpp>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
map<string, function<int()>> tests = {
 | 
			
		||||
	{
 | 
			
		||||
		"ABCDEFG != HIJKLMN",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_memcmp("ABCDEFG", "HIJKLMN", 7) < 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"HIJKLMN != ABCDEFG",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_memcmp("HIJKLMN", "ABCDEFG", 7) > 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"ABCDEFG == ABCDEFG",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_memcmp("ABCDEFG", "ABCDEFG", 7) == 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"ABCDEFGHI == ABCDEFG",
 | 
			
		||||
		[]() {
 | 
			
		||||
			return !(ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) == 0);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(int argc, const char **args) {
 | 
			
		||||
	if (argc > 1) {
 | 
			
		||||
		auto testName = args[1];
 | 
			
		||||
		if (tests.find(testName) != tests.end()) {
 | 
			
		||||
			return tests[testName]();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								src/ox/std/types.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/ox/std/types.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2015 - 2017 gtalent2@gmail.com
 | 
			
		||||
 *
 | 
			
		||||
 * This Source Code Form is subject to the terms of the Mozilla Public
 | 
			
		||||
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
			
		||||
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
typedef signed char        int8_t;
 | 
			
		||||
typedef unsigned char      uint8_t;
 | 
			
		||||
typedef short              int16_t;
 | 
			
		||||
typedef unsigned short     uint16_t;
 | 
			
		||||
typedef int                int32_t;
 | 
			
		||||
typedef unsigned int       uint32_t;
 | 
			
		||||
typedef unsigned           uint_t;
 | 
			
		||||
#if defined(_WIN32) || defined(__APPLE__) || defined(__arm__) || defined(__ppc__)
 | 
			
		||||
typedef long long          int64_t;
 | 
			
		||||
typedef unsigned long long uint64_t;
 | 
			
		||||
#else
 | 
			
		||||
typedef long               int64_t;
 | 
			
		||||
typedef unsigned long      uint64_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace ox {
 | 
			
		||||
 | 
			
		||||
typedef uint32_t Error;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined(_LP64) || defined(__ppc64__) || defined(__aarch64__)
 | 
			
		||||
typedef unsigned long size_t;
 | 
			
		||||
#elif defined(_WIN64)
 | 
			
		||||
typedef uint64_t size_t;
 | 
			
		||||
#elif defined(_LP32) || defined(__ppc__) || defined(_WIN32) || defined(__arm__)
 | 
			
		||||
typedef uint32_t size_t;
 | 
			
		||||
#else
 | 
			
		||||
#error size_t undefined
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user