|
Hmm, you are quite right. Looking at the code a bit harder (I was scared off by CMapStringToOb looking so complicated) I can see he has nothing more than a list of objects derived from the same class, nothing more than that. So I can try with std::list and do the clever bits in a simpler way.
I was hoping to avoid changing every single reference to the things (this is a very large amount of code), but it has to be done, and this week no-one is there to ask what I'm doing. I have redesigned this project quite a lot since it landed on my desk, and this is just about the last untouched corner.
-------------
Bibo ergo sum
|
|
|
|
|
RedSonja wrote: I can see he has nothing more than a list of objects derived from the same class, nothing more than that. So I can try with std::list and do the clever bits in a simpler way.
It is a bit more complex than just a list. It is a map which associate each object to a key (being a string). No duplicate key can be found in the map.
To begin working with a std::map, you can look at these tutorials: here[^] or here[^]. You can probably find hundreds of tutorials on the net if you google a bit.
|
|
|
|
|
Yes, I spotted the key, I need some of those too. Thank you for the tutorials, I shall have a look.
-------------
Bibo ergo sum
|
|
|
|
|
Hi.. i want to write xmlwriter function for writing in xml file in c++.Is there any MFC class by which i can implement it or any sample code as reference.
Thanks
amit
|
|
|
|
|
Don't think MFC has any XML functionality built in.
If you're just writing XML, genx is very easy to use.
Other options include MSXML or libxml2 (which has an XML writer API). I personally don't like MSXML too much for C++, as calling it via COM is a bit of a pain.
|
|
|
|
|
If you need to write some simple XML then you can hand-craft it (writing XML is far simpler than reading -parsing- it). If you need a full-fledged XMLWriter then you may use a library, as suggested by Stuart Dootson.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: If you need to write some simple XML then you can hand-craft it
To be honest, I'd always recommend using a writer, as it'll (hopefully) remember to do things like specifying the file's encoding, closing tags, quoting text etc. The quoting text bit, especially, is very easy to forget to do or, even if you remember it, easy to get wrong.
|
|
|
|
|
All do you need then is an XML validator tool. IMHO Writing hand-crafted XML has some educational purposes too.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for reply. I have looked for msxml for doing xml operation. I have my parser reader function I need to implement writer function or function to modify existing file. So if I had an xml document and I want to move to specific tag given its ID. Would I have to iterate through all the nodes until I found the tag with the id I wanted or is there a quicker way in msxml. I have read its sdk but fails to find anything regarding this.
Thanks
amit
amit
|
|
|
|
|
No, you haven't to. You may search for nodes, see for instance [^] or [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Whats the size of each pixel of a bitmap in memory?
|
|
|
|
|
I suppose it depends on color depth...
See BITMAP struct definition [^], the bmBitsPixel member looks promising.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I was thinking it depends on the resolution...
|
|
|
|
|
That was exactly what traveled my brain for a while.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Look up DIBs and BMP format. Technically the size of a pixel is something like "bmPlanes * bmBitsPerPixel", but I have never seen the number of planes set to anything other than 1.
You need to look up the format because that is not enough information to actually read a .bmp file; each row is aligned on a 4 byte boundry.
Why the planes where specified (I know) is up to you to figure out.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hello,
can somebosy help me...
Im creating a combobox in AddFrm.cpp - Oncreate method which is in toolbar control.
But i have one menu on click of which i want to disable that combobox in some other class.
Can Anybosy help me out
............
ASAp
Thanks
tina
|
|
|
|
|
There can be multiple ways of doing that. You could have a global variable which contains a pointer onto a CComboBox class, or have the handle of the combo stored that way, or you can make a member in the class that belongs to what you are placing the combo on behave the same way and make that member accessible from elsewhere, or or or, if you want more specific help, show us some code, like how you create the combo and where you want to enable/disable it...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Why don't you post the relevant code? It would be much easier for anyone who wants to answer that way.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I have a feature that requires an additional library to be linked to my project.
#define ENABLE_FEATURE
#ifdef ENABLE_FEATURE
void foo()
{
bar();
}
#pragma ???????? // some way to tell the linker to do that?
#endif
I have a *.LIB file and i want to link the project to it if ENABLE_FEATURE is defined, if it not, however, the library shouldn't be linked to reduce the exe size.
My question is: is there any way to link the project to the library without creating two separate project configurations? My project is developed with VC++ 6.0
Right now I have two project configurations, one linking with the library and one which doesn't, and I have to constantly switch between them, and if ENABLE_FEATURE doesn't match the correct configuration it will either fail to link or it will crash at runtime.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Wednesday, January 7, 2009 6:58 AM
|
|
|
|
|
sashoalm wrote: Right now I have two project configurations, one linking with the library and one which doesn't, and I have to constantly switch between them, and if ENABLE_FEATURE doesn't match the correct configuration it will either fail to link or it will crash at runtime.
ENABLE_FEATURE switch should be set as per configuration property.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi, CPallini,
Thanks for the answer!
The project has a little quirk however. The lib file is actually linking to dlls, and I use Inno Setup to create installations. Inno Setup has preprocessor with the same syntax, so I use a config.h header file that's included both in my Stdafx.h and in Setup.iss files.
I wan't when I disable the feature, the code that calls it to be omitted, the linker to remove the library, and the dlls to be omitted from the install.
And the project is already built around the idea that you have a config.h file that's included everywhere in the project (and in Setup.iss file), so changing that for one feature would be confusing, while changing it for all #defines and settings would be too much of a change.
Anyway, I found this a pragma that might work, and I'm testing it right now:
#pragma comment(lib, "mylib.lib")
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Try this:
#pragma comment(lib, "LibraryName.lib")
See here[^] for more information.
Steve
|
|
|
|
|
Thanks
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
It's slightly obscure, but you can use the following to tell the linker to add a lib file:
#ifdef MY_SHINY_FEATURE
#pragma comment(lib, "shinylib")
#endif // MY_SHINY_FEATURE
...
void DoSomethingMaybe ()
{
#ifdef MY_SHINY_FEATURE
shinyfunction ();
#endif // MY_SHINY_FEATURE
}
Iain.
|
|
|
|
|
Thanks!
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|