<div>Hello everybody, </div><div><br></div><div>I am trying to use TagLib to extract tags from a stream and store it in a std::string. Here is the function I used:</div><div><br></div><div>void TopWin::insert_tag_on_db(std::vector<std::string> &filenames) {</div>
<div> for (std::vector<std::string>::iterator iter = filenames.begin(); iter != filenames.end(); ++iter) {</div><div> TagLib::FileRef file((*iter).c_str());</div><div> </div><div> if (!file.isNull() && file.tag()) {</div>
<div> TagLib::Tag *tag = file.tag();</div><div> TagLib::AudioProperties *properties = file.audioProperties();</div><div> </div><div> int seconds = properties->length() % 60;</div><div> int minutes = (properties->length() - seconds) / 60;</div>
<div> </div><div> //error occurs here</div><div> std::string insert = "INSERT INTO SongList (track, name, genre, artist, album, time, uri) values (" + tag->track() + ", '" + tag->title() + "', '" + tag->genre() + "', '" + tag->artist() + "', '" + tag->album() + "', '" + minutes + ":" + seconds + "', '" + *iter + "');";</div>
<div> }</div><div> }</div><div>}</div><div><br></div><div>However, the program was not compiled. g++ reported an error:</div><div><div><br></div><div>/home/phongcao/dingo/topwin.cc:16: error: invalid operands of types ‘const char*’ and ‘const char [4]’ to binary ‘operator+’</div>
</div><div><br></div><div>I have read the TagLib documentation and it said that the TagLib's return type is TagLib::String. What I do not understand here is whether TagLib::String is similar to std::string or char*? If it is similar to std::string then what is the source of the above error?</div>
<div><br></div><div>I guess the source of the error is that I was trying to concatenate tag->title(), tag->track(), etc... (which may have types char*, since I do not know TagLib::String is a CString or a std::string) to a string literal. Can you guys suggest a solution to fix this error?</div>
<div><br></div><div><br></div><div>Thank you for reading my message! Have a good day!</div><div><br></div><div><br></div><div>Best regards,</div><br>-- <br>Phong V. Cao<div><a href="mailto:phngcv@gmail.com" target="_blank">phngcv@gmail.com</a></div>
<div><a href="mailto:caoph@rider.edu" target="_blank">caoph@rider.edu</a></div><div><br></div><br>