mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(array): add TSBaseArray<T>::CheckArrayBounds
This commit is contained in:
parent
a47059bd90
commit
67841ebf14
1 changed files with 20 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef STORM_ARRAY_TS_BASE_ARRAY_HPP
|
#ifndef STORM_ARRAY_TS_BASE_ARRAY_HPP
|
||||||
#define STORM_ARRAY_TS_BASE_ARRAY_HPP
|
#define STORM_ARRAY_TS_BASE_ARRAY_HPP
|
||||||
|
|
||||||
|
#include "storm/Error.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
|
@ -15,15 +16,34 @@ class TSBaseArray {
|
||||||
virtual int32_t MemLineNo() const;
|
virtual int32_t MemLineNo() const;
|
||||||
|
|
||||||
T& operator[](uint32_t index);
|
T& operator[](uint32_t index);
|
||||||
|
void CheckArrayBounds(uint32_t index) const;
|
||||||
uint32_t Count() const;
|
uint32_t Count() const;
|
||||||
void Clear();
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T& TSBaseArray<T>::operator[](uint32_t index) {
|
T& TSBaseArray<T>::operator[](uint32_t index) {
|
||||||
|
this->CheckArrayBounds(index);
|
||||||
return this->m_data[index];
|
return this->m_data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void TSBaseArray<T>::CheckArrayBounds(uint32_t index) const {
|
||||||
|
if (index < this->Count()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SErrDisplayErrorFmt(
|
||||||
|
0x85100080,
|
||||||
|
this->MemFileName(),
|
||||||
|
this->MemLineNo(),
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
"index (0x%08X), array size (0x%08X)",
|
||||||
|
index,
|
||||||
|
this->Count());
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
uint32_t TSBaseArray<T>::Count() const {
|
uint32_t TSBaseArray<T>::Count() const {
|
||||||
return this->m_count;
|
return this->m_count;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue