<br>Hi Darren,<br><br>Thanks for posting the method for printing filenames.<br>It looks reasonable to add it to the class.<br><br><br>1) Note that it may be more general if it takes as second<br> argument a std::ostream, just as the PrintSelf() method<br>
does.<br><br> In that way, it could be used for sending the list of <br> filenames to a file, as well as to the standard output.<br><br><br>2) The .c_str() doesn't seem to be necessary here.<br> It should be fine to call (*nameIdx) as you suggest.<br>
<br><br> Regards,<br><br><br> Luis<br><br><br>-------------------------------------------------------------<br><div class="gmail_quote">On Wed, Jun 3, 2009 at 3:54 PM, Darren Weber <span dir="ltr"><<a href="mailto:darren.weber.lists@gmail.com">darren.weber.lists@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Oh, the class prints the file names in it's print method:<br><br><span style="font-family: courier new,monospace;">nameGenerator->Print(std::cout, 0);</span><br style="font-family: courier new,monospace;">
<br>A function to print only the file names (based on the test code):<br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void printFileNames(std::vector<std::string> fileNames)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> std::vector<std::string>::iterator nameIdx;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> std::cout << "File names --------" << std::endl;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> for (nameIdx = fileNames.begin();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> nameIdx != fileNames.end();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> nameIdx++)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> std::cout << "File: " << (*nameIdx).c_str() << std::endl;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } </span><br style="font-family: courier new,monospace;"><br>Called as a regular function like:<br><br><span style="font-family: courier new,monospace;">printFileNames(nameGenerator->GetFileNames());</span><br style="font-family: courier new,monospace;">
<br>(BTW, why is the c_str() format used instead of<span style="font-family: courier new,monospace;"> std::cout << "File: " << *nameIdx << std::endl;</span>).<br style="font-family: courier new,monospace;">
<br>As a method implementation, the call could simplify to something like:<br><br><span style="font-family: courier new,monospace;">nameGenerator-></span><span style="font-family: courier new,monospace;">PrintFileNames();</span><span style="font-family: courier new,monospace;"><br>
</span><br>Or it would have no input args and extract the file names within the method implementation (as in the Print method).<br><br>Take care,<br><font color="#888888">Darren</font><div><div></div><div class="h5"><br>
<br></div></div></blockquote></div><br>