Boost logo

Boost Users :

Subject: Re: [Boost-users] Search and replace in text files with Boost.Xpressive
From: Júlio Hoffimann (julio.hoffimann_at_[hidden])
Date: 2011-04-02 11:00:09

Hi Eric,

Thank you for the perfect answer! Could you please guide me with some
classes/methods names in libraries you told?

For memory-map the file with Boost.Interprocess, what is the class you have
in mind? I found basic_managed_mapped_file but how can i use it with
Boost.Xpressive regex_replace() function?

I've looked Boost.Filesystem other day and someone told me about
unique_path() function, could i use it even with concurrent tasks
(Boost.MPI)? Change the model of unique_path() with the rank of the process
will avoid overwrite the generated files?

Best regards,

2011/4/2 Eric Niebler <eric_at_[hidden]>

> Hash: SHA1
> On 4/2/2011 8:23 AM, Júlio Hoffimann wrote:
> <snip>
> > As far as i know, Boost.Xpressive treats only std::string and C-like
> > strings.
> Not so. Both Boost.Xpressive and Boost.Regex work on bidirectional
> iterator.
> > What i need to do for work with text files? Put them inside a
> > std::string?
> That's one way. A more efficient way would be to memory-map the file,
> which I think you can do portably using Boost.Interprocess. That should
> give you a random-access iterator to the source file.
> > About the performance, the files has approximately 10^3
> > lines, the search and replace will be an issue?
> You should use the version of regex_replace that takes an output
> iterator, and either write into a string or vector. They both grow their
> capacity exponentially (or should if your STL implementation is worth
> anything), so this is quite efficient. Or, with an ofstream iterator,
> you can write directly to a temporary output file. I think the latest
> version of Boost.Filesystem has a portable way to create temporary
> files. Then you can do whatever you want with the temp file.
> HTH,
> - --
> Eric Niebler
> BoostPro Computing
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla -
> OjlI0cbWJhS+vvKDmGhFbRAGLLUdaQ+8rrmEtuPhbyKv3khjlVklgtbQlMoC9bu+
> RZrNgzVm2Ro1QcHG23NWsYky1NVuiaNXXHLB9kf05ibInzyVTvq3yewnBoXzMQ5o
> ynGFsSmbp+STAuESl/hUM+6yirqQHLXfuidBpXVFyTh/9TsL8FVYnsbrzxNrxwQB
> uhUYXCgPCxXC9MquxdH1MKNUcL1k9DQr7YGcZpHn6j+tsKHijEsfzn0Yy1KyMEIH
> Ljnx8dCszZrWobXUqjBVxMuK2m9ptbZeJfLfi/I6g9a5seoaPAdjIBl5zXo8qko=
> =t0HL
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at