Lucas Eckels | 8a58cac | 2012-08-06 15:12:54 -0700 | [diff] [blame^] | 1 | // $Id: c_wrapper.cpp,v 1.22 2002/09/21 17:23:32 t1mpy Exp $ |
| 2 | |
| 3 | // id3lib: a C++ library for creating and manipulating id3v1/v2 tags |
| 4 | // Copyright 1999, 2000 Scott Thomas Haug |
| 5 | // Copyright 2002 Thijmen Klok (thijmen@id3lib.org) |
| 6 | |
| 7 | // This library is free software; you can redistribute it and/or modify it |
| 8 | // under the terms of the GNU Library General Public License as published by |
| 9 | // the Free Software Foundation; either version 2 of the License, or (at your |
| 10 | // option) any later version. |
| 11 | // |
| 12 | // This library is distributed in the hope that it will be useful, but WITHOUT |
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
| 15 | // License for more details. |
| 16 | // |
| 17 | // You should have received a copy of the GNU Library General Public License |
| 18 | // along with this library; if not, write to the Free Software Foundation, |
| 19 | // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | |
| 21 | // The id3lib authors encourage improvements and optimisations to be sent to |
| 22 | // the id3lib coordinator. Please see the README file for details on where to |
| 23 | // send such submissions. See the AUTHORS file for a list of people who have |
| 24 | // contributed to id3lib. See the ChangeLog file for a list of changes to |
| 25 | // id3lib. These files are distributed with id3lib at |
| 26 | // http://download.sourceforge.net/id3lib/ |
| 27 | |
| 28 | //#include <string.h> |
| 29 | #include "id3.h" |
| 30 | #include "tag.h" |
| 31 | #include "field.h" |
| 32 | #include "id3lib_strings.h" |
| 33 | |
| 34 | #if defined HAVE_CONFIG_H |
| 35 | #include <config.h> |
| 36 | #endif |
| 37 | |
| 38 | #ifdef __cplusplus |
| 39 | extern "C" |
| 40 | { |
| 41 | #endif /* __cplusplus */ |
| 42 | |
| 43 | // tag wrappers |
| 44 | |
| 45 | #define ID3_CATCH(code) try { code; } catch (...) { } |
| 46 | |
| 47 | ID3_C_EXPORT ID3Tag* CCONV |
| 48 | ID3Tag_New(void) |
| 49 | { |
| 50 | ID3_Tag* tag = NULL; |
| 51 | ID3_CATCH(tag = new ID3_Tag); |
| 52 | return reinterpret_cast<ID3Tag *>(tag); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | ID3_C_EXPORT void CCONV |
| 57 | ID3Tag_Delete(ID3Tag *tag) |
| 58 | { |
| 59 | if (tag) |
| 60 | { |
| 61 | ID3_CATCH(delete reinterpret_cast<ID3_Tag*>(tag)); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | |
| 66 | ID3_C_EXPORT void CCONV |
| 67 | ID3Tag_Clear(ID3Tag *tag) |
| 68 | { |
| 69 | if (tag) |
| 70 | { |
| 71 | ID3_CATCH(reinterpret_cast<ID3_Tag*>(tag)->Clear()); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | ID3_C_EXPORT bool CCONV |
| 77 | ID3Tag_HasChanged(const ID3Tag *tag) |
| 78 | { |
| 79 | bool changed = false; |
| 80 | |
| 81 | if (tag) |
| 82 | { |
| 83 | ID3_CATCH(changed = reinterpret_cast<const ID3_Tag * >(tag)->HasChanged()); |
| 84 | } |
| 85 | |
| 86 | return changed; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | ID3_C_EXPORT void CCONV |
| 91 | ID3Tag_SetUnsync(ID3Tag *tag, bool unsync) |
| 92 | { |
| 93 | if (tag) |
| 94 | { |
| 95 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->SetUnsync(unsync)); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | |
| 100 | ID3_C_EXPORT void CCONV |
| 101 | ID3Tag_SetExtendedHeader(ID3Tag *tag, bool ext) |
| 102 | { |
| 103 | if (tag) |
| 104 | { |
| 105 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->SetExtendedHeader(ext)); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | ID3_C_EXPORT void CCONV |
| 110 | ID3Tag_SetPadding(ID3Tag *tag, bool pad) |
| 111 | { |
| 112 | if (tag) |
| 113 | { |
| 114 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->SetPadding(pad)); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | |
| 119 | ID3_C_EXPORT void CCONV |
| 120 | ID3Tag_AddFrame(ID3Tag *tag, const ID3Frame *frame) |
| 121 | { |
| 122 | if (tag) |
| 123 | { |
| 124 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->AddFrame(reinterpret_cast<const ID3_Frame *>(frame))); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | |
| 129 | ID3_C_EXPORT bool CCONV |
| 130 | ID3Tag_AttachFrame(ID3Tag *tag, ID3Frame *frame) |
| 131 | { |
| 132 | bool b = false; |
| 133 | if (tag) |
| 134 | { |
| 135 | ID3_CATCH(b = reinterpret_cast<ID3_Tag *>(tag)->AttachFrame(reinterpret_cast<ID3_Frame *>(frame))); |
| 136 | } |
| 137 | return b; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | ID3_C_EXPORT void CCONV |
| 142 | ID3Tag_AddFrames(ID3Tag *tag, const ID3Frame *frames, size_t num) |
| 143 | { |
| 144 | if (tag) |
| 145 | { |
| 146 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->AddFrames(reinterpret_cast<const ID3_Frame *>(frames), num)); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | |
| 151 | ID3_C_EXPORT ID3Frame* CCONV |
| 152 | ID3Tag_RemoveFrame(ID3Tag *tag, const ID3Frame *frame) |
| 153 | { |
| 154 | ID3_Frame* rem_frame = NULL; |
| 155 | if (tag) |
| 156 | { |
| 157 | ID3_CATCH(rem_frame = reinterpret_cast<ID3_Tag *>(tag)->RemoveFrame(reinterpret_cast<const ID3_Frame *>(frame))); |
| 158 | } |
| 159 | return reinterpret_cast<ID3Frame*>(rem_frame); |
| 160 | } |
| 161 | |
| 162 | |
| 163 | ID3_C_EXPORT ID3_Err CCONV |
| 164 | ID3Tag_Parse(ID3Tag *tag, const uchar header[ ID3_TAGHEADERSIZE ], |
| 165 | const uchar *buffer) |
| 166 | { |
| 167 | size_t size = 0; |
| 168 | if (tag) |
| 169 | { |
| 170 | ID3_CATCH(size = reinterpret_cast<ID3_Tag *>(tag)->Parse(header, buffer)); |
| 171 | } |
| 172 | return ID3E_NoError; |
| 173 | } |
| 174 | |
| 175 | |
| 176 | #ifdef WIN32 |
| 177 | ID3_C_EXPORT size_t CCONV |
| 178 | ID3Tag_Link(ID3Tag *tag, const wchar_t *fileName) |
| 179 | #else |
| 180 | ID3_C_EXPORT size_t CCONV |
| 181 | ID3Tag_Link(ID3Tag *tag, const char *fileName) |
| 182 | #endif |
| 183 | { |
| 184 | size_t offset = 0; |
| 185 | if (tag) |
| 186 | { |
| 187 | ID3_CATCH(offset = reinterpret_cast<ID3_Tag *>(tag)->Link(fileName)); |
| 188 | } |
| 189 | return offset; |
| 190 | } |
| 191 | |
| 192 | #ifdef WIN32 |
| 193 | ID3_C_EXPORT size_t CCONV |
| 194 | ID3Tag_LinkWithFlags(ID3Tag *tag, const wchar_t *fileName, flags_t flags) |
| 195 | #else |
| 196 | ID3_C_EXPORT size_t CCONV |
| 197 | ID3Tag_LinkWithFlags(ID3Tag *tag, const char *fileName, flags_t flags) |
| 198 | #endif |
| 199 | { |
| 200 | size_t offset = 0; |
| 201 | if (tag) |
| 202 | { |
| 203 | ID3_CATCH(offset = reinterpret_cast<ID3_Tag *>(tag)->Link(fileName,flags)); |
| 204 | } |
| 205 | return offset; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | |
| 210 | ID3_C_EXPORT ID3_Err CCONV |
| 211 | ID3Tag_Update(ID3Tag *tag) |
| 212 | { |
| 213 | flags_t flags = 0; |
| 214 | if (tag) |
| 215 | { |
| 216 | ID3_CATCH(flags = reinterpret_cast<ID3_Tag *>(tag)->Update()); |
| 217 | } |
| 218 | return ID3E_NoError; |
| 219 | } |
| 220 | |
| 221 | ID3_C_EXPORT ID3_Err CCONV |
| 222 | ID3Tag_UpdateByTagType(ID3Tag *tag, flags_t tag_type) |
| 223 | { |
| 224 | flags_t flags = 0; |
| 225 | if (tag) |
| 226 | { |
| 227 | ID3_CATCH(flags = reinterpret_cast<ID3_Tag *>(tag)->Update(tag_type)); |
| 228 | } |
| 229 | return ID3E_NoError; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | ID3_C_EXPORT ID3_Err CCONV |
| 234 | ID3Tag_Strip(ID3Tag *tag, flags_t ulTagFlags) |
| 235 | { |
| 236 | if (tag) |
| 237 | { |
| 238 | ID3_CATCH(reinterpret_cast<ID3_Tag *>(tag)->Strip(ulTagFlags)); |
| 239 | } |
| 240 | return ID3E_NoError; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | ID3_C_EXPORT ID3Frame* CCONV |
| 245 | ID3Tag_FindFrameWithID(const ID3Tag *tag, ID3_FrameID id) |
| 246 | { |
| 247 | ID3_Frame *frame = NULL; |
| 248 | |
| 249 | if (tag) |
| 250 | { |
| 251 | ID3_CATCH(frame = reinterpret_cast<const ID3_Tag *>(tag)->Find(id)); |
| 252 | } |
| 253 | |
| 254 | return reinterpret_cast<ID3Frame *>(frame); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | ID3_C_EXPORT ID3Frame* CCONV |
| 259 | ID3Tag_FindFrameWithINT(const ID3Tag *tag, ID3_FrameID id, |
| 260 | ID3_FieldID fld, uint32 data) |
| 261 | { |
| 262 | ID3_Frame *frame = NULL; |
| 263 | |
| 264 | if (tag) |
| 265 | { |
| 266 | ID3_CATCH(frame = reinterpret_cast<const ID3_Tag *>(tag)->Find(id, fld, data)); |
| 267 | } |
| 268 | |
| 269 | return reinterpret_cast<ID3Frame *>(frame); |
| 270 | } |
| 271 | |
| 272 | |
| 273 | ID3_C_EXPORT ID3Frame* CCONV |
| 274 | ID3Tag_FindFrameWithASCII(const ID3Tag *tag, ID3_FrameID id, |
| 275 | ID3_FieldID fld, const char *data) |
| 276 | { |
| 277 | ID3_Frame *frame = NULL; |
| 278 | |
| 279 | if (tag) |
| 280 | { |
| 281 | ID3_CATCH(frame = reinterpret_cast<const ID3_Tag *>(tag)->Find(id, fld, data)); |
| 282 | } |
| 283 | |
| 284 | return reinterpret_cast<ID3Frame *>(frame); |
| 285 | } |
| 286 | |
| 287 | |
| 288 | ID3_C_EXPORT ID3Frame* CCONV |
| 289 | ID3Tag_FindFrameWithUNICODE(const ID3Tag *tag, ID3_FrameID id, |
| 290 | ID3_FieldID fld, const unicode_t *data) |
| 291 | { |
| 292 | ID3_Frame *frame = NULL; |
| 293 | |
| 294 | if (tag) |
| 295 | { |
| 296 | ID3_CATCH(frame = reinterpret_cast<const ID3_Tag *>(tag)->Find(id, fld, data)); |
| 297 | } |
| 298 | |
| 299 | return reinterpret_cast<ID3Frame *>(frame); |
| 300 | } |
| 301 | |
| 302 | |
| 303 | ID3_C_EXPORT size_t CCONV |
| 304 | ID3Tag_NumFrames(const ID3Tag *tag) |
| 305 | { |
| 306 | size_t num = 0; |
| 307 | |
| 308 | if (tag) |
| 309 | { |
| 310 | ID3_CATCH(num = reinterpret_cast<const ID3_Tag *>(tag)->NumFrames()); |
| 311 | } |
| 312 | |
| 313 | return num; |
| 314 | } |
| 315 | |
| 316 | |
| 317 | ID3_C_EXPORT bool CCONV |
| 318 | ID3Tag_HasTagType(const ID3Tag *tag, ID3_TagType tt) |
| 319 | { |
| 320 | bool has_tt = false; |
| 321 | |
| 322 | if (tag) |
| 323 | { |
| 324 | ID3_CATCH(has_tt = reinterpret_cast<const ID3_Tag *>(tag)->HasTagType(tt)); |
| 325 | } |
| 326 | |
| 327 | return has_tt; |
| 328 | } |
| 329 | |
| 330 | ID3_C_EXPORT ID3TagIterator* CCONV |
| 331 | ID3Tag_CreateIterator(ID3Tag* tag) |
| 332 | { |
| 333 | ID3_Tag::Iterator* iter = NULL; |
| 334 | |
| 335 | if (tag) |
| 336 | { |
| 337 | ID3_CATCH(iter = reinterpret_cast<ID3_Tag*>(tag)->CreateIterator()); |
| 338 | } |
| 339 | |
| 340 | return reinterpret_cast<ID3TagIterator*>(iter); |
| 341 | } |
| 342 | |
| 343 | ID3_C_EXPORT ID3TagConstIterator* CCONV |
| 344 | ID3Tag_CreateConstIterator(const ID3Tag* tag) |
| 345 | { |
| 346 | ID3_Tag::ConstIterator* iter = NULL; |
| 347 | |
| 348 | if (tag) |
| 349 | { |
| 350 | ID3_CATCH(iter = reinterpret_cast<const ID3_Tag*>(tag)->CreateIterator()); |
| 351 | } |
| 352 | |
| 353 | return reinterpret_cast<ID3TagConstIterator*>(iter); |
| 354 | } |
| 355 | |
| 356 | ID3_C_EXPORT void CCONV |
| 357 | ID3TagIterator_Delete(ID3TagIterator *iter) |
| 358 | { |
| 359 | if (iter) |
| 360 | { |
| 361 | ID3_CATCH(delete reinterpret_cast<ID3_Tag::Iterator*>(iter)); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | ID3_C_EXPORT ID3Frame* CCONV |
| 366 | ID3TagIterator_GetNext(ID3TagIterator *iter) |
| 367 | { |
| 368 | ID3_Frame* frame = NULL; |
| 369 | if (iter) |
| 370 | { |
| 371 | ID3_CATCH(frame = reinterpret_cast<ID3_Tag::Iterator*>(iter)->GetNext()); |
| 372 | } |
| 373 | return reinterpret_cast<ID3Frame*>(frame); |
| 374 | } |
| 375 | |
| 376 | ID3_C_EXPORT void CCONV |
| 377 | ID3TagConstIterator_Delete(ID3TagConstIterator *iter) |
| 378 | { |
| 379 | if (iter) |
| 380 | { |
| 381 | ID3_CATCH(delete reinterpret_cast<ID3_Tag::ConstIterator*>(iter)); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | ID3_C_EXPORT const ID3Frame* CCONV |
| 386 | ID3TagConstIterator_GetNext(ID3TagConstIterator *iter) |
| 387 | { |
| 388 | const ID3_Frame* frame = NULL; |
| 389 | if (iter) |
| 390 | { |
| 391 | ID3_CATCH(frame = reinterpret_cast<ID3_Tag::ConstIterator*>(iter)->GetNext()); |
| 392 | } |
| 393 | return reinterpret_cast<const ID3Frame*>(frame); |
| 394 | } |
| 395 | |
| 396 | // frame wrappers |
| 397 | |
| 398 | ID3_C_EXPORT ID3Frame* CCONV |
| 399 | ID3Frame_New(void) |
| 400 | { |
| 401 | ID3_Frame* frame = NULL; |
| 402 | ID3_CATCH(frame = new ID3_Frame); |
| 403 | return reinterpret_cast<ID3Frame *>(frame); |
| 404 | } |
| 405 | |
| 406 | ID3_C_EXPORT ID3Frame* CCONV |
| 407 | ID3Frame_NewID(ID3_FrameID id) |
| 408 | { |
| 409 | ID3_Frame* frame = NULL; |
| 410 | ID3_CATCH(frame = new ID3_Frame(id)); |
| 411 | return reinterpret_cast<ID3Frame *>(frame); |
| 412 | } |
| 413 | |
| 414 | ID3_C_EXPORT void CCONV |
| 415 | ID3Frame_Delete(ID3Frame *frame) |
| 416 | { |
| 417 | if (frame) |
| 418 | { |
| 419 | ID3_CATCH(delete reinterpret_cast<ID3_Frame *>(frame)); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | |
| 424 | ID3_C_EXPORT void CCONV |
| 425 | ID3Frame_Clear(ID3Frame *frame) |
| 426 | { |
| 427 | if (frame) |
| 428 | { |
| 429 | ID3_CATCH(reinterpret_cast<ID3_Frame *>(frame)->Clear()); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | |
| 434 | ID3_C_EXPORT void CCONV |
| 435 | ID3Frame_SetID(ID3Frame *frame, ID3_FrameID id) |
| 436 | { |
| 437 | if (frame) |
| 438 | { |
| 439 | ID3_CATCH(reinterpret_cast<ID3_Frame *>(frame)->SetID(id)); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | |
| 444 | ID3_C_EXPORT ID3_FrameID CCONV |
| 445 | ID3Frame_GetID(const ID3Frame *frame) |
| 446 | { |
| 447 | ID3_FrameID id = ID3FID_NOFRAME; |
| 448 | |
| 449 | if (frame) |
| 450 | { |
| 451 | ID3_CATCH(id = reinterpret_cast<const ID3_Frame *>(frame)->GetID()); |
| 452 | } |
| 453 | |
| 454 | return id; |
| 455 | } |
| 456 | |
| 457 | |
| 458 | ID3_C_EXPORT ID3Field* CCONV |
| 459 | ID3Frame_GetField(const ID3Frame *frame, ID3_FieldID name) |
| 460 | { |
| 461 | ID3_Field *field = NULL; |
| 462 | |
| 463 | if (frame) |
| 464 | { |
| 465 | ID3_CATCH(field = reinterpret_cast<const ID3_Frame *>(frame)->GetField(name)); |
| 466 | } |
| 467 | |
| 468 | return reinterpret_cast<ID3Field *>(field); |
| 469 | } |
| 470 | |
| 471 | |
| 472 | ID3_C_EXPORT void CCONV |
| 473 | ID3Frame_SetCompression(ID3Frame *frame, bool comp) |
| 474 | { |
| 475 | if (frame) |
| 476 | { |
| 477 | ID3_CATCH(reinterpret_cast<ID3_Frame *>(frame)->SetCompression(comp)); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | |
| 482 | ID3_C_EXPORT bool CCONV |
| 483 | ID3Frame_GetCompression(const ID3Frame *frame) |
| 484 | { |
| 485 | bool compressed = false; |
| 486 | if (frame) |
| 487 | { |
| 488 | ID3_CATCH(compressed = reinterpret_cast<const ID3_Frame *>(frame)->GetCompression()); |
| 489 | } |
| 490 | return compressed; |
| 491 | } |
| 492 | |
| 493 | |
| 494 | // field wrappers |
| 495 | |
| 496 | |
| 497 | ID3_C_EXPORT void CCONV |
| 498 | ID3Field_Clear(ID3Field *field) |
| 499 | { |
| 500 | if (field) |
| 501 | { |
| 502 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Clear()); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | |
| 507 | ID3_C_EXPORT size_t CCONV |
| 508 | ID3Field_Size(const ID3Field *field) |
| 509 | { |
| 510 | size_t size = 0; |
| 511 | |
| 512 | if (field) |
| 513 | { |
| 514 | ID3_CATCH(size = reinterpret_cast<const ID3_Field *>(field)->Size()); |
| 515 | } |
| 516 | |
| 517 | return size; |
| 518 | } |
| 519 | |
| 520 | |
| 521 | ID3_C_EXPORT size_t CCONV |
| 522 | ID3Field_GetNumTextItems(const ID3Field *field) |
| 523 | { |
| 524 | size_t items = 0; |
| 525 | |
| 526 | if (field) |
| 527 | { |
| 528 | ID3_CATCH(items = reinterpret_cast<const ID3_Field *>(field)->GetNumTextItems()); |
| 529 | } |
| 530 | |
| 531 | return items; |
| 532 | } |
| 533 | |
| 534 | |
| 535 | ID3_C_EXPORT void CCONV |
| 536 | ID3Field_SetINT(ID3Field *field, uint32 data) |
| 537 | { |
| 538 | if (field) |
| 539 | { |
| 540 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Set(data)); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | |
| 545 | ID3_C_EXPORT uint32 CCONV |
| 546 | ID3Field_GetINT(const ID3Field *field) |
| 547 | { |
| 548 | uint32 value = 0; |
| 549 | |
| 550 | if (field) |
| 551 | { |
| 552 | ID3_CATCH(value = reinterpret_cast<const ID3_Field *>(field)->Get()); |
| 553 | } |
| 554 | |
| 555 | return value; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | ID3_C_EXPORT void CCONV |
| 560 | ID3Field_SetUNICODE(ID3Field *field, const unicode_t *string) |
| 561 | { |
| 562 | if (field) |
| 563 | { |
| 564 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Set(string)); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | |
| 569 | ID3_C_EXPORT size_t CCONV |
| 570 | ID3Field_GetUNICODE(const ID3Field *field, unicode_t *buffer, size_t maxChars) |
| 571 | { |
| 572 | size_t numChars = 0; |
| 573 | |
| 574 | if (field) |
| 575 | { |
| 576 | ID3_CATCH(numChars = reinterpret_cast<const ID3_Field *>(field)->Get(buffer, maxChars)); |
| 577 | } |
| 578 | |
| 579 | return numChars; |
| 580 | } |
| 581 | |
| 582 | |
| 583 | ID3_C_EXPORT size_t CCONV |
| 584 | ID3Field_GetUNICODEItem(const ID3Field *field, unicode_t *buffer, |
| 585 | size_t maxChars, size_t itemNum) |
| 586 | { |
| 587 | size_t numChars = 0; |
| 588 | |
| 589 | if (field) |
| 590 | { |
| 591 | ID3_CATCH(numChars = reinterpret_cast<const ID3_Field *>(field)->Get(buffer, maxChars, itemNum)); |
| 592 | } |
| 593 | |
| 594 | return numChars; |
| 595 | } |
| 596 | |
| 597 | |
| 598 | ID3_C_EXPORT void CCONV |
| 599 | ID3Field_AddUNICODE(ID3Field *field, const unicode_t *string) |
| 600 | { |
| 601 | if (field) |
| 602 | { |
| 603 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Add(string)); |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | |
| 608 | ID3_C_EXPORT void CCONV |
| 609 | ID3Field_SetASCII(ID3Field *field, const char *string) |
| 610 | { |
| 611 | dami::String Str ; |
| 612 | |
| 613 | if (field) |
| 614 | { |
| 615 | Str.append ( string ) ; |
| 616 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->SetText(string)); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | |
| 621 | ID3_C_EXPORT size_t CCONV |
| 622 | ID3Field_GetASCII(const ID3Field *field, char *buffer, size_t maxChars) |
| 623 | { |
| 624 | |
| 625 | return ID3Field_GetASCIIItem ( field, buffer, maxChars, 0 ) ; |
| 626 | } |
| 627 | |
| 628 | ID3_C_EXPORT size_t CCONV |
| 629 | ID3Field_GetASCIIItem(const ID3Field *field, char *buffer, |
| 630 | size_t maxChars, size_t itemNum) |
| 631 | { |
| 632 | const char *p ; |
| 633 | dami::String Str ; |
| 634 | size_t numChars = 0 ; |
| 635 | |
| 636 | if (field) |
| 637 | { |
| 638 | ID3_CATCH(Str = reinterpret_cast<const ID3_Field *>(field)->GetText(itemNum,ID3TE_ASCII)); |
| 639 | p = Str.c_str() ; |
| 640 | strncpy ( buffer, p, maxChars ) ; |
| 641 | buffer[maxChars-1] = 0 ; |
| 642 | numChars = strlen ( buffer ) ; |
| 643 | } |
| 644 | |
| 645 | return numChars; |
| 646 | } |
| 647 | |
| 648 | |
| 649 | ID3_C_EXPORT void CCONV |
| 650 | ID3Field_AddASCII(ID3Field *field, const char *string) |
| 651 | { |
| 652 | if (field) |
| 653 | { |
| 654 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Add(string)); |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | |
| 659 | ID3_C_EXPORT void CCONV |
| 660 | ID3Field_SetEncoding(ID3Field *field, const ID3_TextEnc enc) |
| 661 | { |
| 662 | if (field) |
| 663 | { |
| 664 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->SetEncoding(enc)); |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | |
| 669 | ID3_C_EXPORT void CCONV |
| 670 | ID3Field_SetBINARY(ID3Field *field, const uchar *data, size_t size) |
| 671 | { |
| 672 | if (field) |
| 673 | { |
| 674 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->Set(data, size)); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | |
| 679 | ID3_C_EXPORT void CCONV |
| 680 | ID3Field_GetBINARY(const ID3Field *field, uchar *buffer, size_t buffLength) |
| 681 | { |
| 682 | if (field) |
| 683 | { |
| 684 | ID3_CATCH(reinterpret_cast<const ID3_Field *>(field)->Get(buffer, buffLength)); |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | |
| 689 | ID3_C_EXPORT void CCONV |
| 690 | ID3Field_FromFile(ID3Field *field, const char *fileName) |
| 691 | { |
| 692 | if (field) |
| 693 | { |
| 694 | ID3_CATCH(reinterpret_cast<ID3_Field *>(field)->FromFile(fileName)); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | |
| 699 | ID3_C_EXPORT void CCONV |
| 700 | ID3Field_ToFile(const ID3Field *field, const char *fileName) |
| 701 | { |
| 702 | if (field) |
| 703 | { |
| 704 | ID3_CATCH(reinterpret_cast<const ID3_Field *>(field)->ToFile(fileName)); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | ID3_C_EXPORT const Mp3_Headerinfo* CCONV |
| 709 | ID3Tag_GetMp3HeaderInfo ( ID3Tag *tag ) |
| 710 | { |
| 711 | const Mp3_Headerinfo *HeaderInfo = NULL ; |
| 712 | if ( tag ) |
| 713 | { |
| 714 | ID3_CATCH(HeaderInfo = reinterpret_cast<ID3_Tag *>(tag)->GetMp3HeaderInfo()) ; |
| 715 | } |
| 716 | return HeaderInfo ; |
| 717 | } |
| 718 | |
| 719 | #ifdef __cplusplus |
| 720 | } |
| 721 | #endif /* __cplusplus */ |
| 722 | |