00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _HLATYPES_IEEE1516_HH
00018 #define _HLATYPES_IEEE1516_HH
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <HLAbuffer.hh>
00032
00033 namespace libhla {
00034
00035 template<class T>
00036 class HLAdata : public __HLAbuffer
00037 {
00038 public:
00040 HLAdata(size_t capacity = T::emptysizeof())
00041 : __HLAbuffer(capacity)
00042 { }
00043
00045 HLAdata(void *begin, size_t capacity)
00046 : __HLAbuffer(begin, capacity)
00047 {
00048 if (capacity < size())
00049 throw std::length_error("HLAdata: data buffer overflow");
00050
00051 }
00052
00053 T& operator *() const
00054 { return *(T*)mBegin; }
00055
00056 T* operator ->() const
00057 { return (T*)mBegin; }
00058
00059 virtual const size_t size() const
00060 { return ((T*)mBegin)->__sizeof(); }
00061
00063
00064
00065
00066
00067 virtual void __shake(const void* __that, int value, long resize)
00068 {
00069 HLAdata<T> newData(size()+resize);
00070
00071
00072 newData.mShakeThat = __that;
00073 newData.mShakeValue = value;
00074
00075 ((T*)newData.mBegin)->copy(mBegin);
00076
00077 if (mUserAllocated)
00078 {
00079 if (newData.size() < mCapacity)
00080
00081 memcpy(mBegin, newData.mBegin, newData.size());
00082 else
00083 throw std::length_error("HLAdata: data buffer overflow");
00084 }
00085 else
00086 __exchange_buffers(newData);
00087 }
00088 };
00089
00090 }
00091
00092 #if defined(_WIN32)
00093 #pragma warning(disable:4503) // suppress warning C4503: decorated name length exceeded
00094 #endif
00095
00096 #include <HLAbasicType.hh>
00097 #include <HLAenumeratedType.hh>
00098 #include <HLAfixedArray.hh>
00099 #include <HLAvariableArray.hh>
00100 #include <HLAfixedRecord.hh>
00101 #include <HLAvariantRecord.hh>
00102
00103 #endif // _HLATYPES_IEEE1516_HH
00104
00105
00106