ReflectionByteCodeValue.h
// ReflectionByteCodeValue.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2012
@import "IObject.h"
@import "ReflectionByteCode.h"
#include "Ceda/cxUtils/xvector.h"
namespace ceda
{
$class+ ReflectionByteCodeValue <<ar>>
{
public:
// default dtor, copy ctor, copy assignment used
ReflectionByteCodeValue() {}
// Support implicit conversion from ReflectionByteCode
//
// If underlyingOnly = true then all the following type information is removed:
// - Metadata
// - Qualifiers : volatile, const, assignable, movable, offsetable
// - typedefs are reduced
ReflectionByteCodeValue(ReflectionByteCode rbc, bool underlyingOnly = false);
ReflectionByteCode AsReflectionByteCode() const
{
return ReflectionByteCode(m_byteCode.data(), GetStringTable(), nullptr);
}
bool operator<(const ReflectionByteCodeValue& rhs) const
{
return m_byteCode < rhs.m_byteCode ||
(m_byteCode == rhs.m_byteCode && m_strings < rhs.m_strings);
}
bool operator==(const ReflectionByteCodeValue& rhs) const
{
return m_byteCode == rhs.m_byteCode && m_strings == rhs.m_strings;
}
bool operator!=(const ReflectionByteCodeValue& rhs) const
{
return !operator==(rhs);
}
bool operator<=(const ReflectionByteCodeValue& rhs) const { return !rhs.operator<(*this); }
bool operator>(const ReflectionByteCodeValue& rhs) const { return rhs.operator<(*this); }
bool operator>=(const ReflectionByteCodeValue& rhs) const { return !operator<(rhs); }
void Serialise(Archive& ar) const;
void Deserialise(InputArchive& ar);
void DebugWrite(xostream& os) const;
private:
ConstStringZ const* GetStringTable() const;
private:
xvector<octet_t> m_byteCode;
// The concatenation of all the strings in the string table ordered by index position, each
// string including a '\0' terminator.
xstring m_strings;
// Pointers into the strings within m_strings. This can be regarded as redundant state, since
// it can be calculated from m_strings by scanning for the null terminators.
mutable xvector<ConstStringZ> stringTable;
};
// Displays ReflectionByteCodeValue as a type
inline xostream& operator<<(xostream& os, const ReflectionByteCodeValue& rbcv)
{
os << rbcv.AsReflectionByteCode();
return os;
}
} // namespace ceda