mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T552 Using QDataStream marshalling mixins in value classes.
This commit is contained in:
@@ -92,6 +92,28 @@ namespace BlackMisc
|
||||
m_values.swap(newMap);
|
||||
}
|
||||
|
||||
void CPropertyIndexVariantMap::marshalToDataStream(QDataStream &stream) const
|
||||
{
|
||||
stream << m_values.keys();
|
||||
stream << m_values.values();
|
||||
}
|
||||
|
||||
void CPropertyIndexVariantMap::unmarshalFromDataStream(QDataStream &stream)
|
||||
{
|
||||
QList<CPropertyIndex> indexes;
|
||||
QList<CVariant> values;
|
||||
stream >> indexes;
|
||||
stream >> values;
|
||||
Q_ASSERT(indexes.size() == values.size());
|
||||
QMap<CPropertyIndex, CVariant> newMap;
|
||||
for (int i = 0; i < indexes.size(); i++)
|
||||
{
|
||||
newMap.insert(indexes[i], values[i]);
|
||||
}
|
||||
// replace values in one step
|
||||
m_values.swap(newMap);
|
||||
}
|
||||
|
||||
void CPropertyIndexVariantMap::addValue(const CPropertyIndex &index, const CVariant &value)
|
||||
{
|
||||
m_values.insert(index, value);
|
||||
|
||||
Reference in New Issue
Block a user