[Warning: a couple files have long file names... which shouldn't be a problem
considering that this only works on OS/2 now, and can only be converted to
Win32, not DOS...]
All code posted in these six messages, as with all my messages, is given into
the public domain.
>>>>>>>>>> CSplit: Version 2.2 >>>>>>>>>>
>>>>>>>>>> CSplit: Begin part 1/6 >>>>>>>>>>
>>>>>>>>>> CSplit: Begin file error.h >>>>>>>>>>
//
// Error-reporting class
//
/*
Requires that type T can be compared to "0":
"0" is to be considered not an error
*/
#ifndef ERROR_HPP
#define ERROR_HPP
template class Error
{
private:
T m_t;
public:
Error(const T& _t) : m_t(_t) {}
~Error() {}
const T& GetError() const { return m_t; }
// operator bool() returns true if there is no error
// to make a return type easily available for an 'if'.
operator bool() const { return m_t == 0; }
};
template inline Error MakeError(const T& _t)
{ return Error(_t); }
#endif // ERROR_HPP
>>>>>>>>>> CSplit: End file error.h >>>>>>>>>>
>>>>>>>>>> CSplit: Begin file safequeue.h >>>>>>>>>>
//
// A "safe queue" implementation.
//
#ifndef MCBRIDE_SAFEQUEUE_H
#define MCBRIDE_SAFEQUEUE_H
#include "sem32.h"
#include
template class SafeQueue
{
public:
typedef T value_type;
typedef T* iterator;
typedef long size_type;
private:
void DoPush(const value_type& x)
{
m_iEnd[-1] = x;
if (++m_iEnd == BufferEnd())
{
m_iEnd = m_pBuffer + 1;
}
}
void DoPop()
{
m_iBegin++;
if (m_iBegin == BufferEnd())
{
m_iBegin = m_pBuffer;
}
}
value_type& _front() { return *m_iBegin; }
const value_type& _front() const { return *m_iBegin; }
public:
bool empty() const { SemUse su(m_msContainer); return m_iBegin + 1 \
\
== m_iEnd; }
size_type size() const
{
SemUse su(m_msContainer);
if (m_iEnd > m_iBegin)
return m_iEnd - m_iBegin - 1;
return m_stBufferSize - (m_iBegin - m_iEnd);
}
size_type roomleft() const { return m_stBufferSize - size(); }
value_type& front() { SemUse su(m_msContainer); return _front(); }
>>>>>>>>>> CSplit: End part 1/6 crc: 3135 >>>>>>>>>>
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)
|