Skip to content

Commit

Permalink
user assert instead
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Dec 9, 2024
1 parent 809d816 commit f3ab091
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions jParser/base/src/main/resources/IDLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stddef.h> // NULL
#include <stdint.h> // intptr_t
#include <algorithm>
#include <stdexcept>
#include <assert.h>

template<typename T>
class IDLArray {
Expand All @@ -32,21 +32,15 @@ class IDLArray {
std::fill(data, data + size, T());
}
void copy(IDLArray<T>& src, int srcPos, int destPos, int length) {
if (srcPos < 0 || destPos < 0 || length < 0 || srcPos + length > src.size || destPos + length > size) {
throw std::out_of_range("Invalid copy range");
}
assert(srcPos < 0 || destPos < 0 || length < 0 || srcPos + length > src.size || destPos + length > size);
std::copy(src.data + srcPos, src.data + srcPos + length, data + destPos);
}
T getValue(int index) {
if (index < 0 || index >= size) {
throw std::out_of_range("Index out of range");
}
assert(index < 0 || index >= size);
return data[index];
}
void setValue(int index, T value) {
if (index < 0 || index >= size) {
throw std::out_of_range("Index out of range");
}
assert(index < 0 || index >= size);
data[index] = value;
}
int getSize() { return size; }
Expand Down

0 comments on commit f3ab091

Please sign in to comment.