bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions


From: David Sugar
Subject: Re: Questions
Date: Tue, 29 Jan 2002 10:33:56 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010914

I tended to keep away from STL and templates in GNU Common C++ because many compilers tend to generate poor code for template classes and often it swells the size of the resulting executable unreasonably for the small footprint I wanted. However, it certainly works well with STL and there are now GNU Common C++ template classes as well.

GNU Common C++ has something called a "RWLock" which I believe does what your reader/writer class does. However, it requires pthread support for shared locks, and this is not common. It would be useful if RWLock could fall back to your proposed implimentation for platforms and targets which do not support this, as currently it falls back to a far less efficient standard Mutex now.

I would find it very useful to have a Path class in GNU Common C++. If it can provide realpath() validation as well, that would be ideal, as then it can be used to check reach of filepaths in applications that may wish to restrict file access to select portions of the filesystem.

Your template class sounds like it could be useful in the GNU Common C++ template library.

David

David Durham wrote:

Hi, I just found this library today in search of something like it and was pleasently surprised. Because I want to release some source code soon, I've recently been trying to move away from my little libraries that I've used for years to more standard stuff. I've converted one of my projects to the STL now that it is defined and comes sufficiently well implemented on gcc and other compilers. I was wondering if CommonC++ uses the STL whereever possible. I don't guess much of it requires a whole lot of container-like use, perhaps the persistance stuff. I could find any classes that dealt with time... maybe I missed it... I saw dates, but no date/time class. I have one if necessary.

Also, I have a class that is a readers/writers mutex which is simply wrapped around 2 other mutexes, so it would be simple to merge into CommonC++. Basically, it allows 1 write lock but multiple simultaneous read locks. Is there another way of doing that already in CommonC++?

I also have an idea for a Path class which would have functionality that, constructed from a string, would have methods of getting the directory or the filename from it. The implementation isn't as trivial as finding the last '/', because you have to correctly handle '.' as the entire path. glibc does have pathname and dirname, but they comform to the SUSv2 standard, so are not guarenteed to be on all systems. I suppose you could imagine other things you could use a Path class for, perhaps breaking the path up into all the directories components, making sure paths exist, touching files, etc... If this sounds like a worthy class to implement for CommonC++, I'd be glad to write it. Currently, I have an .h file which has dirname, basename and touch functions, but again, I'm trying to move as much as possible away from these little implementations which aren't even autoconfiscated.

Lastly, I have a couple of template classes which are used to create temporary buffers of memory or temporary arrays of object which get deallocted when the variable goes out of scope. I know you'd think that auto_ptr in the STL can be used for this, but it can only (as far as I can tell) be used for a single object, and not an array of objects. Plus, my template class can auto cast to a pointer of the type it is instantiated for, or a void * and can be subscripted all of which auto_ptr doesn't do. -- Davy
_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-commoncpp






reply via email to

[Prev in Thread] Current Thread [Next in Thread]