|
Hi all,
sorry for this basic question...
I've got a std::list<myclass*> mlist and want to erase several elements.
I thought mlist.erase(iter) deletes the element pointed to by iter.
As this is a pointer, only the pointer should be erased, but the destructor of myclass is also called... Is this the desired behaviour?
Btw. how can I delete only the pointer but not the instance of my class?
I'm using the stl_eVC port for PocketPC
Thanks alot
Stefan
|
|
|
|
|
(Next time, please tick on the "Do not treat <'s as HTML tags" checkbox so that brackets show in your message.)
I've got a std::list<myclass*> mlist and want to erase several elements.
I thought mlist.erase(iter) deletes the element pointed to by iter.
As this is a pointer, only the pointer should be erased, but the destructor of myclass is also called... Is this the desired behaviour?
You should misinterpreting the behavior of your program, since mlist.erase(iter) will only erase the element and not destroy the object pointed to. Are you 100% sure the object is being destroyed, too?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks.
I've found the problem... I continued to use iter after erase (which was invalid) and didn't know that erase returns the next element...
Stefan
|
|
|
|
|
Hi,
I'm working on a web service programmed with ATL Server templates and classes. This web service is under testing in a Windows 2000 Server, IIS 5. It's running with high (isolated) application protection (so a new DLLHOST process appears when I make a request to my web service). I've noticed (using Process Explorer) that when an unhandled exception raises, Windows kills all my components in the DLLHOST process, but doesn't kill the DLLHOST process itself (of course, the user owned one, not the system DLLHOST). I just want to know why it behaves like that. Is it not supposed to kill the whole process that produces an unhandled exception?
Thanks,
Federico
|
|
|
|
|
Hi
I am implementing a data structure to insert ( 50000 - 100000 items )and retrive in First in First Out ( FIFO ) order.
Please suggest me which one is the fastest
QUEUE , STACK , LIST , MAP , MULTIMAP or any other
Thanks
Sandeep Naik
|
|
|
|
|
A deque (check the manual) is an ideal structure for this, as insertions and deletions at both ends of the sequence are very efficient (constant time, basically.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Does anyone know how to add a Status bar to a CDialogImpl derived class in an ATL COM EXE ?
Thanks in advance.
shakiru
|
|
|
|
|
My ATL web server is continously loaded and unload. The ISAPI extension fortunately not. Why this happen? I would like to have my web server always loaded because loading it requires many CPU cycles.
Could you please help me?
Best Regards,
Andrea
|
|
|
|
|
Say! If I create an ATL proj in .NET studio there is "References" item in project tree, what is that and how to use it? I mean are they like in C# and VB? If yes - how to use after I add a reference?
|
|
|
|
|
I am not sure of the real meaning of the question, however, if you are trying to use an ATL com server in a ATL project you can use "smart pointers".
Use #import directive in order to import the .tlb table then you can use these magic stuff.
If you have a IFoo intf and Foo coclass:
<br />
MYCOMLIB::IFoo m_foo;<br />
m_foo.CreateInstance (__uuidof (MYCOMLIB::Foo));<br />
m_foo->DoSomething ();<br />
Hope this helps.
Regards,
Andrea
|
|
|
|
|
Hi all,
I need to access a COM object from my ATL web service.
The COM object is propely registered in the target machine and can be freely
accessed from a VB client.
I am using smart pointer in order to create an instance.
When I invoke _com_ptr_t::CreateIntance I get as HRESULT "class not
registered".
What was wrong?
Please help me!!!
best Regards,
Andrea
|
|
|
|
|
Your client computer does not know anything about your COM object, mainly where it is located (this info is taken from the registry).
I have not done it for a long time, but I recall that the correct way to create a component remotely is by using CoCreateInstanceEx() . Look up the MSDN, it should have enough info.
|
|
|
|
|
Thanx a lot,
I found the problem, and this could be interesting for you, too.
My COM dll server was properly registered in a substituted volume (V that does not exists at Windows startup. For some reason this prevents the interface from being accessed in inetinfo processo. Placing my COM dll (ATL COM inproc server, by the way) in %windir%\system32 all works well.
Thanks a lot for your help.
Best Regards,
Andrea
|
|
|
|
|
Hi
I am trying to stream a map container to and from a file...
map<string , string > testMap;<br />
testMap.insert(pair<string , string>("one" , "This is string one"));<br />
testMap.insert(pair<string , string>("two" , "This is string two"));<br />
testMap.insert(pair<string , string>("three" , "This is string three"));<br />
<br />
copy(testMap.begin() , testMap.end() , ostream_iterator< pair<string , string> >(ofstream("C:\\myfile.txt") ));
It won't even compile! I've done similar with vectors without a problem....
vector<string> testVector;<br />
testVector.push_back("This is string one");<br />
testVector.push_back("This is string two");<br />
testVector.push_back("This is string three");<br />
<br />
copy(testVector.begin() , testVector.end() , ostream_iterator< string >(ofstream("C:\\myfile.txt") ));
This is really only a pre-amble to my next question...
If I got the above to work the file would look similar to...
<br />
<br />
oneThis is string onetwoThis is string twothreeThis is string three<br />
<br />
This is string oneThis is string twoThis is string three<br />
So reading in would be 'not easy' to say the least. Using an istream_iterator would not know where to break the string. There must be an easy way of streaming maps (or vector<string> ) to a file and reading them back in....
Somebody must have a snippet of code they can post....?
Cheers
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
I wouldn't start from here; I'd probably write something to load/save from/to XML, possibly using TinyXML or something similar.
Steve S
Developer for hire
|
|
|
|
|
Yes, there's a trick to it. The iostreams library breaks input on any whitespace (sounds a bit silly at first but in some situations it can be helpful). To get around this you need to save each element of the pair with spaces in it to a separate line. To make things easy for yourself, save the size of the container as well.
You can see the basic idea from the snippet below
#include <iostream>
#include <map>
#include <string>
#include <sstream>
using std::cout;
using std::endl;
typedef std::map<std::string,std::string> PairContainer;
void writeMap(std::ostream& os, PairContainer& v)
{
os << static_cast<unsigned int>(v.size()) << "\n";
PairContainer::const_iterator end(v.end());
for(PairContainer::iterator cur(v.begin()); cur != end; ++cur)
{
os << (*cur).first << "\n";
os << (*cur).second << "\n";
}
}
void readMap(std::istream& is, PairContainer& v)
{
unsigned int npairs = 0;
std::string tmp;
std::getline(is,tmp);
std::istringstream iss(tmp);
iss >> npairs;
for(unsigned int i = 0; i < npairs; i++)
{
std::pair<std::string,std::string> p;
std::getline(is,p.first);
std::getline(is,p.second);
v.insert(p);
}
}
I agree with the last poster that serializing data in this way is not a long term solution - it won't scale and can be hard to maintain and read, although I would recommend going with an XML api with a high level of abstraction if you head down that road, and even then it can be frustrating in some situations.
At times scripting languages like python and lua can be godsends for loading complex or heirarchical data, mainly because they are based on full parsers that do all the work for you, rather than SAX and DOM and many of the current XML API's which seem to only partially solve the problem.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks to both of you - the code sample is excellent and meets my reqs perfectly. Ultimately the data will come from an SQL server which can dump out the data in XML so we'll read in eventually from that.
Thanks again.
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Hello,
how to import dll created with MFC into WTL project? The problem is with COleDateTime class which require ATLComTime.h to be included. But ATLComTime.h defines some types like CString which are also part of WTL library. It causes ambiguity problems.
How to solve this problem?
|
|
|
|
|
|
Hello everyone,
I want to create an ATL Dll and want to
Have a good article about it?
Any Ideas or links?
Best Wishes,
Thanks.
|
|
|
|
|
|
I have an ATL Server application (combined DLL), with server mappings set to all the extentions available. How do I, for example, handle requests for Image.jpg? I need to build a custom security system, and this is a very important aspect. So how to I catch all the extentions and call a specific function on their request?
|
|
|
|
|
During the work i have provided the task for Creating the
#1 evaluation version Component or ActiveX Dll
#2 Developer Version DLL
#3 Runtime DLL.
i have almost sorted out First task By producing a Modeless Atl dialog box .
but i still can't understand what about Developer DLl and Runtime Dll ,as i was told that you have to stop runtime dll to connect to IDEso that only application can use that.
can any body provide me any good pointer towards it.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I have create a atl propertypage, and use OleCreatePropertyFrame to create a framework for it. When I open this propertypage, press F1 on it, no help message is appears, why? And how can I let this function work, who can help me?
I have use Spy to monitor the message, the framework has received this WM_HELP message. If I add one EDIT in the propertypage and set the focus to it when open this propertypage, press F1 can get the help message, why this occurs?
Thanks very much.
I had written n bugs today.
|
|
|
|
|
I know HOOK can resolves this issue, but is there any other way to resolves this?
|
|
|
|