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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
// The authors have released ID3Lib as Public Domain (PD) and claim no copyright,
// patent or other intellectual property protection in this work. This means that
// it may be modified, redistributed and used in commercial and non-commercial
// software and hardware without restrictions. ID3Lib is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
//
// The ID3Lib authors encourage improvements and optimisations to be sent to the
// ID3Lib coordinator, currently Dirk Mahoney (dirk@id3.org). Approved
// submissions may be altered, and will be included and released under these terms.
//
// Mon Nov 23 18:34:01 1998
#include "id3_tag.h"
#include "id3_misc_support.h"
ID3_Elem *ID3_Tag::Find ( ID3_Frame *frame )
{
ID3_Elem *elem = NULL;
ID3_Elem *cur = frameList;
bool done = false;
while ( ! done && cur )
{
if ( cur->frame == frame )
{
elem = cur;
done = true;
}
else
cur = cur->next;
}
return elem;
}
ID3_Frame *ID3_Tag::Find ( ID3_FrameID id )
{
ID3_Frame *frame = NULL;
ID3_Elem *cur = findCursor;
bool done = false;
if ( cur == NULL )
findCursor = cur = frameList;
while ( ! done && cur )
{
if ( cur->frame && ( cur->frame->GetID() == id ) )
{
frame = cur->frame;
if ( frame )
{
findCursor = cur->next;
done = true;
}
}
else
cur = cur->next;
if ( cur == NULL )
cur = frameList;
if ( cur == findCursor )
done = true;
}
return frame;
}
ID3_Frame *ID3_Tag::Find ( ID3_FrameID id, ID3_FieldID fld, char *data )
{
ID3_Frame *frame = NULL;
wchar_t *temp;
if ( temp = new wchar_t[ strlen ( data ) + 1 ] )
{
ID3_ASCIItoUnicode ( temp, data, strlen ( data ) + 1 );
frame = Find ( id, fld, temp );
delete[] temp;
}
return frame;
}
ID3_Frame *ID3_Tag::Find ( ID3_FrameID id, ID3_FieldID fld, wchar_t *data )
{
ID3_Frame *frame = NULL;
ID3_Elem *cur = findCursor;
bool done = false;
if ( cur == NULL )
findCursor = cur = frameList;
while ( ! done && cur )
{
if ( cur->frame && ( cur->frame->GetID() == id ) )
{
frame = cur->frame;
if ( data && wcslen ( data ) && BS_ISSET ( frame->fieldBits, fld ) )
{
wchar_t *buffer;
luint size;
size = frame->Field ( fld ).BinSize();
if ( buffer = new wchar_t[ size ] )
{
frame->Field ( fld ).Get ( buffer, size );
if ( wcscmp ( buffer, data ) != 0 )
{
frame = NULL;
cur = cur->next;
}
delete[] buffer;
}
}
if ( frame )
{
findCursor = cur->next;
break;
}
}
else
cur = cur->next;
if ( cur == NULL )
cur = frameList;
if ( cur == findCursor )
done = true;
}
return frame;
}
ID3_Frame *ID3_Tag::Find ( ID3_FrameID id, ID3_FieldID fld, luint data )
{
ID3_Frame *frame = NULL;
ID3_Elem *cur = findCursor;
bool done = false;
if ( cur == NULL )
findCursor = cur = frameList;
while ( ! done && cur )
{
if ( cur->frame && ( cur->frame->GetID() == id ) )
{
frame = cur->frame;
if ( frame->Field ( fld ).Get() != data )
{
frame = NULL;
cur = cur->next;
}
if ( frame )
{
findCursor = cur->next;
break;
}
}
else
cur = cur->next;
if ( cur == NULL )
cur = frameList;
if ( cur == findCursor )
done = true;
}
return frame;
}
ID3_Frame *ID3_Tag::GetFrameNum ( luint num )
{
ID3_Frame *frame = NULL;
ID3_Elem *cur = frameList;
bool done = false;
luint curNum = 0;
while ( cur && ! done )
{
if ( num == curNum )
{
frame = cur->frame;
done = true;
}
else
{
curNum++;
cur = cur->next;
}
}
return frame;
}
ID3_Frame *ID3_Tag::operator[] ( luint num )
{
return GetFrameNum ( num );
}
|