1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
// =================================================================================================
// Copyright Adobe
// Copyright 2010 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================
#include "XMPFiles/source/NativeMetadataSupport/MetadataSet.h"
#include "source/XMP_LibUtils.hpp"
//-----------------------------------------------------------------------------
//
// MetadataSet::MetadataSet(...)
//
// Purpose: ctor/dtor
//
//-----------------------------------------------------------------------------
MetadataSet::MetadataSet()
: mMeta ( NULL )
{
}
MetadataSet::~MetadataSet()
{
delete mMeta;
}
//-----------------------------------------------------------------------------
//
// MetadataSet::append(...)
//
// Purpose: Append metadata container
//
//-----------------------------------------------------------------------------
void MetadataSet::append( IMetadata* meta )
{
if( mMeta == NULL )
{
mMeta = new std::vector<IMetadata*>;
}
mMeta->push_back( meta );
}
//-----------------------------------------------------------------------------
//
// MetadataSet::removeAt(...)
//
// Purpose: Remove metadata container at passed position
//
//-----------------------------------------------------------------------------
void MetadataSet::removeAt( XMP_Uns32 pos )
{
if( mMeta != NULL && pos < mMeta->size() )
{
mMeta->erase( mMeta->begin() + pos );
}
else
{
XMP_Throw( "Index out of range.", kXMPErr_BadIndex );
}
}
//-----------------------------------------------------------------------------
//
// MetadataSet::remove(...)
//
// Purpose: Remove the last metadata container inside the vector
//
//-----------------------------------------------------------------------------
void MetadataSet::remove()
{
if( mMeta != NULL )
{
mMeta->pop_back();
}
}
//-----------------------------------------------------------------------------
//
// MetadataSet::length(...)
//
// Purpose: Return the number of stored metadata container
//
//-----------------------------------------------------------------------------
XMP_Uns32 MetadataSet::length() const
{
XMP_Uns32 ret = 0;
if( mMeta != NULL )
{
ret = (XMP_Uns32)mMeta->size();
}
return ret;
}
//-----------------------------------------------------------------------------
//
// MetadataSet::getAt(...)
//
// Purpose: Return metadata container of passed position.
//
//-----------------------------------------------------------------------------
IMetadata* MetadataSet::getAt( XMP_Uns32 pos ) const
{
IMetadata* ret = NULL;
if( mMeta != NULL && pos < mMeta->size() )
{
ret = mMeta->at(pos);
}
else
{
XMP_Throw( "Index out of range.", kXMPErr_BadIndex );
}
return ret;
}
|