summaryrefslogtreecommitdiff
path: root/src/KM_util.h
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2007-03-26 23:08:16 +0000
committerjhurst <>2007-03-26 23:08:16 +0000
commit253b0b7af5aacd4e112190689fbdeb10968ca074 (patch)
treeeb099ebc6e627ea3f7329af92641e756e3e3cae3 /src/KM_util.h
parent3a4cfef4ecefd74ff3684d06e931414f8baf3580 (diff)
added identifier list type
Diffstat (limited to 'src/KM_util.h')
-rwxr-xr-xsrc/KM_util.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/KM_util.h b/src/KM_util.h
index dbbdedf..5ca3baa 100755
--- a/src/KM_util.h
+++ b/src/KM_util.h
@@ -36,6 +36,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <KM_error.h>
#include <string.h>
#include <string>
+#include <list>
namespace Kumu
{
@@ -265,7 +266,43 @@ namespace Kumu
}
};
-
+ //
+ template <class T>
+ class IdentifierList : public std::list<T>, public IArchive
+ {
+ public:
+ IdentifierList() {}
+ virtual ~IdentifierList() {}
+
+ bool HasValue() const { return ! this->empty(); }
+
+ bool Unarchive(Kumu::MemIOReader* Reader)
+ {
+ if ( Reader == 0 )return false;
+ ui32_t read_size = 0;
+ if ( ! Reader->ReadUi32BE(&read_size) ) return false;
+ for ( ui32_t i = 0; i < read_size; i++ )
+ {
+ T TmpTP;
+ if ( ! TmpTP.Unarchive(Reader) ) return false;
+ this->push_back(TmpTP);
+ }
+
+ return true;
+ }
+
+ bool Archive(Kumu::MemIOWriter* Writer) const
+ {
+ if ( Writer == 0 )return false;
+ if ( ! Writer->WriteUi32BE(this->size()) ) return false;
+ typename IdentifierList<T>::const_iterator i = this->begin();
+ for ( ; i != this->end(); i++ )
+ if ( ! (*i).Archive(Writer) ) return false;
+
+ return true;
+ }
+ };
+
// UUID
//
const ui32_t UUID_Length = 16;