
I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things: 1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation? 2. The ability to memory map a file. I saw mapped_file which I guess is the one. Simon

File ManipulationYou can take a look at shmem if you want to map a file to memory. Haven't tried it myself yet though. Cheers -----Mensaje original----- De: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]En nombre de Simon Reye Enviado el: viernes, 14 de julio de 2006 7:46 Para: boost-users@lists.boost.org Asunto: [Boost-users] File Manipulation I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things: 1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation? 2. The ability to memory map a file. I saw mapped_file which I guess is the one. Simon

From the boost website it seems that shmem has been accepted but it's been over a year since a new version of boost has been released. Is there a new boost version coming out soon or do I just have to download and build shmem myself?
Simon -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Berenguer Blasi Sent: Friday, 14 July 2006 6:50 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] File Manipulation You can take a look at shmem if you want to map a file to memory. Haven't tried it myself yet though. Cheers -----Mensaje original----- De: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]En nombre de Simon Reye Enviado el: viernes, 14 de julio de 2006 7:46 Para: boost-users@lists.boost.org Asunto: [Boost-users] File Manipulation I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things: 1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation? 2. The ability to memory map a file. I saw mapped_file which I guess is the one. Simon

MessageNo idea on when a new version is going to be released... you can download it from CVS though. -----Mensaje original----- De: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]En nombre de Simon Reye Enviado el: lunes, 17 de julio de 2006 3:27 Para: boost-users@lists.boost.org Asunto: Re: [Boost-users] Shmem (was File Manipulation) From the boost website it seems that shmem has been accepted but it's been over a year since a new version of boost has been released. Is there a new boost version coming out soon or do I just have to download and build shmem myself? Simon -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Berenguer Blasi Sent: Friday, 14 July 2006 6:50 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] File Manipulation You can take a look at shmem if you want to map a file to memory. Haven't tried it myself yet though. Cheers -----Mensaje original----- De: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]En nombre de Simon Reye Enviado el: viernes, 14 de julio de 2006 7:46 Para: boost-users@lists.boost.org Asunto: [Boost-users] File Manipulation I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things: 1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation? 2. The ability to memory map a file. I saw mapped_file which I guess is the one. Simon

From the boost website it seems that shmem has been accepted but it's been over a year since a new version of boost has been released. Is there a new boost version coming out soon or do I just have to download and build shmem myself?
Shmem was accepted and many changes were requested. As a result, I'm developing Boost.Interprocess, that will be the official Boost version of the library. Shmem is in a bug fix state. You can download it from Boost.Vault and Sandbox CVS. I plan to upload a new version of Boost.Interprocess in a week to Boost CVS and Vault. Interprocess has many breaking changes from Shmem, but essentially will allow the same features as Shmem plus new interprocess communication mechanisms. I work the faster I can (lately, not very fast, I admit). Interprocess won't appear officially until Boost 1.35. Regards, Ion
Simon
-----Original Message----- *From:* boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] *On Behalf Of *Berenguer Blasi *Sent:* Friday, 14 July 2006 6:50 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] File Manipulation
You can take a look at shmem if you want to map a file to memory.
Haven't tried it myself yet though.
Cheers
-----Mensaje original----- *De:* boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]*En nombre de *Simon Reye *Enviado el:* viernes, 14 de julio de 2006 7:46 *Para:* boost-users@lists.boost.org *Asunto:* [Boost-users] File Manipulation
I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things:
1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation?
2. The ability to memory map a file. I saw mapped_file which I guess is the one.
Simon
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Thanks. I'll put up with APR (apache portable runtime) until I see Interprocess completed. Simon
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ion Gaztañaga Sent: Tuesday, 18 July 2006 4:26 AM To: Boost User List Subject: Re: [Boost-users] Shmem (was File Manipulation)
From the boost website it seems that shmem has been accepted but it's been over a year since a new version of boost has been released. Is there a new boost version coming out soon or do I just have to download and build shmem myself?
Shmem was accepted and many changes were requested. As a result, I'm developing Boost.Interprocess, that will be the official Boost version of the library. Shmem is in a bug fix state. You can download it from Boost.Vault and Sandbox CVS. I plan to upload a new version of Boost.Interprocess in a week to Boost CVS and Vault. Interprocess has many breaking changes from Shmem, but essentially will allow the same features as Shmem plus new interprocess communication mechanisms. I work the faster I can (lately, not very fast, I admit). Interprocess won't appear officially until Boost 1.35.
Regards,
Ion
Simon
-----Original Message----- *From:* boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] *On Behalf Of *Berenguer Blasi *Sent:* Friday, 14 July 2006 6:50 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] File Manipulation
You can take a look at shmem if you want to map a file to memory.
Haven't tried it myself yet though.
Cheers
-----Mensaje original----- *De:* boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]*En nombre de *Simon Reye *Enviado el:* viernes, 14 de julio de 2006 7:46 *Para:* boost-users@lists.boost.org *Asunto:* [Boost-users] File Manipulation
I've had a look through the iostream stuff but my head can't think straight this late in the week. I require two things:
1. The ability to truncate and grow a file. I see the seek/write functions which I'm guessing will take care of my growth needs but what about truncation?
2. The ability to memory map a file. I saw mapped_file which I guess is the one.
Simon
----------------------------------------------------------------------
--
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/bo> ost-users

