[ox/mc] Add def writer

This commit is contained in:
2019-02-11 05:59:33 +00:00
parent 96c56e2589
commit 75aeedb7b5
20 changed files with 468 additions and 17 deletions

View File

@@ -17,6 +17,8 @@ set_property(
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(OxStd PUBLIC OxTrace)
install(
FILES
assert.hpp

View File

@@ -38,6 +38,13 @@ class HashMap {
*/
T &operator[](K key) noexcept;
/**
* K is assumed to be a null terminated string.
*/
T &at(K key) noexcept;
bool contains(K key) noexcept;
std::size_t size() const noexcept;
private:
@@ -93,6 +100,16 @@ T &HashMap<K, T>::operator[](K k) noexcept {
return p->value;
}
template<typename K, typename T>
T &HashMap<K, T>::at(K k) noexcept {
return operator[](k);
}
template<typename K, typename T>
bool HashMap<K, T>::contains(K k) noexcept {
return access(m_pairs, k) != nullptr;
}
template<typename K, typename T>
std::size_t HashMap<K, T>::size() const noexcept {
return m_keys.size();

View File

@@ -21,6 +21,7 @@
#include "stddef.hpp"
#include "strops.hpp"
#include "string.hpp"
#include "typeinfo.hpp"
#include "types.hpp"
#include "typetraits.hpp"
#include "vector.hpp"

34
deps/ox/src/ox/std/typeinfo.hpp vendored Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright 2015 - 2018 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
#if __has_include(<typeinfo>)
#include <typeinfo>
#else
namespace std {
// this is not at all guaranteed to work, and does not even fully comply with
// what little the standard does define
struct type_info {
private:
const char *m_name = "";
protected:
explicit type_info(const char *name): m_name(name) {
}
const char *name() {
return m_name;
}
};
}
#endif

View File

@@ -60,4 +60,23 @@ struct enable_if<true, T> {
using type = T;
};
template<typename T>
struct RemoveIndirection {
private:
template<typename ST>
static constexpr ST decay(ST t) {
return t;
}
template<typename ST>
static constexpr ST decay(ST *t) {
return decay(*t);
}
public:
using type = decltype(decay(static_cast<T*>(nullptr)));
};
}

View File

@@ -197,7 +197,7 @@ void Vector<T>::expandCap(std::size_t cap) noexcept {
m_items[i] = oldItems[i];
}
for (std::size_t i = itRange; i < m_cap; i++) {
m_items[i] = {};
m_items[i] = T();
}
delete[] oldItems;
}