24#ifndef __DOTS_INTERNAL_BLOB_READER_H__
25#define __DOTS_INTERNAL_BLOB_READER_H__
31#include <Safir/Dob/Typesystem/ToolSupport/Internal/InternalDefs.h>
32#include <Safir/Dob/Typesystem/ToolSupport/Internal/Blob.h>
63 template <
class RepositoryT,
class Traits=Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT> >
83 static DotsC_Int32
GetSize(
const char* blob) {
return Internal::Blob::GetSize(blob);}
90 static DotsC_TypeId
GetTypeId(
const char* blob) {
return Internal::Blob::GetTypeId(blob);}
100 ,m_classDescription(rep->GetClass(m_blob.
TypeId()))
101 ,m_memberDescription(NULL)
113 DotsC_Int32
Size()
const {
return m_blob.Size();}
119 DotsC_TypeId
TypeId()
const {
return m_blob.TypeId();}
133 return m_blob.IsChangedTopLevel(member);
143 for (
int member=0; member<m_classDescription->GetNumberOfMembers(); ++member)
160 MoveToMember(member);
161 const DotsC_CollectionType collectionType = m_memberDescription->GetCollectionType();
164 if (collectionType == SequenceCollectionType || collectionType == DictionaryCollectionType)
166 if (m_blob.IsChangedTopLevel(member))
172 const int size = m_blob.NumberOfValues(member);
178 if (collectionType == SequenceCollectionType)
180 if (m_memberDescription->GetMemberType() == ObjectMemberType)
182 for (
int index = 0; index < size; ++index)
184 bool dummy=
false, isNull=
false;
185 m_blob.ValueStatus(member, index, isNull, dummy);
188 std::pair<const char*, DotsC_Int32> obj=m_blob.GetValueBinary(member, index);
189 const BlobReader inner(m_repository, obj.first);
201 for (
int index = 0; index < size; ++index)
210 if (m_memberDescription->GetMemberType() == ObjectMemberType)
212 for (
int index = 0; index < size; ++index)
214 bool dummy=
false, isNull=
false;
215 m_blob.ValueStatus(member, index, isNull, dummy);
218 std::pair<const char*, DotsC_Int32> obj=m_blob.GetValueBinary(member, index);
219 const BlobReader inner(m_repository, obj.first);
243 DotsC_Int32 index)
const
246 MoveToMember(member);
247 assert(m_memberDescription->GetCollectionType() != SequenceCollectionType);
250 return m_blob.IsChangedHere(member,index);
259 int NumberOfValues(DotsC_MemberIndex member)
const {
return m_blob.NumberOfValues(member);}
268 void ReadStatus(DotsC_MemberIndex member,
int valueIndex,
bool& isNull,
bool& isChanged)
const
270 MoveToMember(member);
271 m_blob.ValueStatus(member, valueIndex, isNull, isChanged);
283 Key
ReadKey(DotsC_MemberIndex member,
int valueIndex)
const
285 MoveToMember(member);
286 if (m_memberDescription->GetCollectionType()!=DictionaryCollectionType)
288 ThrowWrongCollectionType();
290 return Internal::BlobUtils::Reader<Key>::Key(m_blob, member, valueIndex);
303 void ReadValue(DotsC_MemberIndex member,
int valueIndex, Val& val,
bool& isNull,
bool& isChanged)
const
305 MoveToMember(member);
306 m_blob.ValueStatus(member, valueIndex, isNull, isChanged);
309 val=Internal::BlobUtils::Reader<Val>::Value(m_blob, member, valueIndex);
315 Safir::Dob::Typesystem::ToolSupport::Internal::Blob m_blob;
318 mutable DotsC_MemberIndex m_memberIndex;
320 inline void MoveToMember(DotsC_MemberIndex member)
const
322 if (m_memberIndex!=member)
324 m_memberDescription=m_classDescription->GetMember(member);
325 m_memberIndex=member;
329 inline void ThrowWrongCollectionType()
const
331 std::ostringstream os;
332 os<<
"Trying to write data of wrong collection type to a blob for member '"<<m_memberDescription->GetName()<<
"' in class '"<<m_classDescription->GetName()<<
"'";
333 throw std::logic_error(os.str());
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
DotsC_TypeId TypeId
A unique type identifier.
Definition Defs.h:218
This class is used to unpack and read blobs created by the BlobWriter class.
Definition BlobReader.h:65
static DotsC_TypeId GetTypeId(const char *blob)
Static method.
Definition BlobReader.h:90
DotsC_TypeId TypeId() const
Get the type id of the blob.
Definition BlobReader.h:119
BlobReader(const RepositoryT *rep, const char *blob)
Constructor - Creates a reader object that unpacks the blob and makes it possible to read its content...
Definition BlobReader.h:97
void ReadStatus(DotsC_MemberIndex member, int valueIndex, bool &isNull, bool &isChanged) const
Convenience method for checking if a member is null.
Definition BlobReader.h:268
Traits::RepositoryType RepositoryType
Definition BlobReader.h:67
Traits::ExceptionDescriptionType ExceptionDescriptionType
Definition BlobReader.h:71
Traits::CreateRoutineDescriptionType CreateRoutineDescriptionType
Definition BlobReader.h:76
Key ReadKey(DotsC_MemberIndex member, int valueIndex) const
Reads the key element of a member value.
Definition BlobReader.h:283
Traits::EnumDescriptionType EnumDescriptionType
Definition BlobReader.h:73
bool IsChangedRecursive(DotsC_MemberIndex member) const
Check change flag on a member, recursively.
Definition BlobReader.h:158
friend struct Internal::BlobUtils::BlobAccess
Definition BlobReader.h:336
Traits::PropertyMappingDescriptionType PropertyMappingDescriptionType
Definition BlobReader.h:75
Traits::ClassDescriptionType ClassDescriptionType
Definition BlobReader.h:68
int NumberOfValues(DotsC_MemberIndex member) const
Get the number of values for the member.
Definition BlobReader.h:259
bool IsChangedTopLevel(DotsC_MemberIndex member) const
Check if the member is changed at top level.
Definition BlobReader.h:131
DotsC_Int32 Size() const
Get the size of the blob.
Definition BlobReader.h:113
BlobReader & operator=(const BlobReader &)=delete
bool IsChangedRecursive() const
Check change flags on all members, recursively.
Definition BlobReader.h:141
void ReadValue(DotsC_MemberIndex member, int valueIndex, Val &val, bool &isNull, bool &isChanged) const
Read the value element of a member value.
Definition BlobReader.h:303
Traits::MemberMappingDescriptionType MemberMappingDescriptionType
Definition BlobReader.h:74
Traits::ParameterDescriptionType ParameterDescriptionType
Definition BlobReader.h:72
Traits::MemberDescriptionType MemberDescriptionType
Definition BlobReader.h:69
Traits::PropertyDescriptionType PropertyDescriptionType
Definition BlobReader.h:70
bool IsChangedHere(DotsC_MemberIndex member, DotsC_Int32 index) const
Check change flag on a member (non-recursively)
Definition BlobReader.h:242
BlobReader(const BlobReader &)=delete
static DotsC_Int32 GetSize(const char *blob)
Static method.
Definition BlobReader.h:83