util/{Const,Writable}Buffer: drop "_type" from type names
Behave like STL.
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
template<>
|
||||
AllocatedString<char>
|
||||
AllocatedString<char>::Duplicate(const_pointer_type src)
|
||||
AllocatedString<char>::Duplicate(const_pointer src)
|
||||
{
|
||||
return Duplicate(src, StringLength(src));
|
||||
}
|
||||
@@ -41,7 +41,7 @@ AllocatedString<char>::Duplicate(const_pointer_type src)
|
||||
|
||||
template<>
|
||||
AllocatedString<wchar_t>
|
||||
AllocatedString<wchar_t>::Duplicate(const_pointer_type src)
|
||||
AllocatedString<wchar_t>::Duplicate(const_pointer src)
|
||||
{
|
||||
return Duplicate(src, StringLength(src));
|
||||
}
|
||||
|
@@ -46,16 +46,16 @@ public:
|
||||
typedef typename StringPointer<T>::value_type value_type;
|
||||
typedef typename StringPointer<T>::reference_type reference_type;
|
||||
typedef typename StringPointer<T>::const_reference_type const_reference_type;
|
||||
typedef typename StringPointer<T>::pointer_type pointer_type;
|
||||
typedef typename StringPointer<T>::const_pointer_type const_pointer_type;
|
||||
typedef typename StringPointer<T>::pointer pointer;
|
||||
typedef typename StringPointer<T>::const_pointer const_pointer;
|
||||
typedef std::size_t size_type;
|
||||
|
||||
static constexpr value_type SENTINEL = '\0';
|
||||
|
||||
private:
|
||||
pointer_type value;
|
||||
pointer value;
|
||||
|
||||
explicit AllocatedString(pointer_type _value)
|
||||
explicit AllocatedString(pointer _value)
|
||||
:value(_value) {}
|
||||
|
||||
public:
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
delete[] value;
|
||||
}
|
||||
|
||||
static AllocatedString Donate(pointer_type value) {
|
||||
static AllocatedString Donate(pointer value) {
|
||||
return AllocatedString(value);
|
||||
}
|
||||
|
||||
@@ -82,16 +82,16 @@ public:
|
||||
return Donate(p);
|
||||
}
|
||||
|
||||
static AllocatedString Duplicate(const_pointer_type src);
|
||||
static AllocatedString Duplicate(const_pointer src);
|
||||
|
||||
static AllocatedString Duplicate(const_pointer_type begin,
|
||||
const_pointer_type end) {
|
||||
static AllocatedString Duplicate(const_pointer begin,
|
||||
const_pointer end) {
|
||||
auto p = new value_type[end - begin + 1];
|
||||
*std::copy(begin, end, p) = SENTINEL;
|
||||
return Donate(p);
|
||||
}
|
||||
|
||||
static AllocatedString Duplicate(const_pointer_type begin,
|
||||
static AllocatedString Duplicate(const_pointer begin,
|
||||
size_type length) {
|
||||
auto p = new value_type[length + 1];
|
||||
*std::copy_n(begin, length, p) = SENTINEL;
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
return value == nullptr;
|
||||
}
|
||||
|
||||
constexpr const_pointer_type c_str() const {
|
||||
constexpr const_pointer c_str() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
return *value == SENTINEL;
|
||||
}
|
||||
|
||||
constexpr pointer_type data() const {
|
||||
constexpr pointer data() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
return value[i];
|
||||
}
|
||||
|
||||
pointer_type Steal() {
|
||||
pointer Steal() {
|
||||
return std::exchange(value, nullptr);
|
||||
}
|
||||
|
||||
|
@@ -246,7 +246,7 @@ struct FunctionTraits<R(Args...) noexcept(NoExcept)> {
|
||||
* A function pointer type which describes the "plain"
|
||||
* function signature.
|
||||
*/
|
||||
typedef R (*pointer_type)(Args...)
|
||||
typedef R (*pointer)(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
@@ -289,12 +289,12 @@ struct BindFunctionWrapperGenerator<R(Args...) noexcept(NoExcept), P, function>
|
||||
: BindFunctionWrapperGenerator2<NoExcept, P, function, R, Args...> {
|
||||
};
|
||||
|
||||
template<typename T, typename T::pointer_type function>
|
||||
template<typename T, typename T::pointer function>
|
||||
typename MethodWrapperWithSignature<typename T::function_type>::function_pointer
|
||||
MakeBindFunctionWrapper() noexcept
|
||||
{
|
||||
return BindFunctionWrapperGenerator<typename T::function_type,
|
||||
typename T::pointer_type,
|
||||
typename T::pointer,
|
||||
function>::Invoke;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ BindMethod(T &_instance) noexcept
|
||||
* @param T the #FunctionTraits class
|
||||
* @param function the function pointer
|
||||
*/
|
||||
template<typename T, typename T::pointer_type function>
|
||||
template<typename T, typename T::pointer function>
|
||||
constexpr BoundMethod<typename T::function_type>
|
||||
BindFunction() noexcept
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ template<typename T>
|
||||
class CircularBuffer {
|
||||
public:
|
||||
typedef WritableBuffer<T> Range;
|
||||
typedef typename Range::pointer_type pointer_type;
|
||||
typedef typename Range::pointer pointer;
|
||||
typedef typename Range::size_type size_type;
|
||||
|
||||
protected:
|
||||
@@ -66,10 +66,10 @@ protected:
|
||||
size_type tail;
|
||||
|
||||
const size_type capacity;
|
||||
const pointer_type data;
|
||||
const pointer data;
|
||||
|
||||
public:
|
||||
constexpr CircularBuffer(pointer_type _data, size_type _capacity)
|
||||
constexpr CircularBuffer(pointer _data, size_type _capacity)
|
||||
:head(0), tail(0), capacity(_capacity), data(_data) {}
|
||||
|
||||
CircularBuffer(const CircularBuffer &other) = delete;
|
||||
|
@@ -45,12 +45,12 @@ template<>
|
||||
struct ConstBuffer<void> {
|
||||
typedef std::size_t size_type;
|
||||
typedef void value_type;
|
||||
typedef const void *pointer_type;
|
||||
typedef pointer_type const_pointer_type;
|
||||
typedef pointer_type iterator;
|
||||
typedef pointer_type const_iterator;
|
||||
typedef const void *pointer;
|
||||
typedef pointer const_pointer;
|
||||
typedef pointer iterator;
|
||||
typedef pointer const_iterator;
|
||||
|
||||
pointer_type data;
|
||||
pointer data;
|
||||
size_type size;
|
||||
|
||||
ConstBuffer() = default;
|
||||
@@ -58,7 +58,7 @@ struct ConstBuffer<void> {
|
||||
constexpr ConstBuffer(std::nullptr_t) noexcept
|
||||
:data(nullptr), size(0) {}
|
||||
|
||||
constexpr ConstBuffer(pointer_type _data, size_type _size) noexcept
|
||||
constexpr ConstBuffer(pointer _data, size_type _size) noexcept
|
||||
:data(_data), size(_size) {}
|
||||
|
||||
constexpr static ConstBuffer<void> FromVoid(ConstBuffer<void> other) noexcept {
|
||||
@@ -95,12 +95,12 @@ struct ConstBuffer {
|
||||
typedef T value_type;
|
||||
typedef const T &reference_type;
|
||||
typedef reference_type const_reference_type;
|
||||
typedef const T *pointer_type;
|
||||
typedef pointer_type const_pointer_type;
|
||||
typedef pointer_type iterator;
|
||||
typedef pointer_type const_iterator;
|
||||
typedef const T *pointer;
|
||||
typedef pointer const_pointer;
|
||||
typedef pointer iterator;
|
||||
typedef pointer const_iterator;
|
||||
|
||||
pointer_type data;
|
||||
pointer data;
|
||||
size_type size;
|
||||
|
||||
ConstBuffer() = default;
|
||||
@@ -108,10 +108,10 @@ struct ConstBuffer {
|
||||
constexpr ConstBuffer(std::nullptr_t) noexcept
|
||||
:data(nullptr), size(0) {}
|
||||
|
||||
constexpr ConstBuffer(pointer_type _data, size_type _size) noexcept
|
||||
constexpr ConstBuffer(pointer _data, size_type _size) noexcept
|
||||
:data(_data), size(_size) {}
|
||||
|
||||
constexpr ConstBuffer(pointer_type _data, pointer_type _end) noexcept
|
||||
constexpr ConstBuffer(pointer _data, pointer _end) noexcept
|
||||
:data(_data), size(_end - _data) {}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ struct ConstBuffer {
|
||||
*/
|
||||
static constexpr ConstBuffer<T> FromVoidFloor(ConstBuffer<void> other) noexcept {
|
||||
static_assert(sizeof(T) > 0, "Empty base type");
|
||||
return ConstBuffer<T>(pointer_type(other.data),
|
||||
return ConstBuffer<T>(pointer(other.data),
|
||||
other.size / sizeof(T));
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ struct ConstBuffer {
|
||||
* Move the front pointer to the given address, and adjust the
|
||||
* size attribute to retain the old end address.
|
||||
*/
|
||||
void MoveFront(pointer_type new_data) noexcept {
|
||||
void MoveFront(pointer new_data) noexcept {
|
||||
#ifndef NDEBUG
|
||||
assert(IsNull() == (new_data == nullptr));
|
||||
assert(new_data <= end());
|
||||
@@ -296,7 +296,7 @@ struct ConstBuffer {
|
||||
* Move the end pointer to the given address (by adjusting the
|
||||
* size).
|
||||
*/
|
||||
void SetEnd(pointer_type new_end) noexcept {
|
||||
void SetEnd(pointer new_end) noexcept {
|
||||
#ifndef NDEBUG
|
||||
assert(IsNull() == (new_end == nullptr));
|
||||
assert(new_end >= begin());
|
||||
|
@@ -41,8 +41,8 @@ template<typename T>
|
||||
class DynamicFifoBuffer : protected ForeignFifoBuffer<T> {
|
||||
public:
|
||||
using typename ForeignFifoBuffer<T>::size_type;
|
||||
using typename ForeignFifoBuffer<T>::pointer_type;
|
||||
using typename ForeignFifoBuffer<T>::const_pointer_type;
|
||||
using typename ForeignFifoBuffer<T>::pointer;
|
||||
using typename ForeignFifoBuffer<T>::const_pointer;
|
||||
using typename ForeignFifoBuffer<T>::Range;
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
* Write data to the buffer, growing it as needed. Returns a
|
||||
* writable pointer.
|
||||
*/
|
||||
pointer_type Write(size_type n) noexcept {
|
||||
pointer Write(size_type n) noexcept {
|
||||
WantWrite(n);
|
||||
return Write().data;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
/**
|
||||
* Append data to the buffer, growing it as needed.
|
||||
*/
|
||||
void Append(const_pointer_type p, size_type n) noexcept {
|
||||
void Append(const_pointer p, size_type n) noexcept {
|
||||
std::copy_n(p, n, Write(n));
|
||||
Append(n);
|
||||
}
|
||||
|
@@ -53,8 +53,8 @@ class ForeignFifoBuffer {
|
||||
public:
|
||||
using size_type = std::size_t;
|
||||
using Range = WritableBuffer<T>;
|
||||
using pointer_type = typename Range::pointer_type;
|
||||
using const_pointer_type = typename Range::const_pointer_type;
|
||||
using pointer = typename Range::pointer;
|
||||
using const_pointer = typename Range::const_pointer;
|
||||
|
||||
protected:
|
||||
size_type head = 0, tail = 0, capacity;
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
head += n;
|
||||
}
|
||||
|
||||
size_type Read(pointer_type p, size_type n) noexcept {
|
||||
size_type Read(pointer p, size_type n) noexcept {
|
||||
auto range = Read();
|
||||
if (n > range.size)
|
||||
n = range.size;
|
||||
|
@@ -39,17 +39,17 @@ public:
|
||||
typedef T value_type;
|
||||
typedef T &reference_type;
|
||||
typedef const T &const_reference_type;
|
||||
typedef T *pointer_type;
|
||||
typedef const T *const_pointer_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
|
||||
static constexpr value_type SENTINEL = '\0';
|
||||
|
||||
private:
|
||||
const_pointer_type value;
|
||||
const_pointer value;
|
||||
|
||||
public:
|
||||
StringPointer() = default;
|
||||
constexpr StringPointer(const_pointer_type _value)
|
||||
constexpr StringPointer(const_pointer _value)
|
||||
:value(_value) {}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
return value == nullptr;
|
||||
}
|
||||
|
||||
constexpr const_pointer_type c_str() const {
|
||||
constexpr const_pointer c_str() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ template<typename T>
|
||||
struct BasicStringView : ConstBuffer<T> {
|
||||
using typename ConstBuffer<T>::size_type;
|
||||
using typename ConstBuffer<T>::value_type;
|
||||
using typename ConstBuffer<T>::pointer_type;
|
||||
using typename ConstBuffer<T>::pointer;
|
||||
|
||||
using ConstBuffer<T>::data;
|
||||
using ConstBuffer<T>::size;
|
||||
@@ -57,14 +57,13 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
explicit constexpr BasicStringView(ConstBuffer<void> src)
|
||||
:ConstBuffer<T>(ConstBuffer<T>::FromVoid(src)) {}
|
||||
|
||||
constexpr BasicStringView(pointer_type _data, size_type _size) noexcept
|
||||
constexpr BasicStringView(pointer _data, size_type _size) noexcept
|
||||
:ConstBuffer<T>(_data, _size) {}
|
||||
|
||||
constexpr BasicStringView(pointer_type _begin,
|
||||
pointer_type _end) noexcept
|
||||
constexpr BasicStringView(pointer _begin, pointer _end) noexcept
|
||||
:ConstBuffer<T>(_begin, _end - _begin) {}
|
||||
|
||||
BasicStringView(pointer_type _data) noexcept
|
||||
BasicStringView(pointer _data) noexcept
|
||||
:ConstBuffer<T>(_data,
|
||||
_data != nullptr ? StringLength(_data) : 0) {}
|
||||
|
||||
@@ -90,12 +89,12 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
using ConstBuffer<T>::skip_front;
|
||||
|
||||
gcc_pure
|
||||
pointer_type Find(value_type ch) const noexcept {
|
||||
pointer Find(value_type ch) const noexcept {
|
||||
return StringFind(data, ch, this->size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
pointer_type FindLast(value_type ch) const noexcept {
|
||||
pointer FindLast(value_type ch) const noexcept {
|
||||
return StringFindLast(data, ch, size);
|
||||
}
|
||||
|
||||
|
@@ -46,12 +46,12 @@ template<>
|
||||
struct WritableBuffer<void> {
|
||||
typedef std::size_t size_type;
|
||||
typedef void value_type;
|
||||
typedef void *pointer_type;
|
||||
typedef const void *const_pointer_type;
|
||||
typedef pointer_type iterator;
|
||||
typedef const_pointer_type const_iterator;
|
||||
typedef void *pointer;
|
||||
typedef const void *const_pointer;
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
|
||||
pointer_type data;
|
||||
pointer data;
|
||||
size_type size;
|
||||
|
||||
WritableBuffer() = default;
|
||||
@@ -59,7 +59,7 @@ struct WritableBuffer<void> {
|
||||
constexpr WritableBuffer(std::nullptr_t) noexcept
|
||||
:data(nullptr), size(0) {}
|
||||
|
||||
constexpr WritableBuffer(pointer_type _data, size_type _size) noexcept
|
||||
constexpr WritableBuffer(pointer _data, size_type _size) noexcept
|
||||
:data(_data), size(_size) {}
|
||||
|
||||
constexpr operator ConstBuffer<void>() const noexcept {
|
||||
@@ -94,12 +94,12 @@ struct WritableBuffer {
|
||||
typedef T value_type;
|
||||
typedef T &reference_type;
|
||||
typedef const T &const_reference_type;
|
||||
typedef T *pointer_type;
|
||||
typedef const T *const_pointer_type;
|
||||
typedef pointer_type iterator;
|
||||
typedef const_pointer_type const_iterator;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
|
||||
pointer_type data;
|
||||
pointer data;
|
||||
size_type size;
|
||||
|
||||
WritableBuffer() = default;
|
||||
@@ -107,11 +107,10 @@ struct WritableBuffer {
|
||||
constexpr WritableBuffer(std::nullptr_t) noexcept
|
||||
:data(nullptr), size(0) {}
|
||||
|
||||
constexpr WritableBuffer(pointer_type _data, size_type _size) noexcept
|
||||
constexpr WritableBuffer(pointer _data, size_type _size) noexcept
|
||||
:data(_data), size(_size) {}
|
||||
|
||||
constexpr WritableBuffer(pointer_type _data,
|
||||
pointer_type _end) noexcept
|
||||
constexpr WritableBuffer(pointer _data, pointer _end) noexcept
|
||||
:data(_data), size(_end - _data) {}
|
||||
|
||||
/**
|
||||
@@ -131,7 +130,7 @@ struct WritableBuffer {
|
||||
*/
|
||||
static constexpr WritableBuffer<T> FromVoidFloor(WritableBuffer<void> other) noexcept {
|
||||
static_assert(sizeof(T) > 0, "Empty base type");
|
||||
return WritableBuffer<T>(pointer_type(other.data),
|
||||
return WritableBuffer<T>(pointer(other.data),
|
||||
other.size / sizeof(T));
|
||||
}
|
||||
|
||||
@@ -272,7 +271,7 @@ struct WritableBuffer {
|
||||
* Move the front pointer to the given address, and adjust the
|
||||
* size attribute to retain the old end address.
|
||||
*/
|
||||
void MoveFront(pointer_type new_data) noexcept {
|
||||
void MoveFront(pointer new_data) noexcept {
|
||||
#ifndef NDEBUG
|
||||
assert(IsNull() == (new_data == nullptr));
|
||||
assert(new_data <= end());
|
||||
@@ -286,7 +285,7 @@ struct WritableBuffer {
|
||||
* Move the end pointer to the given address (by adjusting the
|
||||
* size).
|
||||
*/
|
||||
void SetEnd(pointer_type new_end) noexcept {
|
||||
void SetEnd(pointer new_end) noexcept {
|
||||
#ifndef NDEBUG
|
||||
assert(IsNull() == (new_end == nullptr));
|
||||
assert(new_end >= begin());
|
||||
|
Reference in New Issue
Block a user