#pragma once #include "accessors_impl.h" namespace NAccessors { /* * Adds API compatibility between different types representing memory regions. * * i.e. this will work: * * TString t; * const char* beg = NAccessors::Begin(t); // t.begin() * const char* end = NAccessors::End(t); // t.end() * size_t sz = NAccessors::Size(t); // t.size() * * as well as this: * * ui64 t; * const ui64* beg = NAccessors::Begin(t); // &t * const ui64* end = NAccessors::End(t); // &t + 1 * size_t sz = NAccessors::Size(t); // 1 * * Both will give you begin, end and size of the underlying memory region. */ template inline const typename TMemoryTraits::TElementType* Begin(const T& t) { return NPrivate::TBegin::Get(t); } template inline const typename TMemoryTraits::TElementType* End(const T& t) { return NPrivate::TEnd::Get(t); } template inline size_t Size(const T& t) { return End(t) - Begin(t); } /** * This gives some unification in terms of memory manipulation. */ template inline void Reserve(T& t, size_t sz) { NPrivate::TReserve::Do(t, sz); } template inline void Resize(T& t, size_t sz) { NPrivate::TResize::Do(t, sz); } template inline void Clear(T& t) { NPrivate::TClear::Do(t); } template inline void Init(T& t) { NPrivate::TClear::Do(t); } template inline void Append(T& t, const typename TMemoryTraits::TElementType& v) { NPrivate::TAppend::Do(t, v); } template inline void Append(T& t, const typename TMemoryTraits::TElementType* beg, const typename TMemoryTraits::TElementType* end) { NPrivate::TAppendRegion::Do(t, beg, end); } template inline void Assign(T& t, const typename TMemoryTraits::TElementType* beg, const typename TMemoryTraits::TElementType* end) { NPrivate::TAssign::Do(t, beg, end); } }