|
ABuenger wrote: How is an iterator more flexible than the methods of the MFC container classes? Do you really like the it->second syntax?
Yes, I do. It is much nicer than GetNext/GetPrev! The whole iterator idea is inspired.
ABuenger wrote: You can sort a CArray easily with qsort. qsort is already in the C-Runtime, so no need for an other library to do the same job.
Actually, you are relying on how a CArray works internally for qsort to work - if MS ever changes the internal representation of CArray, you're in trouble. Also, how about a custom sort? What if you have a CArray of custom classes and you want to sort on one member in particular? Easy in STL, not so using qsort. One reason I first looked at STL containers was because I was sick of writing custom sort handlers for different sorts of CArrays.
ABuenger wrote: but if you have the MFC containers, why should you bother with an other set of containers?
Because STL containers are better. Using the right tools for the job is surely the best way to code is it not?
|
|
|
|
|
Robert Edward Caldecott wrote: ABuenger wrote:
You can sort a CArray easily with qsort. qsort is already in the C-Runtime, so no need for an other library to do the same job.
Actually, you are relying on how a CArray works internally for qsort to work - if MS ever changes the internal representation of CArray, you're in trouble. Also, how about a custom sort? What if you have a CArray of custom classes and you want to sort on one member in particular? Easy in STL, not so using qsort
Also, std::sort is much faster[^] than qsort, and typesafe.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
ABuenger wrote: why should i bloat my executable with an other library?
I don't think that the STL is located in a Lib, since all code is in a header file which is included in your application (at least anly the classes/functions that are called/needed).
Whereas the CMap and the other MFC variants are located in a lib hence need to be loaded through a dll at startup. Therefore resulting in a larger memory footprint.
BTW... I use both so don't shoot me
codito ergo sum
|
|
|
|
|
BadKarma wrote: I don't think that the STL is located in a Lib, since all code is in a header file which is included in your application (at least anly the classes/functions that are called/needed).
The STL activates RTTI, expects exception handling to be active and its iterators are not always properly inlined by compilers.
That bloats the code by 50%.
|
|
|
|
|
ABuenger wrote: That bloats the code by 50%
Do you have an example of this "50%" bloat?
|
|
|
|
|
BTW, I just built an MFC app (statically linked) that using a CList/CArray and a std::vector/std::list - without STL the EXE is 308KB. With STL it is 308KB. No RTTI. No exception handling. And certainly no 50% code bloat - where _did_ you get that figure?
|
|
|
|
|
Just focusing on the containers alone when rating the STL architecture is to miss the most important aspect of STL - The separation of the containers from the algorithms which operate on them via the use of iterators. This is an extremely powerful concept. It's in a different league to the MFC container architecture in this respect. For example you can use the std::binary_search algorithm on std::vector , std::deque or even a plain C array. In short, STL kicks ass!
Steve
|
|
|
|
|
|
ABuenger wrote: Everytime i wonder why someone do this, there are equivalent classes in the MFC.
There are *some* equivalent classes, but nowhere near STL. More importantly, there is no equivalent for STL algorithms. Finally, many 3rd party libraries (Boost, for instance, but also WinSTL[^]) are designed to work with STL.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
IMO the only reason to use the MFC containers is so you can get ASSERTs in the debug version. But the performance is superior with STL...
Now it is clear that there is a snobbery about the use of STL: it is really easy to make something very powerful in 2 lines... but absolutely undecypherable - not sure about the spelling there . But that's a C tradition!
And yes (as stated above) the implementation of CMap is poor. And I could be wrong, but I seem to remember that when you iterate thorugh a map, the values are not sorted...
|
|
|
|
|
BadJerry wrote: And yes (as stated above) the implementation of CMap is poor. And I could be wrong, but I seem to remember that when you iterate thorugh a map, the values are not sorted...
CMap is based on a hash, not a sort. While it's possible, what would be a reason for iterating a CMap object? I've only ever used them to store and lookup items based on a key.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
You may need to iterate if you want to persist your map ... and the result (an xml file for instance) looks neater if the keys are sorted... a bit petty.
But yes it would be pointless to iterate through it to find a value
|
|
|
|
|
Hi all,
in my current task obfuscation is not enough, because I need to protect exe resources to be queried as well. For example, if someone try to open that encrypted exe in VS one will not be able to see resources. Any ideas, solutions?
Drca
|
|
|
|
|
Have you been through the Crypto API?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Can we encrypt resources inside and .exe ? encrypt bitmaps, menus, stringtables ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Yes, you can, and then store them as binary data - custom resources.
However, then you have to overload all your resource loaders to decrypt the data on the fly when they are read back in.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
yuck ... point taken ...
but it's not a default MFC/Windows behaviour; and all the extra work will eventually be defeated; if the user really likes your bitmaps and icons ( for example ), he can do a screen grab and manually extract them.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: but it's not a default MFC/Windows behaviour; and all the extra work will eventually be defeated; if the user really likes your bitmaps and icons ( for example ), he can do a screen grab and manually extract them.
Now we have to Encrypt the desktop too!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
You might be able to take something like UPX, modify the code to do some encryption, and use it, or purchase an off-the-shelf solution.
However, remember that encryption, unlike hashing, is designed to be undone - it is usually a matter of resources if someone really wants what you are hiding.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
-- modified at 14:03 Monday 13th February, 2006
|
|
|
|
|
|
The application has to listen for a broadcast and then reply to the workstation which has sent the broadcast.
André
|
|
|
|
|
Hi André,
Thanks a lot for help, Can you give me some links where i can find some samples of Broadcasting and also i came to know that Broadcasting Requires Administrative Permissions on the machine and not every machine reponds to it, is it so ? or is there any other way out ?
Thanks again
kss
|
|
|
|
|
fearless stallion wrote: where i can find some samples of Broadcasting and also i came to know that Broadcasting Requires Administrative Permissions on the machine and not every machine reponds to it, is it so ? or is there any other way out ?
actually it is very typical task !
First you have to enumerate the machine present on your network.. Now AFAIK socket connection doesnot need any administrative permission... so you can send udep socket to all the machine present in the network enquirying about wheather you application is running or not and increment teh counter whenever you recv the reply!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks a lot for the help
kss
|
|
|
|
|
On my current project I'm trying to include some sound. Now I have worked out how to use some of the MCI functions and messages to play my wav files.
Currently I have a looping background wav, and sevral other 'sound' wavs which are played depending on the users actions. (clicking a button etc..) Problem is, it sounds awful. Everything plays without a hitch, but the volume levels are just plain wrong. Most of my code is based on this tutorial http://www.codeproject.com/audio/mididemocp.asp with a few additions of my own.
Now my question is, how do you manipulate the volume levels of the files? My background music plays at the correct volume, but the other sounds are too quiet. Using the waveOutSetVolume() does not do what I need, it simply adjusts the windows global wave volume level. Also I must point out that I do not want to use DirectX or the MFC classes in this project.
|
|
|
|