Hi, I have tried everything so far and maybe it's the sun, the heat or whatever but I can't get flat_multimap from shmem to insert a value. I have: typedef boost::shmem::flat_multimap<size_t, myShmNode*, myHashEqual, myShmNodePtrAllocator> MyMultiMap; and I have tried an insert with a typedef std::pair<size_t,myShmNode*> multiMapNodeType; as an argument to 'insert' without success. Can someone tell me what sould I put as an argument to the call to 'insert' for the above declaration of a flat_multimap? Thanks in advance!

Hi,
I have tried everything so far and maybe it's the sun, the heat or whatever but I can't get flat_multimap from shmem to insert a value.
I have:
typedef boost::shmem::flat_multimap<size_t, myShmNode*, myHashEqual, myShmNodePtrAllocator> MyMultiMap;
and I have tried an insert with a typedef std::pair<size_t,myShmNode*> multiMapNodeType; as an argument to 'insert' without success.
Can someone tell me what sould I put as an argument to the call to 'insert' for the above declaration of a flat_multimap?
Can you give a small example to know what myHashEqual and myShmNodePtrAllocator are defined? flat_multimap is an ordered container (just like std::map) so a the ordering function should be a LessThan like ordering function and not an Equality function. Can you write a small test case just creating a multimap and inserting a value that shows those typedefs? Regards, Ion

Sure Ion, thanks for answering. Commenting or uncommenting the last line (the one with insert) you get the compilation error. I don?t know how to insert something into the multimap... Thanks in advance (I tried to follow the code behind flat_tree but got confused as I think a std::pair is what's expected??) --------------- #include <vector> #include <boost/shmem/named_shared_object.hpp> #include <boost/shmem/containers/string.hpp> #include <boost/shmem/containers/flat_set.hpp> #include <boost/shmem/containers/flat_map.hpp> #include <boost/shmem/allocators/allocator.hpp> #include <boost/shmem/offset_ptr.hpp> #include <boost/functional/hash.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/member.hpp> class myShmNode { //whatever }; typedef boost::shmem::allocator<myShmNode *, boost::shmem::named_shared_object::segment_manager> myShmNodePtrAllocator; typedef boost::shmem::flat_multimap<size_t, myShmNode*, std::less<myShmNode*>, myShmNodePtrAllocator> MyMultiMap; int main(int argc, char *argv[]) { boost::shmem::named_shared_object segment; segment.create( "/MySharedMemory", 1048576 ); //Initialize shared memory STL-compatible allocators myShmNodePtrAllocator nodesPtrsAllocator(segment.get_segment_manager()); std::less<myShmNode*> comparator2; MyMultiMap* ptrsMultiMap=segment.construct<MyMultiMap>(boost::shmem::anonymous_instance) (comparator2,nodesPtrsAllocator); typedef std::pair<size_t,myShmNode*> multiMapNodeType; multiMapNodeType multiMapNode; myShmNode* myNode; multiMapNode.first = 1; multiMapNode.second = myNode; ptrsMultiMap->insert(multiMapNode); }

Hi Berenguer, flat_map has the same interface as map so if you have more problems, try to make an small example using map. Regarding flat_xxx family: The comparison function must compare keys, not mapped types: std::less<size_t> The allocator must allocate pairs: allocator <std::pair<size_t, myShmNode*>, segment_manager> if you were using boost::shmem::map the stored objects are const keys so you would need allocator <std::pair<const size_t, myShmNode*>, segment_manager> This is your modified example. Compiles fine in Visual 7.1. I left commented the code I've changed: #include <vector> #include <boost/shmem/named_shared_object.hpp> #include <boost/shmem/containers/string.hpp> #include <boost/shmem/containers/flat_set.hpp> #include <boost/shmem/containers/flat_map.hpp> #include <boost/shmem/allocators/allocator.hpp> #include <boost/shmem/offset_ptr.hpp> #include <boost/functional/hash.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/member.hpp> class myShmNode { //whatever }; typedef boost::shmem::allocator <std::pair<std::size_t, myShmNode *>/*myShmNode **/ ,boost::shmem::named_shared_object::segment_manager> myShmNodePtrAllocator; typedef boost::shmem::flat_multimap <size_t ,myShmNode* ,std::less<std::size_t/*myShmNode**/> ,myShmNodePtrAllocator> MyMultiMap; int main(int argc, char *argv[]) { boost::shmem::named_shared_object segment; segment.create( "/MySharedMemory", 1048576 ); //Initialize shared memory STL-compatible allocators myShmNodePtrAllocator nodesPtrsAllocator(segment.get_segment_manager()); std::less<std::size_t/*myShmNode* */ > comparator2; MyMultiMap* ptrsMultiMap = segment.construct<MyMultiMap> (boost::shmem::anonymous_instance) (comparator2,nodesPtrsAllocator); typedef std::pair<size_t,myShmNode*> multiMapNodeType; multiMapNodeType multiMapNode; myShmNode* myNode; multiMapNode.first = 1; multiMapNode.second = myNode; ptrsMultiMap->insert(multiMapNode); }

Buf! Thanks a lot, would have never guessed so many things on my own. It works now. Cheers.
participants (3)
-
Berenguer Blasi
-
Ion Gaztañaga
-
Simon Reye