<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&lt;std::string&gt; &amp;filenames) {</div>
<div>  for (std::vector&lt;std::string&gt;::iterator iter = filenames.begin(); iter != filenames.end(); ++iter) {</div><div>    TagLib::FileRef file((*iter).c_str());</div><div>    </div><div>    if (!file.isNull() &amp;&amp; file.tag()) {</div>
<div>      TagLib::Tag *tag = file.tag();</div><div>      TagLib::AudioProperties *properties = file.audioProperties();</div><div>      </div><div>      int seconds = properties-&gt;length() % 60;</div><div>      int minutes = (properties-&gt;length() - seconds) / 60;</div>
<div>      </div><div>      //error occurs here</div><div>      std::string insert = &quot;INSERT INTO SongList (track, name, genre, artist, album, time, uri) values (&quot; + tag-&gt;track() + &quot;, &#39;&quot; + tag-&gt;title() + &quot;&#39;, &#39;&quot; + tag-&gt;genre() + &quot;&#39;, &#39;&quot; + tag-&gt;artist() + &quot;&#39;, &#39;&quot; + tag-&gt;album() + &quot;&#39;, &#39;&quot; + minutes + &quot;:&quot; + seconds + &quot;&#39;, &#39;&quot; + *iter + &quot;&#39;);&quot;;</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&#39;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-&gt;title(), tag-&gt;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>