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