src/tag.h File Reference

#include "gcc.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  tag_item
 One tag value. More...
struct  tag
 The meta information about a song file. More...

Enumerations

enum  tag_type {
  TAG_ARTIST, TAG_ARTIST_SORT, TAG_ALBUM, TAG_ALBUM_ARTIST,
  TAG_ALBUM_ARTIST_SORT, TAG_TITLE, TAG_TRACK, TAG_NAME,
  TAG_GENRE, TAG_DATE, TAG_COMPOSER, TAG_PERFORMER,
  TAG_COMMENT, TAG_DISC, TAG_MUSICBRAINZ_ARTISTID, TAG_MUSICBRAINZ_ALBUMID,
  TAG_MUSICBRAINZ_ALBUMARTISTID, TAG_MUSICBRAINZ_TRACKID, TAG_NUM_OF_ITEM_TYPES
}
 

Codes for the type of a tag item.

More...

Functions

enum tag_type tag_name_parse (const char *name)
 Parse the string, and convert it into a tag_type.
enum tag_type tag_name_parse_i (const char *name)
 Parse the string, and convert it into a tag_type.
struct tagtag_new (void)
 Creates an empty tag.
void tag_lib_init (void)
 Initializes the tag library.
void tag_clear_items_by_type (struct tag *tag, enum tag_type type)
 Clear all tag items with the specified type.
void tag_free (struct tag *tag)
 Frees a tag object and all its items.
void tag_begin_add (struct tag *tag)
 Gives an optional hint to the tag library that we will now add several tag items; this is used by the library to optimize memory allocation.
void tag_end_add (struct tag *tag)
 Finishes the operation started with tag_begin_add().
void tag_add_item_n (struct tag *tag, enum tag_type type, const char *value, size_t len)
 Appends a new tag item.
static void tag_add_item (struct tag *tag, enum tag_type type, const char *value)
 Appends a new tag item.
struct tagtag_dup (const struct tag *tag)
 Duplicates a tag object.
struct tagtag_merge (const struct tag *base, const struct tag *add)
 Merges the data from two tags.
struct tagtag_merge_replace (struct tag *base, struct tag *add)
 Merges the data from two tags.
static bool tag_is_empty (const struct tag *tag)
 Returns true if the tag contains no items.
static bool tag_is_defined (const struct tag *tag)
 Returns true if the tag contains any information.
const char * tag_get_value (const struct tag *tag, enum tag_type type)
 Returns the first value of the specified tag type, or NULL if none is present in this tag object.
bool tag_has_type (const struct tag *tag, enum tag_type type)
 Checks whether the tag contains one or more items with the specified type.
bool tag_equal (const struct tag *tag1, const struct tag *tag2)
 Compares two tags, including the duration and all tag items.

Variables

const char * tag_item_names []
 An array of strings, which map the tag_type to its machine readable name (specific to the MPD protocol).
struct tag_item gcc_packed
 One tag value.

Enumeration Type Documentation

enum tag_type

Codes for the type of a tag item.

Enumerator:
TAG_ARTIST 
TAG_ARTIST_SORT 
TAG_ALBUM 
TAG_ALBUM_ARTIST 
TAG_ALBUM_ARTIST_SORT 
TAG_TITLE 
TAG_TRACK 
TAG_NAME 
TAG_GENRE 
TAG_DATE 
TAG_COMPOSER 
TAG_PERFORMER 
TAG_COMMENT 
TAG_DISC 
TAG_MUSICBRAINZ_ARTISTID 
TAG_MUSICBRAINZ_ALBUMID 
TAG_MUSICBRAINZ_ALBUMARTISTID 
TAG_MUSICBRAINZ_TRACKID 
TAG_NUM_OF_ITEM_TYPES 

Definition at line 33 of file tag.h.


Function Documentation

static void tag_add_item ( struct tag tag,
enum tag_type  type,
const char *  value 
) [inline, static]

Appends a new tag item.

Parameters:
tag the tag object
type the type of the new tag item
value the value of the tag item (null-terminated)

Definition at line 173 of file tag.h.

void tag_add_item_n ( struct tag tag,
enum tag_type  type,
const char *  value,
size_t  len 
)

Appends a new tag item.

Parameters:
tag the tag object
type the type of the new tag item
value the value of the tag item (not null-terminated)
len the length of value
void tag_begin_add ( struct tag tag  ) 

Gives an optional hint to the tag library that we will now add several tag items; this is used by the library to optimize memory allocation.

Only one tag may be in this state, and this tag must not have any items yet. You must call tag_end_add() when you are done.

void tag_clear_items_by_type ( struct tag tag,
enum tag_type  type 
)

Clear all tag items with the specified type.

struct tag* tag_dup ( const struct tag tag  )  [read]

Duplicates a tag object.

void tag_end_add ( struct tag tag  ) 

Finishes the operation started with tag_begin_add().

bool tag_equal ( const struct tag tag1,
const struct tag tag2 
)

Compares two tags, including the duration and all tag items.

The order of the tag items matters.

void tag_free ( struct tag tag  ) 

Frees a tag object and all its items.

const char* tag_get_value ( const struct tag tag,
enum tag_type  type 
)

Returns the first value of the specified tag type, or NULL if none is present in this tag object.

bool tag_has_type ( const struct tag tag,
enum tag_type  type 
)

Checks whether the tag contains one or more items with the specified type.

static bool tag_is_defined ( const struct tag tag  )  [inline, static]

Returns true if the tag contains any information.

Definition at line 215 of file tag.h.

static bool tag_is_empty ( const struct tag tag  )  [inline, static]

Returns true if the tag contains no items.

This ignores the "time" attribute.

Definition at line 206 of file tag.h.

void tag_lib_init ( void   ) 

Initializes the tag library.

struct tag* tag_merge ( const struct tag base,
const struct tag add 
) [read]

Merges the data from two tags.

If both tags share data for the same tag_type, only data from "add" is used.

Returns:
a newly allocated tag, which must be freed with tag_free()
struct tag* tag_merge_replace ( struct tag base,
struct tag add 
) [read]

Merges the data from two tags.

Any of the two may be NULL. Both are freed by this function.

Returns:
a newly allocated tag, which must be freed with tag_free()
enum tag_type tag_name_parse ( const char *  name  ) 

Parse the string, and convert it into a tag_type.

Returns TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.

enum tag_type tag_name_parse_i ( const char *  name  ) 

Parse the string, and convert it into a tag_type.

Returns TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.

Case does not matter.

struct tag* tag_new ( void   )  [read]

Creates an empty tag.


Variable Documentation

One tag value.

It is a mapping of tag_type to am arbitrary string value. Each tag can have multiple items of one tag type (although few clients support that).

const char* tag_item_names[]

An array of strings, which map the tag_type to its machine readable name (specific to the MPD protocol).


Generated on 9 Aug 2013 for MPD by  doxygen 1.6.1