Commit 21326868 authored by Ivan Donchevskiy's avatar Ivan Donchevskiy

Some fixes for CycleStorage iterator

parent 77fd8250
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.98 Version: 0.98
Release: eter2 Release: eter4
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -184,6 +184,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -184,6 +184,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %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 * Tue Jun 01 2010 Vitaly Lipatov <lav@altlinux.ru> 0.98-eter2
- fixed bug in uniset-codegen - fixed bug in uniset-codegen
- minor fixes in SM (add virtual function) - minor fixes in SM (add virtual function)
......
...@@ -179,6 +179,13 @@ class CycleStorage ...@@ -179,6 +179,13 @@ class CycleStorage
inline bool operator==(const Self& other) const 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 ) if( memcmp(str, other.str, cs->getInfSize())==0 )
return true; return true;
return false; return false;
...@@ -186,6 +193,13 @@ class CycleStorage ...@@ -186,6 +193,13 @@ class CycleStorage
inline bool operator!=(const Self& other) const 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 ) if( memcmp(str, other.str, cs->getInfSize())==0 )
return false; return false;
return true; return true;
......
...@@ -493,9 +493,13 @@ bool CycleStorage::setSize(int count) ...@@ -493,9 +493,13 @@ bool CycleStorage::setSize(int count)
/*! Некоторые операции для итератора */ /*! Некоторые операции для итератора */
CycleStorage::iterator& CycleStorage::iterator::operator++() CycleStorage::iterator& CycleStorage::iterator::operator++()
{ {
if( current>=cs->getSize() )
throw "Trying to perform operator ++ at the end of collection";
current++; current++;
if( current>=cs->getSize() )
{
str = NULL;
current = cs->getSize();
return *this;
}
cs->readRow(current,str); cs->readRow(current,str);
return *this; return *this;
} }
...@@ -503,18 +507,26 @@ CycleStorage::iterator& CycleStorage::iterator::operator++() ...@@ -503,18 +507,26 @@ CycleStorage::iterator& CycleStorage::iterator::operator++()
CycleStorage::iterator CycleStorage::iterator::operator++(int) CycleStorage::iterator CycleStorage::iterator::operator++(int)
{ {
Self temp = *this; Self temp = *this;
if(current>=cs->getSize()) temp.current++;
throw "Trying to perform operator ++ at the end of collection"; if(temp.current>=temp.cs->getSize())
current++; {
cs->readRow(current,str); temp.str = NULL;
temp.current = temp.cs->getSize();
return temp;
}
temp.cs->readRow(current,str);
return temp; return temp;
} }
CycleStorage::iterator& CycleStorage::iterator::operator--() CycleStorage::iterator& CycleStorage::iterator::operator--()
{ {
if(current<=0)
throw "Trying to perform operator -- at the begining of collection";
current--; current--;
if(current<=0)
{
str = NULL;
current = -1;;
return *this;
}
cs->readRow(current,str); cs->readRow(current,str);
return *this; return *this;
} }
...@@ -522,9 +534,13 @@ CycleStorage::iterator& CycleStorage::iterator::operator--() ...@@ -522,9 +534,13 @@ CycleStorage::iterator& CycleStorage::iterator::operator--()
CycleStorage::iterator CycleStorage::iterator::operator--(int) CycleStorage::iterator CycleStorage::iterator::operator--(int)
{ {
Self temp = *this; Self temp = *this;
if(current<=0) temp.current--;
throw "Trying to perform operator -- at the begining of collection"; if(temp.current<=0)
current--; {
cs->readRow(current,str); temp.str = NULL;
temp.current = -1;
return temp;
}
temp.cs->readRow(current,str);
return temp; 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