[Insight-users] how to use itk::RegularExpressionSeriesFileNames

Luis Ibanez luis.ibanez at kitware.com
Wed Jun 3 17:17:21 EDT 2009


Hi Darren,

Thanks for posting the method for printing filenames.
It looks reasonable to add it to the class.


1)  Note that it may be more general if it takes as second
     argument a std::ostream, just as the PrintSelf() method
     does.

     In that way, it could be used for sending the list of
     filenames to a file, as well as to the standard output.


2)   The .c_str() doesn't seem to be necessary here.
      It should be fine to call (*nameIdx) as you suggest.


   Regards,


        Luis


-------------------------------------------------------------
On Wed, Jun 3, 2009 at 3:54 PM, Darren Weber
<darren.weber.lists at gmail.com>wrote:

>
> Oh, the class prints the file names in it's print method:
>
> nameGenerator->Print(std::cout, 0);
>
> A function to print only the file names (based on the test code):
>
> void printFileNames(std::vector<std::string> fileNames)
>     {
>     std::vector<std::string>::iterator nameIdx;
>     std::cout << "File names --------" << std::endl;
>     for (nameIdx = fileNames.begin();
>         nameIdx != fileNames.end();
>         nameIdx++)
>         {
>         std::cout << "File: " << (*nameIdx).c_str() << std::endl;
>         }
>     }
>
> Called as a regular function like:
>
> printFileNames(nameGenerator->GetFileNames());
>
> (BTW, why is the c_str() format used instead of std::cout << "File: " <<
> *nameIdx << std::endl;).
>
> As a method implementation, the call could simplify to something like:
>
> nameGenerator->PrintFileNames();
>
> Or it would have no input args and extract the file names within the method
> implementation (as in the Print method).
>
> Take care,
> Darren
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090603/4a7f04b3/attachment.htm>


More information about the Insight-users mailing list