Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _ID3LIB_FIELD_IMPL_H_
00029 #define _ID3LIB_FIELD_IMPL_H_
00030
00031 #include <stdlib.h>
00032 #include "field.h"
00033 #include "id3/id3lib_strings.h"
00034
00035 struct ID3_FieldDef;
00036 struct ID3_FrameDef;
00037 class ID3_Frame;
00038 class ID3_Reader;
00039
00040 class ID3_FieldImpl : public ID3_Field
00041 {
00042 friend class ID3_FrameImpl;
00043 public:
00044 ~ID3_FieldImpl();
00045
00046 void Clear();
00047
00048 size_t Size() const;
00049 size_t BinSize() const;
00050 size_t GetNumTextItems() const;
00051
00052
00053 ID3_Field& operator= (uint32 val) { this->Set(val); return *this; }
00054 void Set(uint32);
00055 uint32 Get() const;
00056
00057 void SetInteger(uint32);
00058 uint32 GetInteger() const;
00059
00060
00061 ID3_Field& operator= (const char* s) { this->Set(s); return *this; }
00062 size_t Set(const char* data);
00063 size_t Get(char*, size_t) const;
00064 size_t Get(char*, size_t, size_t) const;
00065 const char* GetRawText() const;
00066 const char* GetRawTextItem(size_t) const;
00067 size_t Add(const char* data);
00068
00069 dami::String GetText() const;
00070 dami::String GetTextItem(size_t) const;
00071 size_t SetText(dami::String);
00072 size_t AddText(dami::String);
00073
00074
00075 ID3_Field& operator= (const unicode_t* s) { this->Set(s); return *this; }
00076 size_t Set(const unicode_t*);
00077 size_t Get(unicode_t *buffer, size_t) const;
00078 size_t Get(unicode_t *buffer, size_t, size_t) const;
00079 size_t Add(const unicode_t*);
00080 const unicode_t* GetRawUnicodeText() const;
00081 const unicode_t* GetRawUnicodeTextItem(size_t) const;
00082
00083
00084 size_t Set(const uchar* buf, size_t size);
00085 size_t Set(const char* buf, size_t size)
00086 {
00087 return this->Set(reinterpret_cast<const uchar *>(buf), size);
00088 }
00089 size_t Get(uchar*, size_t) const;
00090 const uchar* GetRawBinary() const;
00091 void FromFile(const char*);
00092 void ToFile(const char *sInfo) const;
00093
00094 size_t SetBinary(dami::BString);
00095 dami::BString GetBinary() const;
00096
00097
00098 ID3_Field& operator=( const ID3_Field & );
00099 bool InScope(ID3_V2Spec spec) const
00100 { return _spec_begin <= spec && spec <= _spec_end; }
00101
00102 ID3_FieldID GetID() const { return _id; }
00103 ID3_FieldType GetType() const { return _type; }
00104 bool SetEncoding(ID3_TextEnc enc);
00105 ID3_TextEnc GetEncoding() const { return _enc; }
00106 bool IsEncodable() const { return (_flags & ID3FF_ENCODABLE) > 0; }
00107
00108
00109 void Render(ID3_Writer&) const;
00110 bool Parse(ID3_Reader&);
00111 bool HasChanged() const;
00112
00113 private:
00114 size_t SetText_i(dami::String);
00115 size_t AddText_i(dami::String);
00116
00117 private:
00118
00119 ID3_FieldImpl();
00120 ID3_FieldImpl(const ID3_FieldDef&);
00121
00122 const ID3_FieldID _id;
00123 const ID3_FieldType _type;
00124 const ID3_V2Spec _spec_begin;
00125 const ID3_V2Spec _spec_end;
00126 const flags_t _flags;
00127 mutable bool _changed;
00128
00129 dami::BString _binary;
00130 dami::String _text;
00131 uint32 _integer;
00132
00133 const size_t _fixed_size;
00134 size_t _num_items;
00135 ID3_TextEnc _enc;
00136 protected:
00137 void RenderInteger(ID3_Writer&) const;
00138 void RenderText(ID3_Writer&) const;
00139 void RenderBinary(ID3_Writer&) const;
00140
00141 bool ParseInteger(ID3_Reader&);
00142 bool ParseText(ID3_Reader&);
00143 bool ParseBinary(ID3_Reader&);
00144
00145 };
00146
00147
00148
00149 ID3_FrameDef *ID3_FindFrameDef(ID3_FrameID id);
00150 ID3_FrameID ID3_FindFrameID(const char *id);
00151
00152 #endif
00153