Make the toString() method virtual

This commit is contained in:
Lukáš Lalinský 2012-11-12 16:22:23 +01:00
parent e8ae4ecd93
commit 60ba972244
6 changed files with 12 additions and 37 deletions

View File

@ -26,17 +26,11 @@
#include <stdlib.h>
#include <fileref.h>
#include <mp4file.h>
#include <tfile.h>
using namespace std;
using namespace TagLib;
#define MAYBE_PRINT_DESC(_Type) \
if(dynamic_cast<_Type *>(f.file())) { \
cout << dynamic_cast<_Type *>(f.file())->toString().to8Bit(true) << endl; \
found = 1; \
}
int main(int argc, char *argv[])
{
// process the command line args
@ -46,15 +40,8 @@ int main(int argc, char *argv[])
cout << "******************** \"" << argv[i] << "\"********************" << endl;
FileRef f(argv[i]);
bool found = 0;
if(!f.isNull() && f.file()) {
MAYBE_PRINT_DESC(MP4::File);
MAYBE_PRINT_DESC(File);
}
if(!found) {
cout << "could not find any information about the file" << endl;
cout << f.file()->toString().to8Bit(true) << endl;
}
}

View File

@ -87,7 +87,10 @@ namespace TagLib {
*/
virtual int channels() const = 0;
String toString() const;
/*!
* Returns description of the audio file.
*/
virtual String toString() const;
protected:

View File

@ -149,16 +149,3 @@ MP4::File::save()
return d->tag->save();
}
String
MP4::File::toString() const
{
StringList desc;
if(d->properties) {
desc.append(d->properties->toString());
}
if(d->tag) {
desc.append(d->tag->toString());
}
return desc.toString("\n");
}

View File

@ -100,11 +100,6 @@ namespace TagLib {
*/
bool save();
/*!
* Description of the file.
*/
String toString() const;
private:
void read(bool readProperties, Properties::ReadStyle audioPropertiesStyle);

View File

@ -179,7 +179,10 @@ namespace TagLib {
*/
static void duplicate(const Tag *source, Tag *target, bool overwrite = true);
String toString() const;
/*!
* Returns description of the tag.
*/
virtual String toString() const;
protected:
/*!

View File

@ -246,9 +246,9 @@ namespace TagLib {
static bool isWritable(const char *name);
/*!
* Description of the file.
* Returns description of the audio file and its tags.
*/
String toString() const;
virtual String toString() const;
protected:
/*!