From 4ecbf7407c19b59fc136c334f9386c53db453930 Mon Sep 17 00:00:00 2001 From: zecke Date: Tue, 10 Dec 2002 17:01:18 +0000 Subject: get in sync with HEAD again -OPimBase was added to be used as a default struct inside OPimResolver and to work with DSOs -TodoListXML backend now uses mmap and madvise to load data -OContact added/changed rtti -OTodo added changed rtti OPimAccess* added stuff necessary for the Resolver and a 'state'/'hint' on how to load data OPimResolver which resolves uid + services to Records, rtti to QCOPChannels loads arbitary Service backends ( will work with DSOs soon ) -OPimMainWindow added some setDocument scripting possibility and internal marshalling and demarshalling of Records -OPimRecord added loadDataFromm and saveDataTo for marshalling purposes much more :) --- (limited to 'libopie/pim/opimrecord.cpp') diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp index 49b5bf9..ac0f4a9 100644 --- a/libopie/pim/opimrecord.cpp +++ b/libopie/pim/opimrecord.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -82,3 +84,83 @@ OPimXRefManager &OPimRecord::xrefmanager() { int OPimRecord::rtti(){ return 0; } + +/** + * now let's put our data into the stream + */ +/* + * First read UID + * Categories + * XRef + */ +bool OPimRecord::loadFromStream( QDataStream& stream ) { + int Int; + uint UInt; + stream >> Int; + setUid(Int); + + /** Categories */ + stream >> UInt; + QArray array(UInt); + for (uint i = 0; i < UInt; i++ ) { + stream >> array[i]; + } + setCategories( array ); + + /* + * now we do the X-Ref stuff + */ + OPimXRef xref; + stream >> UInt; + for ( uint i = 0; i < UInt; i++ ) { + xref.setPartner( OPimXRef::One, partner( stream ) ); + xref.setPartner( OPimXRef::Two, partner( stream ) ); + m_xrefman.add( xref ); + } + + return true; +} +bool OPimRecord::saveToStream( QDataStream& stream )const { + /** UIDs */ + + stream << uid(); + + /** Categories */ + stream << categories().count(); + for ( uint i = 0; i < categories().count(); i++ ) { + stream << categories()[i]; + } + + /* + * first the XRef count + * then the xrefs + */ + stream << m_xrefman.list().count(); + for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); + it != m_xrefman.list().end(); ++it ) { + flush( (*it).partner( OPimXRef::One), stream ); + flush( (*it).partner( OPimXRef::Two), stream ); + } + return true; +} +void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ + str << par.service(); + str << par.uid(); + str << par.field(); +} +OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { + OPimXRefPartner par; + QString str; + int i; + + stream >> str; + par.setService( str ); + + stream >> i; + par.setUid( i ); + + stream >> i ; + par.setField( i ); + + return par; +} -- cgit v0.9.0.2