Changeset 6921 for source/ariba


Ignore:
Timestamp:
Nov 13, 2009, 3:50:40 PM (14 years ago)
Author:
mies
Message:

fixed bug in array serializer
added static array serializer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/utility/serialization/DataStream.hpp

    r6919 r6921  
    516516
    517517        /* array and vector support */
    518         template<typename T, bool staticArray = false>
     518        template<typename T>
    519519        class ArrayTpl : public ExplicitSerializer {
    520520        private:
     
    524524        public:
    525525                finline ArrayTpl( T*& array, size_t length ) :
    526                 v(0), l(length) {}
    527 
    528                 sznMethodBegin(X)
    529                 if (X.isDeserializer() && !staticArray) v = new T[l];
     526                v(array), l(length) {}
     527
     528                sznMethodBegin(X)
     529                if (X.isDeserializer()) v = new T[l];
     530                for (size_t i=0; i<l; i++) X && v[i];
     531                sznMethodEnd()
     532        };
     533
     534        template<typename T>
     535        class StaticArrayTpl : public ExplicitSerializer {
     536        private:
     537                T* v;
     538                size_t l;
     539
     540        public:
     541                finline StaticArrayTpl( T* array, size_t length ) :
     542                v(array), l(length) {}
     543
     544                sznMethodBegin(X)
    530545                for (size_t i=0; i<l; i++) X && v[i];
    531546                sznMethodEnd()
     
    559574
    560575        template<typename T>
    561         finline ArrayTpl<T,true> static_A( T*& array, size_t length ) {
    562                 return ArrayTpl<T, true>(array,length);
     576        finline StaticArrayTpl<T> static_A( T* array, size_t length ) {
     577                return StaticArrayTpl<T>(array,length);
    563578        }
    564579
Note: See TracChangeset for help on using the changeset viewer.