Base implementation of iser::IArchive interface.
More...
#include <CArchiveBase.h>
|
| virtual bool | IsTagSkippingSupported () const override |
| | Checks if skipping to the end of a tag on EndTag() is supported.
|
| |
| virtual bool | BeginMultiTag (const CArchiveTag &tag, const CArchiveTag &subTag, int &count) override |
| | Begins a tagged section containing multiple elements of the same type.
|
| |
| virtual bool | IsStoring () const =0 |
| | Checks if this archive is in storing (writing) or loading (reading) mode.
|
| |
| virtual const IVersionInfo & | GetVersionInfo () const =0 |
| | Gets version information for the archived stream.
|
| |
| virtual bool | BeginTag (const CArchiveTag &tag)=0 |
| | Begins a tagged section in the archive.
|
| |
| virtual bool | EndTag (const CArchiveTag &tag)=0 |
| | Ends a tagged section in the archive.
|
| |
| virtual bool | Process (bool &value)=0 |
| | Processes (reads or writes) a boolean value.
|
| |
| virtual bool | Process (char &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (quint8 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (qint8 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (quint16 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (qint16 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (quint32 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (qint32 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (quint64 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (qint64 &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (float &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (double &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (QByteArray &value)=0 |
| | Process primitive type.
|
| |
| virtual bool | Process (QString &value)=0 |
| | Process primitive type.
|
| |
| template<typename Primitive > |
| bool | TagAndProcess (const CArchiveTag &tag, Primitive &value) |
| |
| virtual bool | ProcessData (void *dataPtr, int size)=0 |
| | Process binary data block.
|
| |
| virtual bool | ProcessBits (void *dataPtr, int bitsCount, int bytesCount)=0 |
| | Process binary data block.
|
| |
| virtual | ~IPolymorphic () |
| |
Base implementation of iser::IArchive interface.
It provides standard implementation of some methods and standard tags.
Definition at line 20 of file CArchiveBase.h.
◆ CArchiveBase()
| iser::CArchiveBase::CArchiveBase |
( |
| ) |
|
|
inlineprotected |
◆ BeginMultiTag()
| virtual bool iser::CArchiveBase::BeginMultiTag |
( |
const CArchiveTag & |
tag, |
|
|
const CArchiveTag & |
subTag, |
|
|
int & |
count |
|
) |
| |
|
overridevirtual |
Begins a tagged section containing multiple elements of the same type.
BeginMultiTag is used for serializing collections, arrays, or lists where you have multiple items of the same structure. The count parameter works differently for reading vs. writing:
- Writing: Pass the number of elements you will serialize
- Reading: The archive sets count to the number of elements stored
- Parameters
-
| tag | Main container tag for the entire collection |
| subTag | Tag type for each individual element in the collection |
| count | [in/out] For writing: number of elements to serialize For reading: set by archive to number of stored elements |
- Returns
- true if successful, false on error
if (archive.IsStoring()) {
int count = m_items.count();
archive.BeginMultiTag(listTag, itemTag, count);
for (const Item& item : m_items) {
archive.BeginTag(itemTag);
item.Serialize(archive);
archive.EndTag(itemTag);
}
archive.EndTag(listTag);
}
else {
int count;
archive.BeginMultiTag(listTag, itemTag, count);
m_items.clear();
for (int i = 0; i < count; ++i) {
archive.BeginTag(itemTag);
Item item;
item.Serialize(archive);
m_items.append(item);
archive.EndTag(itemTag);
}
archive.EndTag(listTag);
}
- See also
- BeginTag(), EndTag()
Implements iser::IArchive.
Reimplemented in iser::CXmlReadArchiveBase, iser::CXmlWriteArchiveBase, iqt::CSettingsReadArchive, iqt::CSettingsWriteArchive, iser::CCompactXmlReadArchiveBase, iser::CCompactXmlWriteArchiveBase, iser::CJsonReadArchiveBase, and iser::CJsonWriteArchiveBase.
◆ GetAcfRootTag()
| static const CArchiveTag & iser::CArchiveBase::GetAcfRootTag |
( |
| ) |
|
|
static |
◆ IsTagSkippingSupported()
| virtual bool iser::CArchiveBase::IsTagSkippingSupported |
( |
| ) |
const |
|
overridevirtual |
Checks if skipping to the end of a tag on EndTag() is supported.
Some archive types (like XML) support skipping unread content within a tag, allowing forward compatibility. When reading an archive created by a newer version that added fields, this feature lets you skip unknown data.
- Returns
- true if the archive supports tag skipping, false otherwise
- Note
- Binary archives typically don't support skipping, requiring all data to be read sequentially.
-
XML and JSON archives usually support skipping.
if (archive.IsTagSkippingSupported()) {
} else {
}
- See also
- EndTag()
Implements iser::IArchive.
Reimplemented in ifile::CFileReadArchive, ifile::CFileWriteArchive, iser::CCompactXmlReadArchiveBase, iser::CCompactXmlWriteArchiveBase, iser::CJsonWriteArchiveBase, iser::CXmlReadArchiveBase, and iser::CXmlWriteArchiveBase.
◆ s_acfRootTag
The documentation for this class was generated from the following file: