Skip to content

Commit

Permalink
Type cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyssoul committed Mar 15, 2020
1 parent caee735 commit 683a5f1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
13 changes: 6 additions & 7 deletions include/solace/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ T* assertNull(T* value) {
* @param to Upper value bound (exclusive)
* @return Index value if the index is in range. Throws otherwise.
*/
uint16 assertIndexInRange(uint16 index, uint16 from, uint16 to);
uint16 assertValueInRange(uint16 index, uint16 from, uint16 to);

/**
* Assert that the give index is within the give range. Throw if it is not.
Expand All @@ -150,7 +150,7 @@ uint16 assertIndexInRange(uint16 index, uint16 from, uint16 to);
* @param to Upper value bound (exclusive)
* @return Index value if the index is in range. Throws otherwise.
*/
uint32 assertIndexInRange(uint32 index, uint32 from, uint32 to);
uint32 assertValueInRange(uint32 index, uint32 from, uint32 to);

/**
* Assert that the give index is within the give range. Throw if it is not.
Expand All @@ -160,7 +160,7 @@ uint32 assertIndexInRange(uint32 index, uint32 from, uint32 to);
* @param to Upper value bound (exclusive)
* @return Index value if the index is in range. Throws otherwise.
*/
uint64 assertIndexInRange(uint64 index, uint64 from, uint64 to);
uint64 assertValueInRange(uint64 index, uint64 from, uint64 to);


/**
Expand All @@ -172,7 +172,7 @@ uint64 assertIndexInRange(uint64 index, uint64 from, uint64 to);
*
* @return Index value if the index is in range. Throws otherwise.
*/
uint16 assertIndexInRange(uint16 index, uint16 from, uint16 to, const char* message);
uint16 assertValueInRange(uint16 index, uint16 from, uint16 to, const char* message);


/**
Expand All @@ -184,7 +184,7 @@ uint16 assertIndexInRange(uint16 index, uint16 from, uint16 to, const char* mess
*
* @return Index value if the index is in range. Throws otherwise.
*/
uint32 assertIndexInRange(uint32 index, uint32 from, uint32 to, const char* message);
uint32 assertValueInRange(uint32 index, uint32 from, uint32 to, const char* message);


/**
Expand All @@ -196,7 +196,7 @@ uint32 assertIndexInRange(uint32 index, uint32 from, uint32 to, const char* mess
*
* @return Index value if the index is in range. Throws otherwise.
*/
uint64 assertIndexInRange(uint64 index, uint64 from, uint64 to, const char* message);
uint64 assertValueInRange(uint64 index, uint64 from, uint64 to, const char* message);



Expand Down Expand Up @@ -231,4 +231,3 @@ uint64 assertIndexInRange(uint64 index, uint64 size, const char* message);

} // End of namespace Solace
#endif // SOLACE_ASSERT_HPP

