Commit 21326868 authored by Ivan Donchevskiy's avatar Ivan Donchevskiy

Some fixes for CycleStorage iterator

parent 77fd8250
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 0.98
Release: eter2
Release: eter4
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -184,6 +184,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Wed Jun 16 2010 Ivan Donchevskiy <yv@etersoft.ru> 0.98-eter3
- new build
* Tue Jun 01 2010 Vitaly Lipatov <lav@altlinux.ru> 0.98-eter2
- fixed bug in uniset-codegen
- minor fixes in SM (add virtual function)
......
......@@ -179,6 +179,13 @@ class CycleStorage
inline bool operator==(const Self& other) const
{
if( str==NULL || other.str==NULL )
{
if( str==NULL && other.str==NULL )
return true;
else
return false;
}
if( memcmp(str, other.str, cs->getInfSize())==0 )
return true;
return false;
......@@ -186,6 +193,13 @@ class CycleStorage
inline bool operator!=(const Self& other) const
{
if( str==NULL || other.str==NULL )
{
if( str==NULL && other.str==NULL )
return false;
else
return true;
}
if( memcmp(str, other.str, cs->getInfSize())==0 )
return false;
return true;
......
......@@ -493,9 +493,13 @@ bool CycleStorage::setSize(int count)
/*! Некоторые операции для итератора */
CycleStorage::iterator& CycleStorage::iterator::operator++()
{
if( current>=cs->getSize() )
throw "Trying to perform operator ++ at the end of collection";
current++;
if( current>=cs->getSize() )
{
str = NULL;
current = cs->getSize();
return *this;
}
cs->readRow(current,str);
return *this;
}
......@@ -503,18 +507,26 @@ CycleStorage::iterator& CycleStorage::iterator::operator++()
CycleStorage::iterator CycleStorage::iterator::operator++(int)
{
Self temp = *this;
if(current>=cs->getSize())
throw "Trying to perform operator ++ at the end of collection";
current++;
cs->readRow(current,str);
temp.current++;
if(temp.current>=temp.cs->getSize())
{
temp.str = NULL;
temp.current = temp.cs->getSize();
return temp;
}
temp.cs->readRow(current,str);
return temp;
}
CycleStorage::iterator& CycleStorage::iterator::operator--()
{
if(current<=0)
throw "Trying to perform operator -- at the begining of collection";
current--;
if(current<=0)
{
str = NULL;
current = -1;;
return *this;
}
cs->readRow(current,str);
return *this;
}
......@@ -522,9 +534,13 @@ CycleStorage::iterator& CycleStorage::iterator::operator--()
CycleStorage::iterator CycleStorage::iterator::operator--(int)
{
Self temp = *this;
if(current<=0)
throw "Trying to perform operator -- at the begining of collection";
current--;
cs->readRow(current,str);
temp.current--;
if(temp.current<=0)
{
temp.str = NULL;
temp.current = -1;
return temp;
}
temp.cs->readRow(current,str);
return temp;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment