SA_Logger
Sapphire's Suite's C++ Logger.
Loading...
Searching...
No Matches
Exception_OutOfArrayRange.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire's Suite. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_LOGGER_EXCEPTION_OUT_OF_ARRAY_RANGE_GUARD
6#define SAPPHIRE_LOGGER_EXCEPTION_OUT_OF_ARRAY_RANGE_GUARD
7
9
20namespace SA
21{
28 {
29 public:
41 template <typename U>
43 uint32_t _currIndex,
44 std::wstring _currIndexStr,
45 const U& _array,
46 std::wstring _arrayName = L"",
47 uint32_t _minBound = 0,
48 uint32_t _maxBound = uint32_t(-1)
49 ) noexcept :
50 Exception_OutOfRange(std::move(_info),
51 _currIndex,
52 _minBound < static_cast<uint32_t>(_array.size()) ? _minBound : static_cast<uint32_t>(_array.size()) - 1,
53 _maxBound < static_cast<uint32_t>(_array.size()) ? _maxBound : static_cast<uint32_t>(_array.size()) - 1,
54 L"")
55 {
56 // Post initialization to use min/max bounds variables.
57 msg = L"Index \'" + _currIndexStr + L"\' [" + ToWString(_currIndex) + L"] must be in array \'" + _arrayName +
58 L"\' range [" + ToWString(minBound) + L';' + ToWString(maxBound) + L']';
59 }
60 };
61
62
64
66 #define __SA_CREATE_EXCEPTION_OutOfArrayRange(_baseInfo, _currIndex, _array, ...) SA::Exception_OutOfArrayRange(\
67 _baseInfo,\
68 _currIndex,\
69 SA_WSTR(_currIndex),\
70 _array,\
71 SA_WSTR(_array),\
72 ##__VA_ARGS__\
73 )
74
76}
77
78
87#endif // GUARD
OutOfRange Exception type implementation.
std::wstring ToWString(const Log &_log)
ToWString implementation for log.
OutOfArrayRange Exception type.
Definition Exception_OutOfArrayRange.hpp:28
Exception_OutOfArrayRange(BaseInfo _info, uint32_t _currIndex, std::wstring _currIndexStr, const U &_array, std::wstring _arrayName=L"", uint32_t _minBound=0, uint32_t _maxBound=uint32_t(-1)) noexcept
Definition Exception_OutOfArrayRange.hpp:42
OutOfRange Exception type.
Definition Exception_OutOfRange.hpp:28
uint32_t minBound
Minimum bound included.
Definition Exception_OutOfRange.hpp:34
uint32_t maxBound
Maximum bound included.
Definition Exception_OutOfRange.hpp:37
std::wstring msg
User string message.
Definition Log.hpp:37
Base exception create info.
Definition Exception.hpp:28