#503 closed defect (fixed)
psMetadataRemove and PS_LIST_UNKNOWN
| Reported by: | Paul Price | Owned by: | Paul Price |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | types | Version: | unspecified |
| Severity: | trivial | Keywords: | |
| Cc: | rhl@… |
Description
PS_LIST_UNKNOWN is supposed to be required for psMetadataRemove --- to remove by
key instead of by position. The current implementation simply looks at whether
the key is defined. Should we define separate functions,
psMetadataRemoveByIndex/psMetadataRemoveByKey?
From psList.h:
/ Special values of index into list
*
- This list of possible list position values should be contiguous non-positive
values ending with
- PS_LIST_UNKNOWN. Any value less-than-or-equal-to PS_LIST_UNKNOWN is
considered a undefined position.
*
*/
enum {
PS_LIST_HEAD = 0, /< at head
PS_LIST_TAIL = -1, /< at tail
};
Change History (7)
comment:1 by , 21 years ago
| Cc: | added |
|---|
comment:2 by , 21 years ago
comment:3 by , 21 years ago
| Owner: | changed from to |
|---|
PS_LIST_UNKNOWN was removed because of the changes made to psList. It probably would be good to
mirror the change made in psList for psMetadata, i.e., define the function psMetadataRemoveData that
is analogous to psListRemoveData. that would then remove any PS_LIST_UNKNOWN requirement.
comment:4 by , 21 years ago
That sounds like a vote for splitting psMetadataRemove into two functions:
bool psMetadataRemoveIndex(psMetadata *md, int location);
bool psMetadataRemoveKey(psMetadata *md, const char *key);
comment:5 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Since there are no objections, I have updated the SDRS to specify two remove
functions.
Items may be removed from the metadata by specifying a key or a
location in the list. For \code{psMetadataRemoveKey}, if the key
matches a metadata item, the item is removed from the metadata and
\code{true} is returned; otherwise, \code{false} is returned. If the
key is not unique, then \emph{all} items corresponding to the key are
removed, and \code{true} is returned. For
\code{psMetadataRemoveIndex}, the metadata item at the specified
\code{location} is removed, if valid, and \code{true} is returned;
otherwise the function returns \code{false}.
%
\begin{prototype}
bool psMetadataRemoveKey(psMetadata *md, const char *key);
bool psMetadataRemoveIndex(psMetadata *md, int location);
\end{prototype}

* Bug 477 has been marked as a duplicate of this bug. *