Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

src/field.cpp

Go to the documentation of this file.
00001 // $Id: field.cpp,v 1.42 2001/09/08 21:33:18 shadrack Exp $
00002 
00003 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
00004 // Copyright 1999, 2000  Scott Thomas Haug
00005 
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Library General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or (at your
00009 // option) any later version.
00010 //
00011 // This library is distributed in the hope that it will be useful, but WITHOUT
00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 // License for more details.
00015 //
00016 // You should have received a copy of the GNU Library General Public License
00017 // along with this library; if not, write to the Free Software Foundation,
00018 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 
00020 // The id3lib authors encourage improvements and optimisations to be sent to
00021 // the id3lib coordinator.  Please see the README file for details on where to
00022 // send such submissions.  See the AUTHORS file for a list of people who have
00023 // contributed to id3lib.  See the ChangeLog file for a list of changes to
00024 // id3lib.  These files are distributed with id3lib at
00025 // http://download.sourceforge.net/id3lib/
00026 
00027 #if defined HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00031 
00032 
00033 #include <string.h>
00034 
00035 #include "field_impl.h"
00036 #include "utils.h"
00037 #include "field_def.h"
00038 #include "frame_def.h"
00039 #include "readers.h"
00040 
00041 using namespace dami;
00042 
00043 // This is used for unimplemented frames so that their data is preserved when
00044 // parsing and rendering
00045 static ID3_FieldDef ID3FD_Unimplemented[] =
00046 {
00047   {
00048     ID3FN_DATA,                         // FIELD NAME
00049     ID3FTY_BINARY,                      // FIELD TYPE
00050     0,                                  // FIXED LEN
00051     ID3V2_EARLIEST,                     // INITIAL SPEC
00052     ID3V2_LATEST,                       // ENDING SPEC
00053     ID3FF_NONE,                         // FLAGS
00054     ID3FN_NOFIELD                       // LINKED FIELD
00055   },
00056   { ID3FN_NOFIELD }
00057 };
00058 
00059 const ID3_FieldDef* ID3_FieldDef::DEFAULT = ID3FD_Unimplemented;
00060 
00061 static ID3_FieldDef ID3FD_URL[] =
00062 { 
00063   {
00064     ID3FN_URL,                          // FIELD NAME
00065     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00066     0,                                  // FIXED LEN
00067     ID3V2_EARLIEST,                     // INITIAL SPEC
00068     ID3V2_LATEST,                       // ENDING SPEC
00069     ID3FF_NONE,                         // FLAGS
00070     ID3FN_NOFIELD                       // LINKED FIELD
00071   },
00072   { ID3FN_NOFIELD }
00073 };
00074   
00075 static ID3_FieldDef ID3FD_UserURL[] =
00076 {
00077   {
00078     ID3FN_TEXTENC,                      // FIELD NAME        
00079     ID3FTY_INTEGER,                     // FIELD TYPE
00080     1,                                  // FIXED LEN
00081     ID3V2_EARLIEST,                     // INITIAL SPEC
00082     ID3V2_LATEST,                       // ENDING SPEC
00083     ID3FF_NONE,                         // FLAGS
00084     ID3FN_NOFIELD                       // LINKED FIELD
00085   },
00086   {
00087     ID3FN_DESCRIPTION,                  // FIELD NAME
00088     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00089     0,                                  // FIXED LEN
00090     ID3V2_EARLIEST,                     // INITIAL SPEC
00091     ID3V2_LATEST,                       // ENDING SPEC
00092     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00093     ID3FN_NOFIELD                       // LINKED FIELD
00094   },
00095   {
00096     ID3FN_URL,                          // FIELD NAME
00097     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00098     0,                                  // FIXED LEN
00099     ID3V2_EARLIEST,                     // INITIAL SPEC
00100     ID3V2_LATEST,                       // ENDING SPEC
00101     ID3FF_NONE,                         // FLAGS
00102     ID3FN_NOFIELD                       // LINKED FIELD
00103   },
00104   { ID3FN_NOFIELD }
00105 };
00106   
00107 static ID3_FieldDef ID3FD_Text[] =
00108 {
00109   {
00110     ID3FN_TEXTENC,                      // FIELD NAME
00111     ID3FTY_INTEGER,                     // FIELD TYPE
00112     1,                                  // FIXED LEN
00113     ID3V2_EARLIEST,                     // INITIAL SPEC
00114     ID3V2_LATEST,                       // ENDING SPEC
00115     ID3FF_NONE,                         // FLAGS
00116     ID3FN_NOFIELD                       // LINKED FIELD
00117   },
00118   {
00119     ID3FN_TEXT,                         // FIELD NAME
00120     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00121     0,                                  // FIXED LEN
00122     ID3V2_EARLIEST,                     // INITIAL SPEC
00123     ID3V2_LATEST,                       // ENDING SPEC
00124     ID3FF_ENCODABLE,                    // FLAGS
00125     ID3FN_NOFIELD                       // LINKED FIELD
00126   },
00127   { ID3FN_NOFIELD }
00128 };
00129   
00130   
00131 static ID3_FieldDef ID3FD_UserText[] =
00132 {
00133   {
00134     ID3FN_TEXTENC,                      // FIELD NAME
00135     ID3FTY_INTEGER,                     // FIELD TYPE
00136     1,                                  // FIXED LEN
00137     ID3V2_EARLIEST,                     // INITIAL SPEC
00138     ID3V2_LATEST,                       // ENDING SPEC
00139     ID3FF_NONE,                         // FLAGS
00140     ID3FN_NOFIELD                       // LINKED FIELD
00141   },
00142   {
00143     ID3FN_DESCRIPTION,                  // FIELD NAME
00144     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00145     0,                                  // FIXED LEN
00146     ID3V2_EARLIEST,                     // INITIAL SPEC
00147     ID3V2_LATEST,                       // ENDING SPEC
00148     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00149     ID3FN_NOFIELD                       // LINKED FIELD
00150   },
00151   {
00152     ID3FN_TEXT,                         // FIELD NAME
00153     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00154     0,                                  // FIXED LEN
00155     ID3V2_EARLIEST,                     // INITIAL SPEC
00156     ID3V2_LATEST,                       // ENDING SPEC
00157     ID3FF_ENCODABLE,                    // FLAGS
00158     ID3FN_NOFIELD                       // LINKED FIELD
00159   },
00160   { ID3FN_NOFIELD }
00161 };
00162   
00163   
00164 static ID3_FieldDef ID3FD_GeneralText[] =
00165 {
00166   {
00167     ID3FN_TEXTENC,                      // FIELD NAME
00168     ID3FTY_INTEGER,                     // FIELD TYPE
00169     1,                                  // FIXED LEN
00170     ID3V2_EARLIEST,                     // INITIAL SPEC
00171     ID3V2_LATEST,                       // ENDING SPEC
00172     ID3FF_NONE,                         // FLAGS
00173     ID3FN_NOFIELD                       // LINKED FIELD
00174   },
00175   {
00176     ID3FN_LANGUAGE,                     // FIELD NAME
00177     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00178     3,                                  // FIXED LEN
00179     ID3V2_EARLIEST,                     // INITIAL SPEC
00180     ID3V2_LATEST,                       // ENDING SPEC
00181     ID3FF_NONE,                         // FLAGS
00182     ID3FN_NOFIELD                       // LINKED FIELD
00183   },
00184   {
00185     ID3FN_DESCRIPTION,                  // FIELD NAME
00186     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00187     0,                                  // FIXED LEN
00188     ID3V2_EARLIEST,                     // INITIAL SPEC
00189     ID3V2_LATEST,                       // ENDING SPEC
00190     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00191     ID3FN_NOFIELD                       // LINKED FIELD
00192   },
00193   {
00194     ID3FN_TEXT,                         // FIELD NAME
00195     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00196     0,                                  // FIXED LEN
00197     ID3V2_EARLIEST,                     // INITIAL SPEC
00198     ID3V2_LATEST,                       // ENDING SPEC
00199     ID3FF_ENCODABLE,                    // FLAGS
00200     ID3FN_NOFIELD                       // LINKED FIELD
00201   },
00202   { ID3FN_NOFIELD }
00203 };
00204 
00205 static ID3_FieldDef ID3FD_TermsOfUse[] =
00206 {
00207   {
00208     ID3FN_TEXTENC,                      // FIELD NAME
00209     ID3FTY_INTEGER,                     // FIELD TYPE
00210     1,                                  // FIXED LEN
00211     ID3V2_3_0,                          // INITIAL SPEC
00212     ID3V2_LATEST,                       // ENDING SPEC
00213     ID3FF_NONE,                         // FLAGS
00214     ID3FN_NOFIELD                       // LINKED FIELD
00215   },
00216   {
00217     ID3FN_LANGUAGE,                     // FIELD NAME
00218     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00219     3,                                  // FIXED LEN
00220     ID3V2_3_0,                          // INITIAL SPEC
00221     ID3V2_LATEST,                       // ENDING SPEC
00222     ID3FF_NONE,                         // FLAGS
00223     ID3FN_NOFIELD                       // LINKED FIELD
00224   },
00225   {
00226     ID3FN_TEXT,                         // FIELD NAME
00227     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00228     0,                                  // FIXED LEN
00229     ID3V2_3_0,                          // INITIAL SPEC
00230     ID3V2_LATEST,                       // ENDING SPEC
00231     ID3FF_ENCODABLE,                    // FLAGS
00232     ID3FN_NOFIELD                       // LINKED FIELD
00233   },
00234   { ID3FN_NOFIELD }
00235 };
00236 
00237 static ID3_FieldDef ID3FD_LinkedInfo[] =
00238 {
00239   {
00240     ID3FN_ID,                           // FIELD NAME
00241     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00242     3,                                  // FIXED LEN
00243     ID3V2_EARLIEST,                     // INITIAL SPEC
00244     ID3V2_2_1,                          // ENDING SPEC
00245     ID3FF_NONE,                         // FLAGS
00246     ID3FN_NOFIELD                       // LINKED FIELD
00247   },
00248   {
00249     ID3FN_ID,                           // FIELD NAME
00250     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00251     4,                                  // FIXED LEN
00252     ID3V2_3_0,                          // INITIAL SPEC
00253     ID3V2_LATEST,                       // ENDING SPEC
00254     ID3FF_NONE,                         // FLAGS
00255     ID3FN_NOFIELD                       // LINKED FIELD
00256   },
00257   {
00258     ID3FN_URL,                          // FIELD NAME
00259     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00260     0,                                  // FIXED LEN
00261     ID3V2_EARLIEST,                     // INITIAL SPEC
00262     ID3V2_LATEST,                       // ENDING SPEC
00263     ID3FF_CSTR,                         // FLAGS
00264     ID3FN_NOFIELD                       // LINKED FIELD
00265   },
00266   {
00267     ID3FN_TEXT,                         // FIELD NAME
00268     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00269     0,                                  // FIXED LEN
00270     ID3V2_EARLIEST,                     // INITIAL SPEC
00271     ID3V2_LATEST,                       // ENDING SPEC
00272     ID3FF_NONE,                         // FLAGS
00273     ID3FN_NOFIELD                       // LINKED FIELD
00274   },
00275   { ID3FN_NOFIELD }
00276 };
00277 
00278 static ID3_FieldDef ID3FD_Picture[] =
00279 {
00280   {
00281     ID3FN_TEXTENC,                      // FIELD NAME
00282     ID3FTY_INTEGER,                     // FIELD TYPE
00283     1,                                  // FIXED LEN
00284     ID3V2_EARLIEST,                     // INITIAL SPEC
00285     ID3V2_LATEST,                       // ENDING SPEC
00286     ID3FF_NONE,                         // FLAGS
00287     ID3FN_NOFIELD                       // LINKED FIELD
00288   },
00289   {
00290     ID3FN_IMAGEFORMAT,                  // FIELD NAME
00291     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00292     3,                                  // FIXED LEN
00293     ID3V2_EARLIEST,                     // INITIAL SPEC
00294     ID3V2_2_1,                          // ENDING SPEC
00295     ID3FF_NONE,                         // FLAGS
00296     ID3FN_NOFIELD                       // LINKED FIELD
00297   },
00298   {
00299     ID3FN_MIMETYPE,                     // FIELD NAME
00300     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00301     0,                                  // FIXED LEN
00302     ID3V2_3_0,                          // INITIAL SPEC
00303     ID3V2_LATEST,                       // ENDING SPEC
00304     ID3FF_CSTR,                         // FLAGS
00305     ID3FN_NOFIELD                       // LINKED FIELD
00306   },
00307   {
00308     ID3FN_PICTURETYPE,                  // FIELD NAME
00309     ID3FTY_INTEGER,                     // FIELD TYPE
00310     1,                                  // FIXED LEN
00311     ID3V2_EARLIEST,                     // INITIAL SPEC
00312     ID3V2_LATEST,                       // ENDING SPEC
00313     ID3FF_NONE,                         // FLAGS
00314     ID3FN_NOFIELD                       // LINKED FIELD
00315   },
00316   {
00317     ID3FN_DESCRIPTION,                  // FIELD NAME
00318     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00319     0,                                  // FIXED LEN
00320     ID3V2_EARLIEST,                     // INITIAL SPEC
00321     ID3V2_LATEST,                       // ENDING SPEC
00322     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00323     ID3FN_NOFIELD                       // LINKED FIELD
00324   },
00325   {
00326     ID3FN_DATA,                         // FIELD NAME
00327     ID3FTY_BINARY,                      // FIELD TYPE
00328     0,                                  // FIXED LEN
00329     ID3V2_EARLIEST,                     // INITIAL SPEC
00330     ID3V2_LATEST,                       // ENDING SPEC
00331     ID3FF_NONE,                         // FLAGS
00332     ID3FN_NOFIELD                       // LINKED FIELD
00333   },
00334   { ID3FN_NOFIELD }
00335 };
00336   
00337 static ID3_FieldDef ID3FD_GEO[] =
00338 {
00339   {
00340     ID3FN_TEXTENC,                      // FIELD NAME
00341     ID3FTY_INTEGER,                     // FIELD TYPE
00342     1,                                  // FIXED LEN
00343     ID3V2_EARLIEST,                     // INITIAL SPEC
00344     ID3V2_LATEST,                       // ENDING SPEC
00345     ID3FF_NONE,                         // FLAGS
00346     ID3FN_NOFIELD                       // LINKED FIELD
00347   },
00348   {
00349     ID3FN_MIMETYPE,                     // FIELD NAME
00350     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00351     0,                                  // FIXED LEN
00352     ID3V2_EARLIEST,                     // INITIAL SPEC
00353     ID3V2_LATEST,                       // ENDING SPEC
00354     ID3FF_CSTR,                         // FLAGS
00355     ID3FN_NOFIELD                       // LINKED FIELD
00356   },
00357   {
00358     ID3FN_FILENAME,                     // FIELD NAME
00359     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00360     0,                                  // FIXED LEN
00361     ID3V2_EARLIEST,                     // INITIAL SPEC
00362     ID3V2_LATEST,                       // ENDING SPEC
00363     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00364     ID3FN_NOFIELD                       // LINKED FIELD
00365   },
00366   {
00367     ID3FN_DESCRIPTION,                  // FIELD NAME
00368     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00369     0,                                  // FIXED LEN
00370     ID3V2_EARLIEST,                     // INITIAL SPEC
00371     ID3V2_LATEST,                       // ENDING SPEC
00372     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00373     ID3FN_NOFIELD                       // LINKED FIELD
00374   },
00375   {
00376     ID3FN_DATA,                         // FIELD NAME
00377     ID3FTY_BINARY,                      // FIELD TYPE
00378     0,                                  // FIXED LEN
00379     ID3V2_EARLIEST,                     // INITIAL SPEC
00380     ID3V2_LATEST,                       // ENDING SPEC
00381     ID3FF_NONE,                         // FLAGS
00382     ID3FN_NOFIELD                       // LINKED FIELD
00383   },
00384   { ID3FN_NOFIELD }
00385 };
00386   
00387 static ID3_FieldDef ID3FD_UFI[] =
00388 {
00389   {
00390     ID3FN_OWNER,                        // FIELD NAME
00391     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00392     0,                                  // FIXED LEN
00393     ID3V2_EARLIEST,                     // INITIAL SPEC
00394     ID3V2_LATEST,                       // ENDING SPEC
00395     ID3FF_CSTR,                         // FLAGS
00396     ID3FN_NOFIELD                       // LINKED FIELD
00397   },
00398   {
00399     ID3FN_DATA,                         // FIELD NAME
00400     ID3FTY_BINARY,                      // FIELD TYPE
00401     0,                                  // FIXED LEN
00402     ID3V2_EARLIEST,                     // INITIAL SPEC
00403     ID3V2_LATEST,                       // ENDING SPEC
00404     ID3FF_NONE,                         // FLAGS
00405     ID3FN_NOFIELD                       // LINKED FIELD
00406   },
00407   { ID3FN_NOFIELD }
00408 };
00409   
00410 static ID3_FieldDef ID3FD_PlayCounter[] =
00411 {
00412   {
00413     ID3FN_COUNTER,                      // FIELD NAME
00414     ID3FTY_INTEGER,                     // FIELD TYPE
00415     4,                                  // FIXED LEN
00416     ID3V2_EARLIEST,                     // INITIAL SPEC
00417     ID3V2_LATEST,                       // ENDING SPEC
00418     ID3FF_NONE,                         // FLAGS
00419     ID3FN_NOFIELD                       // LINKED FIELD
00420   },
00421   { ID3FN_NOFIELD }
00422 };
00423   
00424 static ID3_FieldDef ID3FD_Popularimeter[] =
00425 {
00426   {
00427     ID3FN_EMAIL,                        // FIELD NAME
00428     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00429     0,                                  // FIXED LEN
00430     ID3V2_EARLIEST,                     // INITIAL SPEC
00431     ID3V2_LATEST,                       // ENDING SPEC
00432     ID3FF_CSTR,                         // FLAGS
00433     ID3FN_NOFIELD                       // LINKED FIELD
00434   },
00435   {
00436     ID3FN_RATING,                       // FIELD NAME
00437     ID3FTY_INTEGER,                     // FIELD TYPE
00438     1,                                  // FIXED LEN
00439     ID3V2_EARLIEST,                     // INITIAL SPEC
00440     ID3V2_LATEST,                       // ENDING SPEC
00441     ID3FF_NONE,                         // FLAGS
00442     ID3FN_NOFIELD                       // LINKED FIELD
00443   },
00444   {
00445     ID3FN_COUNTER,                      // FIELD NAME
00446     ID3FTY_INTEGER,                     // FIELD TYPE
00447     4,                                  // FIXED LEN
00448     ID3V2_EARLIEST,                     // INITIAL SPEC
00449     ID3V2_LATEST,                       // ENDING SPEC
00450     ID3FF_NONE,                         // FLAGS
00451     ID3FN_NOFIELD                       // LINKED FIELD
00452   },
00453   { ID3FN_NOFIELD }
00454 };
00455 
00456 static ID3_FieldDef ID3FD_Private[] =
00457 {
00458   {
00459     ID3FN_OWNER,                        // FIELD NAME
00460     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00461     0,                                  // FIXED LEN
00462     ID3V2_3_0,                          // INITIAL SPEC
00463     ID3V2_LATEST,                       // ENDING SPEC
00464     ID3FF_CSTR,                         // FLAGS
00465     ID3FN_NOFIELD                       // LINKED FIELD
00466   },
00467   {
00468     ID3FN_DATA,                         // FIELD NAME
00469     ID3FTY_BINARY,                      // FIELD TYPE
00470     0,                                  // FIXED LEN
00471     ID3V2_3_0,                          // INITIAL SPEC
00472     ID3V2_LATEST,                       // ENDING SPEC
00473     ID3FF_NONE,                         // FLAGS
00474     ID3FN_NOFIELD                       // LINKED FIELD
00475   },
00476   { ID3FN_NOFIELD }
00477 };
00478   
00479   
00480 static ID3_FieldDef ID3FD_Registration[] =
00481 {
00482   {
00483     ID3FN_OWNER,                        // FIELD NAME
00484     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00485     0,                                  // FIXED LEN
00486     ID3V2_3_0,                          // INITIAL SPEC
00487     ID3V2_LATEST,                       // ENDING SPEC
00488     ID3FF_CSTR,                         // FLAGS
00489     ID3FN_NOFIELD                       // LINKED FIELD
00490   },
00491   {
00492     ID3FN_ID,                           // FIELD NAME
00493     ID3FTY_INTEGER,                     // FIELD TYPE
00494     1,                                  // FIXED LEN
00495     ID3V2_3_0,                          // INITIAL SPEC
00496     ID3V2_LATEST,                       // ENDING SPEC
00497     ID3FF_NONE,                         // FLAGS
00498     ID3FN_NOFIELD                       // LINKED FIELD
00499   },
00500   {
00501     ID3FN_DATA,                         // FIELD NAME
00502     ID3FTY_BINARY,                      // FIELD TYPE
00503     0,                                  // FIXED LEN
00504     ID3V2_3_0,                          // INITIAL SPEC
00505     ID3V2_LATEST,                       // ENDING SPEC
00506     ID3FF_NONE,                         // FLAGS
00507     ID3FN_NOFIELD                       // LINKED FIELD
00508   },
00509   { ID3FN_NOFIELD }
00510 };
00511   
00512 static ID3_FieldDef ID3FD_InvolvedPeople[] =
00513 {
00514   {
00515     ID3FN_TEXTENC,                      // FIELD NAME
00516     ID3FTY_INTEGER,                     // FIELD TYPE
00517     1,                                  // FIXED LEN
00518     ID3V2_EARLIEST,                     // INITIAL SPEC
00519     ID3V2_LATEST,                       // ENDING SPEC
00520     ID3FF_NONE,                         // FLAGS
00521     ID3FN_NOFIELD                       // LINKED FIELD
00522   },
00523   {
00524     ID3FN_TEXT,                         // FIELD NAME
00525     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00526     0,                                  // FIXED LEN
00527     ID3V2_EARLIEST,                     // INITIAL SPEC
00528     ID3V2_LATEST,                       // ENDING SPEC
00529     ID3FF_TEXTLIST,                     // FLAGS
00530     ID3FN_NOFIELD                       // LINKED FIELD
00531   },
00532   { ID3FN_NOFIELD }
00533 };
00534 
00535 static ID3_FieldDef ID3FD_CDM[] =
00536 {
00537   {
00538     ID3FN_DATA,                         // FIELD NAME
00539     ID3FTY_BINARY,                      // FIELD TYPE
00540     0,                                  // FIXED LEN
00541     ID3V2_2_1,                          // INITIAL SPEC
00542     ID3V2_2_1,                          // ENDING SPEC
00543     ID3FF_NONE,                         // FLAGS
00544     ID3FN_NOFIELD                       // LINKED FIELD
00545   }
00546 };
00547 
00548 static ID3_FieldDef ID3FD_SyncLyrics[] = 
00549 {
00550   {
00551     ID3FN_TEXTENC,                      // FIELD NAME
00552     ID3FTY_INTEGER,                     // FIELD TYPE
00553     1,                                  // FIXED LEN
00554     ID3V2_EARLIEST,                     // INITIAL SPEC
00555     ID3V2_LATEST,                       // ENDING SPEC
00556     ID3FF_NONE,                         // FLAGS
00557     ID3FN_NOFIELD                       // LINKED FIELD
00558   },
00559   {
00560     ID3FN_LANGUAGE,                     // FIELD NAME
00561     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00562     3,                                  // FIXED LEN
00563     ID3V2_EARLIEST,                     // INITIAL SPEC
00564     ID3V2_LATEST,                       // ENDING SPEC
00565     ID3FF_NONE,                         // FLAGS
00566     ID3FN_NOFIELD                       // LINKED FIELD
00567   },
00568   {
00569     ID3FN_TIMESTAMPFORMAT,              // FIELD NAME
00570     ID3FTY_INTEGER,                     // FIELD TYPE
00571     1,                                  // FIXED LEN
00572     ID3V2_EARLIEST,                     // INITIAL SPEC
00573     ID3V2_LATEST,                       // ENDING SPEC
00574     ID3FF_NONE,                         // FLAGS
00575     ID3FN_NOFIELD                       // LINKED FIELD
00576   },
00577   {
00578     ID3FN_CONTENTTYPE,                  // FIELD NAME
00579     ID3FTY_INTEGER,                     // FIELD TYPE
00580     1,                                  // FIXED LEN
00581     ID3V2_EARLIEST,                     // INITIAL SPEC
00582     ID3V2_LATEST,                       // ENDING SPEC
00583     ID3FF_NONE,                         // FLAGS
00584     ID3FN_NOFIELD                       // LINKED FIELD
00585   },
00586   {
00587     ID3FN_DESCRIPTION,                  // FIELD NAME
00588     ID3FTY_TEXTSTRING,                  // FIELD TYPE
00589     0,                                  // FIXED LEN
00590     ID3V2_EARLIEST,                     // INITIAL SPEC
00591     ID3V2_LATEST,                       // ENDING SPEC
00592     ID3FF_CSTR | ID3FF_ENCODABLE,       // FLAGS
00593     ID3FN_NOFIELD                       // LINKED FIELD
00594   },
00595   {
00596     ID3FN_DATA,                         // FIELD NAME
00597     ID3FTY_BINARY,                      // FIELD TYPE
00598     0,                                  // FIXED LEN
00599     ID3V2_EARLIEST,                     // INITIAL SPEC
00600     ID3V2_LATEST,                       // ENDING SPEC
00601     ID3FF_NONE,                         // FLAGS
00602     ID3FN_NOFIELD                       // LINKED FIELD
00603   },
00604   { ID3FN_NOFIELD }
00605 };
00606 
00607 
00608 /*
00609  * Currently unused
00610  */
00611 #if defined _UNDEFINED_
00612 static ID3_FieldDef ID3FD_Volume[] =
00613 {
00614   {
00615     ID3FN_VOLUMEADJ,                    // FIELD NAME
00616     ID3FTY_INTEGER,                     // FIELD TYPE
00617     1,                                  // FIXED LEN
00618     ID3V2_EARLIEST,                     // INITIAL SPEC
00619     ID3V2_LATEST,                       // ENDING SPEC
00620     ID3FF_NONE,                         // FLAGS
00621     ID3FN_NOFIELD                       // LINKED FIELD
00622   },
00623   {
00624     ID3FN_NUMBITS,                      // FIELD NAME
00625     ID3FTY_INTEGER,                     // FIELD TYPE
00626     1,                                  // FIXED LEN
00627     ID3V2_EARLIEST,                     // INITIAL SPEC
00628     ID3V2_LATEST,                       // ENDING SPEC
00629     ID3FF_NONE,                         // FLAGS
00630     ID3FN_NOFIELD                       // LINKED FIELD
00631   },
00632   {
00633     ID3FN_VOLCHGRIGHT,                  // FIELD NAME
00634     ID3FTY_BITFIELD,                    // FIELD TYPE
00635     0,                                  // FIXED LEN
00636     ID3V2_EARLIEST,                     // INITIAL SPEC
00637     ID3V2_LATEST,                       // ENDING SPEC
00638     ID3FF_ADJUSTEDBY,                   // FLAGS
00639     ID3FN_NUMBITS                       // LINKED FIELD
00640   },
00641   {
00642     ID3FN_VOLCHGLEFT,                   // FIELD NAME
00643     ID3FTY_BITFIELD,                    // FIELD TYPE
00644     0,                                  // FIXED LEN
00645     ID3V2_EARLIEST,                     // INITIAL SPEC
00646     ID3V2_LATEST,                       // ENDING SPEC
00647     ID3FF_ADJUSTEDBY,                   // FLAGS
00648     ID3FN_NUMBITS                       // LINKED FIELD
00649   },
00650   {
00651     ID3FN_PEAKVOLRIGHT,                 // FIELD NAME
00652     ID3FTY_BITFIELD,                    // FIELD TYPE
00653     0,                                  // FIXED LEN
00654     ID3V2_EARLIEST,                     // INITIAL SPEC
00655     ID3V2_LATEST,                       // ENDING SPEC
00656     ID3FF_ADJUSTEDBY,                   // FLAGS
00657     ID3FN_NUMBITS                       // LINKED FIELD
00658   },
00659   {
00660     ID3FN_PEAKVOLLEFT,                  // FIELD NAME
00661     ID3FTY_BITFIELD,                    // FIELD TYPE
00662     0,                                  // FIXED LEN
00663     ID3V2_EARLIEST,                     // INITIAL SPEC
00664     ID3V2_LATEST,                       // ENDING SPEC
00665     ID3FF_ADJUSTEDBY,                   // FLAGS
00666     ID3FN_NUMBITS                       // LINKED FIELD
00667   },
00668   { ID3FN_NOFIELD }
00669 };
00670 #endif /* _UNDEFINED_ */
00671 
00672 // **** Currently Implemented Frames
00673 // APIC  PIC  ID3FID_PICTURE           Attached picture
00674 // COMM  COM  ID3FID_COMMENT           Comments
00675 // ENCR       ID3FID_CRYPTOREG         Encryption method registration
00676 // GEOB  GEO  ID3FID_GENERALOBJECT     General encapsulated object
00677 // GRID       ID3FID_GROUPINGREG       Group identification registration
00678 // IPLS  IPL  ID3FID_INVOLVEDPEOPLE    Involved people list
00679 // LINK  LNK  ID3FID_LINKEDINFO        Linked information
00680 // PCNT  CNT  ID3FID_PLAYCOUNTER       Play counter
00681 // POPM  POP  ID3FID_POPULARIMETER     Popularimeter
00682 // PRIV       ID3FID_PRIVATE           Private frame
00683 // SYLT  SLT  ID3FID_SYNCEDLYRICS      Synchronized lyric/text
00684 // TALB  TAL  ID3FID_ALBUM             Album/Movie/Show title
00685 // TBPM  TBP  ID3FID_BPM               BPM (beats per minute)
00686 // TCOM  TCM  ID3FID_COMPOSER          Composer
00687 // TCON  TCO  ID3FID_CONTENTTYPE       Content type
00688 // TCOP  TCR  ID3FID_COPYRIGHT         Copyright message
00689 // TDAT  TDA  ID3FID_DATE              Date
00690 // TDLY  TDY  ID3FID_PLAYLISTDELAY     Playlist delay
00691 // TENC  TEN  ID3FID_ENCODEDBY         Encoded by
00692 // TEXT  TXT  ID3FID_LYRICIST          Lyricist/Text writer
00693 // TFLT  TFT  ID3FID_FILETYPE          File type
00694 // TIME  TKE  ID3FID_TIME              Time
00695 // TIT1  TIM  ID3FID_CONTENTGROUP      Content group description
00696 // TIT2  TT1  ID3FID_TITLE             Title/songname/content description
00697 // TIT3  TT2  ID3FID_SUBTITLE          Subtitle/Description refinement
00698 // TKEY  TT3  ID3FID_INITIALKEY        Initial key
00699 // TLAN  TLA  ID3FID_LANGUAGE          Language(s)
00700 // TLEN  TLE  ID3FID_SONGLEN           Length
00701 // TMED  TMT  ID3FID_MEDIATYPE         Media type
00702 // TOAL  TOT  ID3FID_ORIGALBUM         Original album/movie/show title
00703 // TOFN  TOF  ID3FID_ORIGFILENAME      Original filename
00704 // TOLY  TOL  ID3FID_ORIGLYRICIST      Original lyricist(s)/text writer(s)
00705 // TOPE  TOA  ID3FID_ORIGARTIST        Original artist(s)/performer(s)
00706 // TORY  TOR  ID3FID_ORIGYEAR          Original release year
00707 // TOWN       ID3FID_FILEOWNER         File owner/licensee
00708 // TPE1  TP1  ID3FID_LEADARTIST        Lead performer(s)/Soloist(s)
00709 // TPE2  TP2  ID3FID_BAND              Band/orchestra/accompaniment
00710 // TPE3  TP3  ID3FID_CONDUCTOR         Conductor/performer refinement
00711 // TPE4  TP4  ID3FID_MIXARTIST         Interpreted, remixed, or otherwise modified
00712 // TPOS  TPA  ID3FID_PARTINSET         Part of a set
00713 // TPUB  TPB  ID3FID_PUBLISHER         Publisher
00714 // TRCK  TRK  ID3FID_TRACKNUM          Track number/Position in set
00715 // TRDA  TRD  ID3FID_RECORDINGDATES    Recording dates
00716 // TRSN  TRN  ID3FID_NETRADIOSTATION   Internet radio station name
00717 // TRSO  TRO  ID3FID_NETRADIOOWNER     Internet radio station owner
00718 // TSIZ  TSI  ID3FID_SIZE              Size
00719 // TSRC  TRC  ID3FID_ISRC              ISRC (international standard recording code)
00720 // TSSE  TSS  ID3FID_ENCODERSETTINGS   Software/Hardware and encoding settings
00721 // TXXX  TXX  ID3FID_USERTEXT          User defined text information
00722 // TYER  TYE  ID3FID_YEAR              Year
00723 // UFID  UFI  ID3FID_UNIQUEFILEID      Unique file identifier
00724 // USER       ID3FID_TERMSOFUSE        Terms of use
00725 // USLT  ULT  ID3FID_UNSYNCEDLYRICS    Unsynchronized lyric/text transcription
00726 // WCOM  WCM  ID3FID_WWWCOMMERCIALINFO Commercial information
00727 // WCOP  WCM  ID3FID_WWWCOPYRIGHT      Copyright/Legal infromation
00728 // WOAF  WCP  ID3FID_WWWAUDIOFILE      Official audio file webpage
00729 // WOAR  WAF  ID3FID_WWWARTIST         Official artist/performer webpage
00730 // WOAS  WAR  ID3FID_WWWAUDIOSOURCE    Official audio source webpage
00731 // WORS  WAS  ID3FID_WWWRADIOPAGE      Official internet radio station homepage
00732 // WPAY  WRA  ID3FID_WWWPAYMENT        Payment
00733 // WPUB  WPY  ID3FID_WWWPUBLISHER      Official publisher webpage
00734 // WXXX  WXX  ID3FID_WWWUSER           User defined URL link
00735 //       CDM  ID3FID_METACOMPRESSION   Compressed data meta frame
00736 
00737 // **** Currently unimplemented frames
00738 // AENC  CRA  ID3FID_AUDIOCRYPTO       Audio encryption
00739 // COMR       ID3FID_COMMERCIAL        Commercial frame
00740 // EQUA  EQU  ID3FID_EQUALIZATION      Equalization
00741 // ETCO  ETC  ID3FID_EVENTTIMING       Event timing codes
00742 // MCDI  MCI  ID3FID_CDID              Music CD identifier
00743 // MLLT  MLL  ID3FID_MPEGLOOKUP        MPEG location lookup table
00744 // OWNE       ID3FID_OWNERSHIP         Ownership frame
00745 // POSS       ID3FID_POSITIONSYNC      Position synchronisation frame
00746 // RBUF  BUF  ID3FID_BUFFERSIZE        Recommended buffer size
00747 // RVAD  RVA  ID3FID_VOLUMEADJ         Relative volume adjustment
00748 // RVRB  REV  ID3FID_REVERB            Reverb
00749 // SYTC  STC  ID3FID_SYNCEDTEMPO       Synchronized tempo codes
00750 //       CRM  ID3FID_METACRYPTO        Encrypted meta frame
00751 static  ID3_FrameDef ID3_FrameDefs[] =
00752 {
00753   //                          short  long   tag    file
00754   // frame id                 id     id     discrd discrd field defs           description
00755   {ID3FID_AUDIOCRYPTO,       "CRA", "AENC", false, false, ID3FD_Unimplemented, "Audio encryption"},
00756   {ID3FID_PICTURE,           "PIC", "APIC", false, false, ID3FD_Picture,       "Attached picture"},
00757   {ID3FID_COMMENT,           "COM", "COMM", false, false, ID3FD_GeneralText,   "Comments"},
00758   {ID3FID_COMMERCIAL,        ""   , "COMR", false, false, ID3FD_Unimplemented, "Commercial"},
00759   {ID3FID_CRYPTOREG,         ""   , "ENCR", false, false, ID3FD_Registration,  "Encryption method registration"},
00760   {ID3FID_EQUALIZATION,      "EQU", "EQUA", false, true,  ID3FD_Unimplemented, "Equalization"},
00761   {ID3FID_EVENTTIMING,       "ETC", "ETCO", false, true,  ID3FD_Unimplemented, "Event timing codes"},
00762   {ID3FID_GENERALOBJECT,     "GEO", "GEOB", false, false, ID3FD_GEO,           "General encapsulated object"},
00763   {ID3FID_GROUPINGREG,       ""   , "GRID", false, false, ID3FD_Registration,  "Group identification registration"},
00764   {ID3FID_INVOLVEDPEOPLE,    "IPL", "IPLS", false, false, ID3FD_InvolvedPeople,"Involved people list"},
00765   {ID3FID_LINKEDINFO,        "LNK", "LINK", false, false, ID3FD_LinkedInfo,    "Linked information"},
00766   {ID3FID_CDID,              "MCI", "MCDI", false, false, ID3FD_Unimplemented, "Music CD identifier"},
00767   {ID3FID_MPEGLOOKUP,        "MLL", "MLLT", false, true,  ID3FD_Unimplemented, "MPEG location lookup table"},
00768   {ID3FID_OWNERSHIP,         ""   , "OWNE", false, false, ID3FD_Unimplemented, "Ownership frame"},
00769   {ID3FID_PRIVATE,           ""   , "PRIV", false, false, ID3FD_Private,       "Private frame"},
00770   {ID3FID_PLAYCOUNTER,       "CNT", "PCNT", false, false, ID3FD_PlayCounter,   "Play counter"},
00771   {ID3FID_POPULARIMETER,     "POP", "POPM", false, false, ID3FD_Popularimeter, "Popularimeter"},
00772   {ID3FID_POSITIONSYNC,      ""   , "POSS", false, true,  ID3FD_Unimplemented, "Position synchronisation frame"},
00773   {ID3FID_BUFFERSIZE,        "BUF", "RBUF", false, false, ID3FD_Unimplemented, "Recommended buffer size"},
00774   {ID3FID_VOLUMEADJ,         "RVA", "RVAD", false, true,  ID3FD_Unimplemented, "Relative volume adjustment"},
00775   {ID3FID_REVERB,            "REV", "RVRB", false, false, ID3FD_Unimplemented, "Reverb"},
00776   {ID3FID_SYNCEDLYRICS,      "SLT", "SYLT", false, false, ID3FD_SyncLyrics,     "Synchronized lyric/text"},
00777   {ID3FID_SYNCEDTEMPO,       "STC", "SYTC", false, true,  ID3FD_Unimplemented, "Synchronized tempo codes"},
00778   {ID3FID_ALBUM,             "TAL", "TALB", false, false, ID3FD_Text,          "Album/Movie/Show title"},
00779   {ID3FID_BPM,               "TBP", "TBPM", false, false, ID3FD_Text,          "BPM (beats per minute)"},
00780   {ID3FID_COMPOSER,          "TCM", "TCOM", false, false, ID3FD_Text,          "Composer"},
00781   {ID3FID_CONTENTTYPE,       "TCO", "TCON", false, false, ID3FD_Text,          "Content type"},
00782   {ID3FID_COPYRIGHT,         "TCR", "TCOP", false, false, ID3FD_Text,          "Copyright message"},
00783   {ID3FID_DATE,              "TDA", "TDAT", false, false, ID3FD_Text,          "Date"},
00784   {ID3FID_PLAYLISTDELAY,     "TDY", "TDLY", false, false, ID3FD_Text,          "Playlist delay"},
00785   {ID3FID_ENCODEDBY,         "TEN", "TENC", false, true,  ID3FD_Text,          "Encoded by"},
00786   {ID3FID_LYRICIST,          "TXT", "TEXT", false, false, ID3FD_Text,          "Lyricist/Text writer"},
00787   {ID3FID_FILETYPE,          "TFT", "TFLT", false, false, ID3FD_Text,          "File type"},
00788   {ID3FID_TIME,              "TIM", "TIME", false, false, ID3FD_Text,          "Time"},
00789   {ID3FID_CONTENTGROUP,      "TT1", "TIT1", false, false, ID3FD_Text,          "Content group description"},
00790   {ID3FID_TITLE,             "TT2", "TIT2", false, false, ID3FD_Text,          "Title/songname/content description"},
00791   {ID3FID_SUBTITLE,          "TT3", "TIT3", false, false, ID3FD_Text,          "Subtitle/Description refinement"},
00792   {ID3FID_INITIALKEY,        "TKE", "TKEY", false, false, ID3FD_Text,          "Initial key"},
00793   {ID3FID_LANGUAGE,          "TLA", "TLAN", false, false, ID3FD_Text,          "Language(s)"},
00794   {ID3FID_SONGLEN,           "TLE", "TLEN", false, true,  ID3FD_Text,          "Length"},
00795   {ID3FID_MEDIATYPE,         "TMT", "TMED", false, false, ID3FD_Text,          "Media type"},
00796   {ID3FID_ORIGALBUM,         "TOT", "TOAL", false, false, ID3FD_Text,          "Original album/movie/show title"},
00797   {ID3FID_ORIGFILENAME,      "TOF", "TOFN", false, false, ID3FD_Text,          "Original filename"},
00798   {ID3FID_ORIGLYRICIST,      "TOL", "TOLY", false, false, ID3FD_Text,          "Original lyricist(s)/text writer(s)"},
00799   {ID3FID_ORIGARTIST,        "TOA", "TOPE", false, false, ID3FD_Text,          "Original artist(s)/performer(s)"},
00800   {ID3FID_ORIGYEAR,          "TOR", "TORY", false, false, ID3FD_Text,          "Original release year"},
00801   {ID3FID_FILEOWNER,         ""   , "TOWN", false, false, ID3FD_Text,          "File owner/licensee"},
00802   {ID3FID_LEADARTIST,        "TP1", "TPE1", false, false, ID3FD_Text,          "Lead performer(s)/Soloist(s)"},
00803   {ID3FID_BAND,              "TP2", "TPE2", false, false, ID3FD_Text,          "Band/orchestra/accompaniment"},
00804   {ID3FID_CONDUCTOR,         "TP3", "TPE3", false, false, ID3FD_Text,          "Conductor/performer refinement"},
00805   {ID3FID_MIXARTIST,         "TP4", "TPE4", false, false, ID3FD_Text,          "Interpreted, remixed, or otherwise modified by"},
00806   {ID3FID_PARTINSET,         "TPA", "TPOS", false, false, ID3FD_Text,          "Part of a set"},
00807   {ID3FID_PUBLISHER,         "TPB", "TPUB", false, false, ID3FD_Text,          "Publisher"},
00808   {ID3FID_TRACKNUM,          "TRK", "TRCK", false, false, ID3FD_Text,          "Track number/Position in set"},
00809   {ID3FID_RECORDINGDATES,    "TRD", "TRDA", false, false, ID3FD_Text,          "Recording dates"},
00810   {ID3FID_NETRADIOSTATION,   "TRN", "TRSN", false, false, ID3FD_Text,          "Internet radio station name"},
00811   {ID3FID_NETRADIOOWNER,     "TRO", "TRSO", false, false, ID3FD_Text,          "Internet radio station owner"},
00812   {ID3FID_SIZE,              "TSI", "TSIZ", false, true,  ID3FD_Text,          "Size"},
00813   {ID3FID_ISRC,              "TRC", "TSRC", false, false, ID3FD_Text,          "ISRC (international standard recording code)"},
00814   {ID3FID_ENCODERSETTINGS,   "TSS", "TSSE", false, false, ID3FD_Text,          "Software/Hardware and settings used for encoding"},
00815   {ID3FID_USERTEXT,          "TXX", "TXXX", false, false, ID3FD_UserText,      "User defined text information"},
00816   {ID3FID_YEAR,              "TYE", "TYER", false, false, ID3FD_Text,          "Year"},
00817   {ID3FID_UNIQUEFILEID,      "UFI", "UFID", false, false, ID3FD_UFI,           "Unique file identifier"},
00818   {ID3FID_TERMSOFUSE,        ""   , "USER", false, false, ID3FD_TermsOfUse,    "Terms of use"},
00819   {ID3FID_UNSYNCEDLYRICS,    "ULT", "USLT", false, false, ID3FD_GeneralText,   "Unsynchronized lyric/text transcription"},
00820   {ID3FID_WWWCOMMERCIALINFO, "WCM", "WCOM", false, false, ID3FD_URL,           "Commercial information"},
00821   {ID3FID_WWWCOPYRIGHT,      "WCP", "WCOP", false, false, ID3FD_URL,           "Copyright/Legal infromation"},
00822   {ID3FID_WWWAUDIOFILE,      "WAF", "WOAF", false, false, ID3FD_URL,           "Official audio file webpage"},
00823   {ID3FID_WWWARTIST,         "WAR", "WOAR", false, false, ID3FD_URL,           "Official artist/performer webpage"},
00824   {ID3FID_WWWAUDIOSOURCE,    "WAS", "WOAS", false, false, ID3FD_URL,           "Official audio source webpage"},
00825   {ID3FID_WWWRADIOPAGE,      "WRA", "WORS", false, false, ID3FD_URL,           "Official internet radio station homepage"},
00826   {ID3FID_WWWPAYMENT,        "WPY", "WPAY", false, false, ID3FD_URL,           "Payment"},
00827   {ID3FID_WWWPUBLISHER,      "WPB", "WPUB", false, false, ID3FD_URL,           "Official publisher webpage"},
00828   {ID3FID_WWWUSER,           "WXX", "WXXX", false, false, ID3FD_UserURL,       "User defined URL link"},
00829   {ID3FID_METACRYPTO,        "CRM", ""    , false, false, ID3FD_Unimplemented, "Encrypted meta frame"},
00830   {ID3FID_METACOMPRESSION,   "CDM", ""    , false, false, ID3FD_CDM,           "Compressed data meta frame"},
00831   {ID3FID_NOFRAME}
00832 };
00833   
00891 ID3_FieldImpl::ID3_FieldImpl()
00892   : _id(ID3FN_NOFIELD),
00893     _type(ID3FTY_INTEGER),
00894     _spec_begin(ID3V2_EARLIEST),
00895     _spec_end(ID3V2_LATEST),
00896     _flags(0),
00897     _changed(false),
00898     _fixed_size(0),
00899     _num_items(0),
00900     _enc(ID3TE_NONE)
00901 {
00902   this->Clear();
00903 }
00904 
00905 ID3_FieldImpl::ID3_FieldImpl(const ID3_FieldDef& def)
00906   : _id(def._id),
00907     _type(def._type),
00908     _spec_begin(def._spec_begin),
00909     _spec_end(def._spec_end),
00910     _flags(def._flags),
00911     _changed(false),
00912     _fixed_size(def._fixed_size),
00913     _num_items(0),
00914     _enc((_type == ID3FTY_TEXTSTRING) ? ID3TE_ASCII : ID3TE_NONE)
00915 {
00916   this->Clear();
00917 }
00918 
00919 ID3_FieldImpl::~ID3_FieldImpl()
00920 {
00921 }
00922 
00928 void ID3_FieldImpl::Clear()
00929 {
00930   switch (_type)
00931   {
00932     case ID3FTY_INTEGER:
00933     {
00934       _integer = 0;
00935       break;
00936     }
00937     case ID3FTY_BINARY:
00938     {
00939       _binary.erase();
00940       if (_fixed_size > 0)
00941       {
00942         _binary.assign(_fixed_size, '\0');
00943       }
00944       break;
00945     }
00946     case ID3FTY_TEXTSTRING:
00947     {
00948       _text.erase();
00949       if (_fixed_size > 0)
00950       {
00951         if (this->GetEncoding() == ID3TE_UNICODE)
00952         {
00953           _text.assign(_fixed_size * 2, '\0');
00954         }
00955         else if (this->GetEncoding() == ID3TE_ASCII)
00956         {
00957           _text.assign(_fixed_size, '\0');
00958         }
00959       }
00960       break;
00961     }
00962     default:
00963     {
00964       break;
00965     }
00966   }
00967   _changed    = true;
00968   
00969   return ;
00970 }
00971 
00972 bool
00973 ID3_FieldImpl::HasChanged() const
00974 {
00975   return _changed;
00976 }
00977 
00997 size_t ID3_FieldImpl::BinSize() const
00998 {
00999   if (_fixed_size > 0)
01000   {
01001     return _fixed_size;
01002   }
01003   size_t size = this->Size();
01004   if (_type == ID3FTY_TEXTSTRING)
01005   {
01006     ID3_TextEnc enc = this->GetEncoding();
01007     if (enc == ID3TE_UNICODE && size > 0)
01008     {
01009       size++;
01010     }
01011     if (_flags & ID3FF_CSTR)
01012     {
01013       size++;
01014     }
01015     if (enc == ID3TE_UNICODE)
01016     {
01017       size *= 2;
01018     }
01019   }
01020   return size;
01021 }
01022 
01023 size_t ID3_FieldImpl::Size() const
01024 {
01025   size_t size = 0;
01026   // check to see if we are within the legal limit for this field 0 means
01027   // arbitrary length field
01028   if (_fixed_size > 0)
01029   {
01030     size = _fixed_size;
01031   }
01032   else if (_type == ID3FTY_INTEGER)
01033   {
01034     size = sizeof(uint32);
01035   }
01036   else if (_type == ID3FTY_TEXTSTRING)
01037   {
01038     size = _text.size();
01039   }
01040   else
01041   {
01042     size = _binary.size();
01043   }
01044 
01045   return size;
01046 }
01047 
01048 bool ID3_FieldImpl::Parse(ID3_Reader& reader)
01049 {
01050   bool success = false;
01051   switch (this->GetType())
01052   {
01053     case ID3FTY_INTEGER:
01054     {
01055       success = this->ParseInteger(reader);
01056       break;
01057     }
01058         
01059     case ID3FTY_BINARY:
01060     {
01061       success = this->ParseBinary(reader);
01062       break;
01063     }
01064         
01065     case ID3FTY_TEXTSTRING:
01066     {
01067       success = this->ParseText(reader);
01068       break;
01069     }
01070 
01071     default:
01072     {
01073       ID3D_WARNING( "ID3_FieldImpl::Parse(): unknown field type" );
01074       break;
01075     }
01076   }
01077   return success;
01078 }
01079 
01080 ID3_FrameDef* ID3_FindFrameDef(ID3_FrameID id)
01081 {
01082   ID3_FrameDef  *info   = NULL;
01083 
01084   for (index_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; cur++)
01085   {
01086     if (ID3_FrameDefs[cur].eID == id)
01087     {
01088       info = &ID3_FrameDefs[cur];
01089       break;
01090     }
01091   }
01092     
01093   return info;
01094 }
01095 
01096 ID3_FrameID
01097 ID3_FindFrameID(const char *id)
01098 {
01099   ID3_FrameID fid = ID3FID_NOFRAME;
01100   
01101   for (index_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; cur++)
01102   {
01103     if (((strcmp(ID3_FrameDefs[cur].sShortTextID, id) == 0) &&
01104          strlen(id) == 3) ||
01105         ((strcmp(ID3_FrameDefs[cur].sLongTextID,  id) == 0) &&
01106          strlen(id) == 4))
01107     {
01108       fid = ID3_FrameDefs[cur].eID;
01109       break;
01110     }
01111   }
01112   
01113   return fid;
01114 }
01115 
01116 void ID3_FieldImpl::Render(ID3_Writer& writer) const
01117 {
01118   switch (this->GetType()) 
01119   {
01120     case ID3FTY_INTEGER:
01121     {
01122       RenderInteger(writer);
01123       break;
01124     }
01125         
01126     case ID3FTY_BINARY:
01127     {
01128       RenderBinary(writer);
01129       break;
01130     }
01131         
01132     case ID3FTY_TEXTSTRING:
01133     {
01134       RenderText(writer);
01135       break;
01136     }
01137         
01138     default:
01139     {
01140       ID3D_WARNING ( "ID3D_FieldImpl::Render(): unknown field type" );
01141       break;
01142     }
01143   }
01144 }
01145 
01146 ID3_Field &
01147 ID3_FieldImpl::operator=( const ID3_Field &rhs )
01148 {
01149   const ID3_FieldImpl* fld = (const ID3_FieldImpl*) &rhs;
01150   if (this != &rhs && this->GetType() == fld->GetType())
01151   {
01152     switch (fld->GetType())
01153     {
01154       case ID3FTY_INTEGER:
01155       {
01156         this->SetInteger(fld->GetInteger());
01157         break;
01158       }
01159       case ID3FTY_TEXTSTRING:
01160       {
01161         this->SetEncoding(fld->GetEncoding());
01162         this->SetText(fld->GetText());
01163         break;
01164       }
01165       case ID3FTY_BINARY:
01166       {
01167         this->SetBinary(fld->GetBinary());
01168         break;
01169       }
01170       default:
01171       {
01172         break;
01173       }
01174     }
01175   }
01176   return *this;
01177 }
01178 
01179 bool ID3_FieldImpl::SetEncoding(ID3_TextEnc enc)
01180 {
01181   bool changed = this->IsEncodable() && (enc != this->GetEncoding()) &&
01182     (ID3TE_NONE < enc && enc < ID3TE_NUMENCODINGS);
01183   if (changed)
01184   {
01185     _text = convert(_text, _enc, enc);
01186     _enc = enc;
01187     _changed = true;
01188   }
01189   return changed;
01190 }
01191 
01246 char *ID3_FrameInfo::ShortName(ID3_FrameID frameid) {
01247         if(frameid < ID3FID_LASTFRAMEID) {
01248                 return ID3_FrameDefs[frameid-1].sShortTextID;
01249         } else {
01250                 return NULL;
01251         }
01252 }
01253 
01254 char *ID3_FrameInfo::LongName(ID3_FrameID frameid) {
01255         if(frameid < ID3FID_LASTFRAMEID) {
01256                 return ID3_FrameDefs[frameid-1].sLongTextID;
01257         } else {
01258                 return NULL;
01259         }
01260 }
01261 
01262 const char *ID3_FrameInfo::Description(ID3_FrameID frameid) {
01263         if(frameid < ID3FID_LASTFRAMEID) {
01264                 return ID3_FrameDefs[frameid-1].sDescription;
01265         } else {
01266                 return NULL;
01267         }
01268 }
01269 
01270 int ID3_FrameInfo::MaxFrameID() {
01271         return ID3FID_LASTFRAMEID-1;
01272 }
01273 
01274 int ID3_FrameInfo::NumFields(ID3_FrameID frameid) {
01275         int fieldnum=0;
01276 
01277         while (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._id !=
01278                ID3FN_NOFIELD) {
01279                 fieldnum++;
01280         }
01281         return fieldnum;
01282 }
01283 
01284 ID3_FieldType ID3_FrameInfo::FieldType(ID3_FrameID frameid, int fieldnum) {
01285         return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._type);
01286 }
01287 
01288 size_t ID3_FrameInfo::FieldSize(ID3_FrameID frameid, int fieldnum) {
01289         return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._fixed_size);
01290 }
01291 
01292 flags_t ID3_FrameInfo::FieldFlags(ID3_FrameID frameid, int fieldnum) {
01293         return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._flags);
01294 }
01295 

Generated at Sat Sep 8 15:51:08 2001 for id3lib by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001