Commit 1fd82690 authored by SxBoeck's avatar SxBoeck

Merge branch 'feature/IteratorMove'

parents 05c6b8ca d601f264
AC_INIT([SxAccelerate],[2.5.2], [https://sxlib.mpie.de])
AC_INIT([SxAccelerate],[2.5.3], [https://sxlib.mpie.de])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([foreign])
......
......@@ -13,7 +13,7 @@
#
# ---------------------------------------------------------------------------
AC_INIT([S/PHI/nX Accelerate Libraries], [2.5.2], [https://sxlib.mpie.de], [sxaccelerate])
AC_INIT([S/PHI/nX Accelerate Libraries], [2.5.3], [https://sxlib.mpie.de], [sxaccelerate])
SHARED_VERSION_INFO="1:0:0"
AC_CANONICAL_HOST
......
......@@ -182,16 +182,16 @@ void SxFSAction::mkdir (const SxDir &subFolder,
void SxFSAction::mkdir_p (const SxString &destDir,
int umask)
{
SX_CHECK (destDir.removeWhiteSpace() != "");
SX_CHECK_VAR (!destDir.contains ("***"), destDir); // avoid markers
SX_CHECK (destDir.removeWhiteSpace() != "");
SX_CHECK (!destDir.contains ("***"), destDir); // avoid markers
SxFSAction::mkdir_p (SxDir (destDir), umask);
}
void SxFSAction::mkdir_p (const SxDir &destDir,
int umask)
{
SX_CHECK (destDir.getPath().removeWhiteSpace() != "");
SX_CHECK_VAR (!destDir.getPath().contains ("***"), destDir); // avoid markers
SX_CHECK (destDir.getPath().removeWhiteSpace() != "");
SX_CHECK (!destDir.getPath().contains ("***"), destDir); // avoid markers
SxFSCreateAction::mkdir_p (destDir, umask);
}
......
......@@ -242,7 +242,7 @@ int SxFileInfo::getMode () const
int SxFileInfo::getMode (const SxString &perms)
{
SX_CHECK_VAR (perms.getSize () == 9, perms);
SX_CHECK (perms.getSize () == 9, perms);
int res = 0;
if (perms(0) == 'r') res += 0400;
if (perms(1) == 'w') res += 0200;
......@@ -892,7 +892,7 @@ SxFileInfo operator/ (const SxFileInfo &a, const SxString &b)
SX_DBG_TRACE("");
// Checking input arguments
SX_CHECK (b != SxString ());
SX_CHECK_VAR (a.getAbsPath ().getSize() > 0, a.getAbsPath ().getSize());
SX_CHECK (a.getAbsPath ().getSize() > 0, a.getAbsPath ().getSize());
SX_CHECK (SxFileInfo::isAbs (a.getAbsPath ())); // only storing absolute
// paths
// Returning the concatenated absolute path and string
......@@ -906,7 +906,7 @@ SxFileInfo operator/ (const SxString &a, const SxFileInfo &b)
SX_DBG_TRACE("");
// Checking input arguments
SX_CHECK (a != SxString ());
SX_CHECK_VAR (b.getAbsPath ().getSize() > 0, b.getAbsPath ().getSize());
SX_CHECK (b.getAbsPath ().getSize() > 0, b.getAbsPath ().getSize());
SX_CHECK (SxFileInfo::isAbs (b.getAbsPath ())); // only storing absolute
// paths
// Returning the concatenated string and absolute path
......@@ -918,7 +918,7 @@ SxFileInfo operator+ (const SxFileInfo &a, const SxString &b)
SX_DBG_TRACE("");
// Checking input arguments
SX_CHECK (b != SxString ());
SX_CHECK_VAR (a.getAbsPath ().getSize() > 0, a.getAbsPath ().getSize());
SX_CHECK (a.getAbsPath ().getSize() > 0, a.getAbsPath ().getSize());
SX_CHECK (SxFileInfo::isAbs (a.getAbsPath ())); // only storing absolute
// paths
// Returning the concatenated absolute path and string
......@@ -930,7 +930,7 @@ SxFileInfo operator+ (const SxString &a, const SxFileInfo &b)
SX_DBG_TRACE("");
// Checking input arguments
SX_CHECK (a != SxString ());
SX_CHECK_VAR (b.getAbsPath ().getSize() > 0, b.getAbsPath ().getSize());
SX_CHECK (b.getAbsPath ().getSize() > 0, b.getAbsPath ().getSize());
SX_CHECK (SxFileInfo::isAbs (b.getAbsPath ())); // only storing absolute
// paths
// Returning the concatenated string and absolute path
......
......@@ -72,18 +72,18 @@ void SxFileParser::updateLine ()
size_t nn =
#endif
fread (buffer, sizeof(char), n, fp);
SX_CHECK_VARS (nn == n, nn, n);
SX_CHECK (nn == n, nn, n);
for (size_t i = 0; i < n; ++i)
if (buffer[i] == '\n') line++;
fpos += (long)n;
}
SX_CHECK_VARS (currentPos == ftell (fp), currentPos, ftell(fp));
SX_CHECK (currentPos == ftell (fp), currentPos, ftell(fp));
fpos = currentPos;
}
void SxFileParser::nextLine (int nLine)
{
SX_CHECK_VAR (nLine > 0, nLine);
SX_CHECK (nLine > 0, nLine);
updateLine ();
while (!feof (fp)) {
if (fgetc (fp) == '\n') {
......@@ -256,7 +256,7 @@ SxArray<double> SxFileParser::getVector ()
SxArray<double> SxFileParser::getVector (ssize_t n)
{
SX_CHECK (fp);
SX_CHECK_VAR (n > 0, n);
SX_CHECK (n > 0, n);
noEof ();
SxArray<double> res(n);
for (ssize_t i = 0; i < n; ++i) {
......
......@@ -38,8 +38,8 @@ SxPluginManager::~SxPluginManager ()
for (it = ids.begin(); it != ids.end(); ++it, ++i) {
// --- we cannot close a shared object if it is still in use!
SX_CHECK_VARS (pluginRefCounter(*it) == 0,
pluginRefCounter(*it), ids(i));
SX_CHECK (pluginRefCounter(*it) == 0,
pluginRefCounter(*it), ids(i));
plugins(*it)->closeSharedObject ();
}
......
......@@ -230,9 +230,9 @@ int SxMPIMgr::updateProcs ()
if (procUnits.getSize() > nProcs) {
sxprintf ("ERROR: Not enough free processes available.\n");
sxprintf (" nProcs = %d, maxProcs = %d.\n",
(int)procUnits.getSize(), nProcs);
SX_CHECK_VARS (procUnits.getSize() <= nProcs,
procUnits.getSize(), nProcs);
(int)procUnits.getSize(), nProcs);
SX_CHECK (procUnits.getSize() <= nProcs,
procUnits.getSize(), nProcs);
SX_QUIT;
}
......
......@@ -72,7 +72,7 @@ ssize_t SxProcUnitGroup::getNextGroupId ()
void SxProcUnitGroup::removeGroup (const SxPtr<SxProcUnitGroup> &grp)
{
SX_CHECK (grp);
SX_CHECK_VARS (groups.contains (grp), groupId, grp->groupId);
SX_CHECK (groups.contains (grp), groupId, grp->groupId);
// --- remove all nested groups
SxList<SxPtr<SxProcUnitGroup> >::Iterator grpIt;
......
......@@ -1154,7 +1154,7 @@ void SxProcess::run (const SxList<SxString> &env)
keyValuePair = (*it).tokenize('=');
// --- check 'key=value'
SX_CHECK_VAR (keyValuePair.getSize() == 2, keyValuePair.getSize());
SX_CHECK (keyValuePair.getSize() == 2, keyValuePair.getSize());
setenv (key, value);
}
......@@ -1647,7 +1647,7 @@ void SxProcess::readBufferLineWise (int FD, SxPtr<SxArray<char>> *bufferPtr,
void SxProcess::readLineWise (bool useStderr)
{
SX_CHECK_VAR (bufLen > 0, bufLen);
SX_CHECK (bufLen > 0, bufLen);
SxPtr<SxArray<char>> outBufferPtr, errBufferPtr;
if (channels & StdOut)
......@@ -1731,7 +1731,7 @@ void SxProcess::readLineWise (bool useStderr)
void SxProcess::readBuffer (int FD)
{
SX_CHECK_VAR (bufLen > 0, bufLen);
SX_CHECK (bufLen > 0, bufLen);
SxList<SxPtr<SxArray<char>>> bufferList;
SxList<ssize_t> bufferSizeList;
// --- read from child's STDOUT/STDERR
......@@ -2191,17 +2191,17 @@ void SxProcess::finishExecution ()
void SxProcess::closePipeIdx (int stdStreamFd, uint8_t idx)
{
SX_CHECK_VAR (idx == 0 || idx == 1, idx);
SX_CHECK (idx == 0 || idx == 1, idx);
#ifdef WIN32
SX_CHECK_VAR (stdStreamFd == STDIN_FILENO || stdStreamFd == STDOUT_FILENO
|| stdStreamFd == STDERR_FILENO, stdStreamFd);
SX_CHECK (stdStreamFd == STDIN_FILENO || stdStreamFd == STDOUT_FILENO
|| stdStreamFd == STDERR_FILENO, stdStreamFd);
if (pipes[stdStreamFd].handles[idx] != INVALID_HANDLE_VALUE) {
::CloseHandle (pipes[stdStreamFd].handles[idx]);
pipes[stdStreamFd].handles[idx] = INVALID_HANDLE_VALUE;
}
#else
SX_CHECK_VAR (stdStreamFd >= STDIN_FILENO && stdStreamFd <= STDERR_FILENO,
stdStreamFd);
SX_CHECK (stdStreamFd >= STDIN_FILENO && stdStreamFd <= STDERR_FILENO,
stdStreamFd);
if (pipes[stdStreamFd].fds[idx] >= 0) {
::close (pipes[stdStreamFd].fds[idx]);
pipes[stdStreamFd].fds[idx] = -1;
......@@ -2236,10 +2236,10 @@ void SxProcess::closeStdStream (int stdStreamFd)
#ifndef WIN32
int SxProcess::getPipeFd (int stdStreamFd) const
{
SX_CHECK_VAR (stdStreamFd >= STDIN_FILENO && stdStreamFd <= STDERR_FILENO,
stdStreamFd);
SX_CHECK (stdStreamFd >= STDIN_FILENO && stdStreamFd <= STDERR_FILENO,
stdStreamFd);
int res = pipes[stdStreamFd].fds[(stdStreamFd == STDIN_FILENO) ? 1 : 0];
SX_CHECK_VAR (res >= 0, res);
SX_CHECK (res >= 0, res);
return res;
}
#endif
......
......@@ -37,7 +37,7 @@ SxTask::SxTask (const SxPtr<SxProcUnit> &task_,
task(task_),
prioPoints (0)
{
SX_CHECK_VAR (priority >= 0 && priority < MaxPriority, priority);
SX_CHECK (priority >= 0 && priority < MaxPriority, priority);
SX_CHECK (task->group.getPtr() == NULL);
timer.start (Spooling);
}
......
......@@ -303,7 +303,7 @@ void SxThreadPool::resizePool (ssize_t nThreads_)
<< " to " << nThreads_ << " threads");
ssize_t nOld = pool.getSize ();
SX_CHECK_VARS (nThreads_ >= nOld, nThreads_, nOld);
SX_CHECK (nThreads_ >= nOld, nThreads_, nOld);
if (nThreads_ == nOld) {
return;
......@@ -346,7 +346,7 @@ SxArray<SxList<SxTask> > tasks; // :priority
void SxThreadPool::submit (const SxTask &task)
{
for (int i=0; i < 100; i++) {
SX_CHECK_VAR (tasks(i).getSize() == 0, tasks(i).getSize());
SX_CHECK (tasks(i).getSize() == 0, tasks(i).getSize());
}
tasks(task.getPriority()) << task;
nTasks++;
......
......@@ -7,6 +7,11 @@ p1. The 2.5 branch improves the performance of common containers by implementing
to be able to take advantage of r-value references, hence avoid excessive
creation of temporary variables.
h3. SxAccelerate 2.5.3
p1. All iterators have been extended to support move semantics as well.
The handling of class hierarchies with @SxPtr<T>@ has been improved.
h3. SxAccelerate 2.5.2
p1. The 2.5.2 version is a fix addressing the removal of the experimental
......
......@@ -32,8 +32,6 @@
list.foreach ([](Iterator &it) { cout << *it << endl; });
\author Sixten Boeck, boeck@dacs-labs.com */
// see also
......@@ -45,7 +43,9 @@ namespace sx
{
// Enum for iterator direction
enum Direction {Undefined, Forward, Backward, Both};
enum ItCopyMode {NoCopy=0x01, CopyItMeta=0x02, CopyItData=0x04, CopyAll=0x08};
// iterate over all elements
template<class Iterator, class Function>
void foreach (Iterator it, Iterator end, Function fn)
......@@ -113,7 +113,7 @@ namespace sx
Iterator tmpIt = it, tmpIt2 = it, itPrev = it;
bool forward = it.isForward ();
if (forward) ++lastIt;
else --lastIt;
......@@ -123,11 +123,11 @@ namespace sx
itPrev = it;
if (forward) ++tmpIt;
else --tmpIt;
SX_CHECK(tmpIt.isValid ());
SX_CHECK(tmpIt.isValid ());
while (tmpIt != lastIt) {
SX_CHECK(tmpIt.isValid ());
SX_CHECK(itPrev.isValid ());
if (comp(tmpIt,itPrev) == -1) {
auto val = *tmpIt;
*tmpIt = *itPrev;
......@@ -143,7 +143,7 @@ namespace sx
else --tmpIt2;
}
}
template<class Iterator>
void sort (Iterator it, Iterator lastIt)
{
......@@ -155,8 +155,6 @@ namespace sx
}
// sort using quick sort [it, lastIt]
template<class Iterator>
void qsort (Iterator it, Iterator lastIt,
......@@ -165,7 +163,7 @@ namespace sx
{
SX_CHECK(it.isValid ());
SX_CHECK(lastIt.isValid ());// should point to a valid element
if (it == lastIt) return;
bool forward = it.isForward ();
......@@ -181,7 +179,7 @@ namespace sx
while ((leftIt != rightIt) && (comp(leftIt,it) != 1)) {
if (forward) ++leftIt;
else --leftIt;
SX_CHECK(leftIt.isValid ());
SX_CHECK(leftIt.isValid ());
}
while ((leftIt != rightIt) && (comp(rightIt,it) == 1)) {
if (forward) --rightIt;
......@@ -202,7 +200,7 @@ namespace sx
*leftIt = pivotVal;
pivotIt = leftIt;
Iterator pivPrevIt = pivotIt;
Iterator pivPrevIt = pivotIt;
Iterator pivNextIt = pivotIt;
if (forward) {--pivPrevIt; ++pivNextIt;}
else {++pivPrevIt; --pivNextIt;}
......@@ -214,7 +212,7 @@ namespace sx
template<class Iterator>
void qsort (Iterator it, Iterator lastIt)
{
{
sx::qsort<Iterator> (it, lastIt, [](const Iterator &itA, const Iterator &itB)->int
{ if (*itA < *itB) return -1;
else if (*itA == *itB) return 0;
......
This diff is collapsed.
......@@ -20,7 +20,7 @@
#include <SxError.h>
/** \brief Automatic loops
This is a simple auxiliary class to enable automatic loops over
containers. The container will provide the actual loop limit.
......@@ -124,9 +124,9 @@ SX_LOOP(iDir(3))
/// Set/check the limit by an auto-loop compatible container
void setLimit (ssize_t limit_) const
{
SX_CHECK_VAR (limit_ > 0, limit_);
SX_CHECK (limit_ > 0, limit_);
if (limit != -1) {
SX_CHECK_VARS (limit == limit_, limit, limit_);
SX_CHECK (limit == limit_, limit, limit_);
} else {
limit = limit_;
}
......@@ -136,7 +136,7 @@ SX_LOOP(iDir(3))
void operator++ ()
{
// limit must be set somewhere in the loop body
SX_CHECK_VAR (limit > 0, limit);
SX_CHECK (limit > 0, limit);
++i;
}
......
......@@ -44,7 +44,7 @@ SxBitArray::SxBitArray (SxBitArray &&rhs) :
// -- Creates a bit array from int array
SxBitArray::SxBitArray (const SxArray<int> &in_)
{
SX_CHECK_VAR (in_.getSize() >= 0, in_.getSize());
SX_CHECK (in_.getSize() >= 0, in_.getSize());
size_t i;
size_t n;
......@@ -181,7 +181,7 @@ SxBitArray &SxBitArray::operator= (SxBitArray &&rhs)
bool SxBitArray::operator() (size_t iBit) const
{
SX_CHECK_VARS (iBit < nBits, iBit, nBits);
SX_CHECK (iBit < nBits, iBit, nBits);
size_t iChr = iBit / (sizeof (unsigned char) * 8);
size_t mod = iBit - iChr * (sizeof (unsigned char) * 8);
unsigned char testChr = bytes(iChr);
......
......@@ -24,7 +24,7 @@
\b SxCBoundPtr S/PHI/nX (unsafe) C-like bound-pointers
\par Warning
The usage of this class is unsafe. If not sure please use SxFunction
instead! SxFunction monitors the object's lifetime.
......@@ -33,7 +33,7 @@
global functions and to member functions.
\code
// --- functions with signature 'void foo(const SxString &)'
// --- functions with signature 'void foo(const SxString &)'
// (1) global function
void foo (const SxString &) { printf ("this is foo\n"); }
......@@ -68,7 +68,7 @@ of invalid bound pointers.
\author Sixten Boeck, boeck@mpie.de
*/
template<class RES,
template<class RES,
class P1 = SxNull, class P2 = SxNull, class P3 = SxNull,
class P4 = SxNull, class P5 = SxNull, class P6 = SxNull
>
......@@ -145,32 +145,32 @@ class SxCBoundPtr : public SxFunctor<RES,P1,P2,P3,P4,P5,P6>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(),RES> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1),RES,P1> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2),RES,P1,P2> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3),RES,P1,P2,P3> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4),RES,P1,P2,P3,P4> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4,class TP5>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4,TP5),RES,P1,P2,P3,P4,P5> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4,class TP5,class TP6>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4,TP5,TP6),RES,P1,P2,P3,P4,P5,P6> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
......@@ -181,32 +181,32 @@ class SxCBoundPtr : public SxFunctor<RES,P1,P2,P3,P4,P5,P6>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)()const,RES> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1)const,RES,P1> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2)const,RES,P1,P2> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3)const,RES,P1,P2,P3> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4)const,RES,P1,P2,P3,P4> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4,class TP5>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4,TP5)const,RES,P1,P2,P3,P4,P5> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
template<class Callee, class TRES, class Class,
template<class Callee, class TRES, class Class,
class TP1,class TP2,class TP3, class TP4,class TP5,class TP6>
SxCBoundPtr (const SxMemTranslator<Callee,TRES (Class::*)(TP1,TP2,TP3,TP4,TP5,TP6)const,RES,P1,P2,P3,P4,P5,P6> &in)
: SxFunctor<RES,P1,P2,P3,P4,P5,P6> (in) { /* empty */ }
......@@ -216,7 +216,7 @@ class SxCBoundPtr : public SxFunctor<RES,P1,P2,P3,P4,P5,P6>
// --------------------------------------------------------------------
template<class TRES, class TP1>
static SxFuncTranslator<TRES (*)(TP1),RES,P1>
static SxFuncTranslator<TRES (*)(TP1),RES,P1>
create (TRES (*f)(TP1), const char *tag_ = NULL)
{
return SxFuncTranslator<TRES (*)(TP1),RES,P1> (f, tag_);
......
......@@ -441,11 +441,11 @@ void SxCLI::CliArg::setDefault(const SxString& def,
int SxCLI::CliArg::toInt (Given<int> def, Given<int> min, Given<int> max)
{
// --- check def, min and max are consistent
SX_CHECK_VARS (!(min.given && max.given && (min.value > max.value)),
SX_CHECK (!(min.given && max.given && (min.value > max.value)),
min.value, max.value);
SX_CHECK_VARS (!(min.given && def.given && (min.value > def.value)),
SX_CHECK (!(min.given && def.given && (min.value > def.value)),
min.value, def.value);
SX_CHECK_VARS (!(def.given && max.given && (def.value > max.value)),
SX_CHECK (!(def.given && max.given && (def.value > max.value)),
def.value, max.value);
if (!hasValue ()) {
......@@ -487,11 +487,11 @@ long int SxCLI::CliArg::toLong (Given<long int> def,
Given<long int> max)
{
// --- check def, min and max are consistent
SX_CHECK_VARS (!(min.given && max.given && (min.value > max.value)),
SX_CHECK (!(min.given && max.given && (min.value > max.value)),
min.value, max.value);
SX_CHECK_VARS (!(min.given && def.given && (min.value > def.value)),
SX_CHECK (!(min.given && def.given && (min.value > def.value)),
min.value, def.value);
SX_CHECK_VARS (!(def.given && max.given && (def.value > max.value)),
SX_CHECK (!(def.given && max.given && (def.value > max.value)),
def.value, max.value);
// --- set option behaviour
......@@ -533,11 +533,11 @@ int64_t SxCLI::CliArg::toInt64 (Given<int64_t> def,
Given<int64_t> max)
{
// --- check def, min and max are consistent
SX_CHECK_VARS (!(min.given && max.given && (min.value > max.value)),
SX_CHECK (!(min.given && max.given && (min.value > max.value)),
min.value, max.value);
SX_CHECK_VARS (!(min.given && def.given && (min.value > def.value)),
SX_CHECK (!(min.given && def.given && (min.value > def.value)),
min.value, def.value);
SX_CHECK_VARS (!(def.given && max.given && (def.value > max.value)),
SX_CHECK (!(def.given && max.given && (def.value > max.value)),
def.value, max.value);
// --- set option behaviour
......@@ -580,11 +580,11 @@ float SxCLI::CliArg::toFloat (Given<float> def,
Given<float> max)
{
// --- check def, min and max are consistent
SX_CHECK_VARS (!(min.given && max.given && (min.value > max.value)),
SX_CHECK (!(min.given && max.given && (min.value > max.value)),
min.value, max.value);
SX_CHECK_VARS (!(min.given && def.given && (min.value > def.value)),
SX_CHECK (!(min.given && def.given && (min.value > def.value)),
min.value, def.value);
SX_CHECK_VARS (!(def.given && max.given && (def.value > max.value)),
SX_CHECK (!(def.given && max.given && (def.value > max.value)),
def.value, max.value);
// --- set option behaviour
......@@ -626,11 +626,11 @@ double SxCLI::CliArg::toDouble (Given<double> def,
Given<double> max)
{
// --- check def, min and max are consistent
SX_CHECK_VARS (!(min.given && max.given && (min.value > max.value)),
SX_CHECK (!(min.given && max.given && (min.value > max.value)),
min.value, max.value);
SX_CHECK_VARS (!(min.given && def.given && (min.value > def.value)),
SX_CHECK (!(min.given && def.given && (min.value > def.value)),
min.value, def.value);
SX_CHECK_VARS (!(def.given && max.given && (def.value > max.value)),
SX_CHECK (!(def.given && max.given && (def.value > max.value)),
def.value, max.value);
// --- set option behaviour
......@@ -1103,15 +1103,15 @@ void SxCLI::init (const SxList<SxString> &args_)
if (programName.contains ("/"))
programName = programName.tokenize ('/').last ();
// cut off final ".x"
SX_CHECK_VAR (programName.getSize () > 2, programName.getSize ());
SX_CHECK (programName.getSize () > 2, programName.getSize ());
if (programName.subString (programName.getSize () - 2) == ".x") {
programName.resize (programName.getSize () - 2, true);
programName = programName.toLower ();
}
// cut off leading lt-
SX_CHECK_VAR (programName.getSize () >= 3, programName.getSize ());
SX_CHECK (programName.getSize () >= 3, programName.getSize ());
if (programName.subString (0,2) == "lt-") {
SX_CHECK_VAR (programName.getSize () > 3, programName.getSize ());
SX_CHECK (programName.getSize () > 3, programName.getSize ());
programName = programName.subString(3);
}
......
This diff is collapsed.
......@@ -48,14 +48,14 @@ void SxConstChar::initialize (const char *start_, const char *limit_,
{
SX_CHECK (start_);
SX_CHECK (limit_);
SX_CHECK_VARS (limit_ >= start_, (const void *) start_,
SX_CHECK (limit_ >= start_, (const void *) start_,
(const void *) limit_);
// SX_CHECK_VAR (*limit_ == '\0', (const void *) limit_); -- not always
// SX_CHECK (*limit_ == '\0', (const void *) limit_); -- not always
start = start_;
limit = limit_;
isUnicode = isUnicode_;
if ( (isUnicode) && (start < limit) )
SX_CHECK_VAR (!isUtf8Continuation (*start), (uint8_t) *start);
SX_CHECK (!isUtf8Continuation (*start), (uint8_t) *start);
isDirty = true;
}
......@@ -93,7 +93,7 @@ SxConstChar::UnicodePoint SxConstChar::utf8ToChar (const char **ptr_)
SX_CHECK (ptr_);
const char *ptr = *ptr_;
SX_CHECK (ptr);
SX_CHECK_VAR (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
SX_CHECK (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
SxConstChar::UnicodePoint res;
char ch = *ptr++, ch2, ch3, ch4;
if ((ch & 128) == 0) res = ch; // the most likely case: 7-bit ASCII char
......@@ -121,7 +121,7 @@ SxConstChar::UnicodePoint SxConstChar::utf8ToChar (const char **ptr_)
ptr += 3;
}
}
SX_CHECK_VAR (res > 0, res);
SX_CHECK (res > 0, res);
}
*ptr_ = ptr;
return res;
......@@ -159,7 +159,7 @@ ssize_t SxConstChar::countChars (const char *start_, const char *limit_,
{
SX_CHECK (start_);
SX_CHECK (limit_);
SX_CHECK_VARS (start_ <= limit_, (const void *) start_,
SX_CHECK (start_ <= limit_, (const void *) start_,
(const void *) limit_);
return (isUnicode_ ? getNUtf8Chars (start_, limit_) : (limit_ - start_));
}
......@@ -177,13 +177,13 @@ ssize_t SxConstChar::getNChars () const
void SxConstChar::utf8Inc (const char **ptr_, ssize_t count)
{
SX_CHECK (ptr_);
SX_CHECK_VAR (count >= 0, count);
SX_CHECK (count >= 0, count);
if (count == 0) return;
const char *ptr = *ptr_;
SX_CHECK (ptr);
SX_CHECK_VAR (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
SX_CHECK (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
while (count-- > 0) {
SX_CHECK_VAR (*ptr != '\0', (uint8_t) *ptr); // don't leave the string
SX_CHECK (*ptr != '\0', (uint8_t) *ptr); // don't leave the string
do { ptr++; } while (!SxConstChar::isUtf8CharStart (*ptr));
}
*ptr_ = ptr;
......@@ -192,7 +192,7 @@ void SxConstChar::utf8Inc (const char **ptr_, ssize_t count)
void SxConstChar::inc (const char **ptr_, ssize_t count, bool isUnicode_)
{
SX_CHECK (ptr_);
SX_CHECK_VAR (count >= 0, count);
SX_CHECK (count >= 0, count);
if (count == 0) return;
if (!isUnicode_) {
const char *ptr = *ptr_;
......@@ -206,11 +206,11 @@ void SxConstChar::inc (const char **ptr_, ssize_t count, bool isUnicode_)
void SxConstChar::utf8Dec (const char **ptr_, ssize_t count)
{
SX_CHECK (ptr_);
SX_CHECK_VAR (count >= 0, count);
SX_CHECK (count >= 0, count);
if (count == 0) return;
const char *ptr = *ptr_;
SX_CHECK (ptr);
SX_CHECK_VAR (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
SX_CHECK (!isUtf8Continuation (*ptr), (uint8_t) *ptr);
while (count-- > 0) {