- fixed Buffer for PROCESSOR_BUFFER_USE_EXCEPTIONS not defined
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@1044 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -6,10 +6,11 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define EXC_MSG(code) (std::string(__PRETTY_FUNCTION__) + ", line " + std::to_string(__LINE__) + ", code " + std::to_string(code))
|
#define EXC_MSG(code) (std::string(__PRETTY_FUNCTION__) + ", line " + std::to_string(__LINE__) + ", code " + std::to_string(code))
|
||||||
|
#define EXC_EXCEPT(code) throw Buffer::Exception(EXC_MSG(code))
|
||||||
|
|
||||||
#ifdef PROCESSOR_BUFFER_USE_EXCEPTIONS
|
#ifdef PROCESSOR_BUFFER_USE_EXCEPTIONS
|
||||||
#define RETURN_OR_EXCEPT(code) throw Buffer::Exception(EXC_MSG(code))
|
#define RETURN_OR_EXCEPT(code) EXC_EXCEPT(code)
|
||||||
#else
|
#else
|
||||||
#define RETURN_OR_EXCEPT(code) return code
|
#define RETURN_OR_EXCEPT(code) return code
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ typename Buffer<T>::Result Buffer<T>::write(const T *pData, size_t len)
|
|||||||
{
|
{
|
||||||
if (len > free())
|
if (len > free())
|
||||||
{
|
{
|
||||||
printf("len : %u\n", len);
|
printf("len : %u\n", (unsigned)len);
|
||||||
printf("free : %u\n", free());
|
printf("free : %u\n", (unsigned)free());
|
||||||
printf("capa : %u\n", capacity());
|
printf("capa : %u\n", (unsigned)capacity());
|
||||||
RETURN_OR_EXCEPT(Result::Err_InvalidSize);
|
RETURN_OR_EXCEPT(Result::Err_InvalidSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ T Buffer<T>::readAt(size_t offset)
|
|||||||
{
|
{
|
||||||
if (m_len < (1+offset))
|
if (m_len < (1+offset))
|
||||||
{
|
{
|
||||||
RETURN_OR_EXCEPT(Result::Err_InvalidSize);
|
EXC_EXCEPT(Result::Err_InvalidSize);
|
||||||
}
|
}
|
||||||
size_t i = (m_ri + offset) % m_capacity;
|
size_t i = (m_ri + offset) % m_capacity;
|
||||||
T result = bufferActive()[i];
|
T result = bufferActive()[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user