6 changes: 3 additions & 3 deletions include/solace/memoryManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace Solace {
*/
class MemoryManager {
public:
using size_type = MutableMemoryView::size_type;
using value_type = MutableMemoryView::value_type;
using size_type = MemoryView::size_type;
using value_type = MemoryView::value_type;

using MemoryAddress = void *;
using MemoryAddress = MemoryView::MutableMemoryAddress;

public:

Expand Down
2 changes: 1 addition & 1 deletion include/solace/memoryResource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Solace {
class MemoryResource {
public:

using size_type = MutableMemoryView::size_type;
using size_type = MemoryView::size_type;


/**
Expand Down
2 changes: 1 addition & 1 deletion include/solace/memoryView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LIFETIME_HINT_POINTER(void) MemoryView {
using MutableMemoryAddress = void*;
using MemoryAddress = void const*;

using size_type = size_t;
using size_type = std::conditional<sizeof(MutableMemoryAddress) == 4, uint32, uint64>::type;
using value_type = byte;

using const_reference = value_type const&;
Expand Down
6 changes: 3 additions & 3 deletions include/solace/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ class Optional {

T const& get() const {
if (isNone()) {
raiseInvalidStateError();
raiseInvalidStateError("Optional<>::get");
}

return _payload;
}

T& get() {
if (isNone()) {
raiseInvalidStateError();
raiseInvalidStateError("Optional<>::get");
}

return _payload;
Expand All @@ -219,7 +219,7 @@ class Optional {

T&& move() {
if (isNone()) {
raiseInvalidStateError();
raiseInvalidStateError("Optional<>::move");
}

return mv(_payload);
Expand Down
16 changes: 8 additions & 8 deletions include/solace/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,25 +345,25 @@ Result {
V& operator* () { return unwrap(); }
V const& operator* () const { return unwrap(); }

V const& unwrap() const& {
V const& unwrap() const & {
if (isError()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::unwrap");
}

return _value;
}

V& unwrap() & {
if (isError()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::unwrap");
}

return _value;
}

V&& unwrap() && {
if (isError()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::unwrap");
}

return mv(_value);
Expand All @@ -372,31 +372,31 @@ Result {

V&& moveResult() {
if (isError()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::moveResult");
}

return mv(_value);
}

E&& moveError() {
if (isOk()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::moveError");
}

return mv(_error);
}

E& getError() {
if (isOk()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::getError");
}

return _error;
}

E const& getError() const {
if (isOk()) {
raiseInvalidStateError();
raiseInvalidStateError("Result<>::getError");
}

return _error;
Expand Down
15 changes: 6 additions & 9 deletions src/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace Solace;


uint16
Solace::assertIndexInRange(uint16 index, uint16 from, uint16 to) {
Solace::assertValueInRange(uint16 index, uint16 from, uint16 to) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to);
}
Expand All @@ -37,15 +37,15 @@ Solace::assertIndexInRange(uint16 index, uint16 from, uint16 to) {


uint32
Solace::assertIndexInRange(uint32 index, uint32 from, uint32 to) {
Solace::assertValueInRange(uint32 index, uint32 from, uint32 to) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to);
}

return index;
}

uint64 Solace::assertIndexInRange(uint64 index, uint64 from, uint64 to) {
uint64 Solace::assertValueInRange(uint64 index, uint64 from, uint64 to) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to);
}
Expand All @@ -54,23 +54,23 @@ uint64 Solace::assertIndexInRange(uint64 index, uint64 from, uint64 to) {
}


uint64 Solace::assertIndexInRange(uint64 index, uint64 from, uint64 to, const char* message) {
uint64 Solace::assertValueInRange(uint64 index, uint64 from, uint64 to, const char* message) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to, message);
}

return index;
}

uint32 Solace::assertIndexInRange(uint32 index, uint32 from, uint32 to, const char* message) {
uint32 Solace::assertValueInRange(uint32 index, uint32 from, uint32 to, const char* message) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to, message);
}

return index;
}

uint16 Solace::assertIndexInRange(uint16 index, uint16 from, uint16 to, const char* message) {
uint16 Solace::assertValueInRange(uint16 index, uint16 from, uint16 to, const char* message) {
if (index >= to || index < from) {
Solace::raise<IndexOutOfRangeException>(index, from, to, message);
}
Expand All @@ -80,9 +80,6 @@ uint16 Solace::assertIndexInRange(uint16 index, uint16 from, uint16 to, const ch






uint64 Solace::assertIndexInRange(uint64 index, uint64 size, const char* message) {
if (size <= index) {
Solace::raise<IndexOutOfRangeException>(index, decltype(size){0}, size, message);
Expand Down
2 changes: 1 addition & 1 deletion test/test_uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

using namespace Solace;

static constexpr size_t RandomSampleSize = 100;
static constexpr uint32 RandomSampleSize = 100;


TEST(TestUUID, testStaticConstraints) {
Expand Down

0 comments on commit 683a5f1

Please sign in to comment.