🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

ostringstream with AS

Started by
-1 comments, last by Maddi 18 years ago
Hi Witchlord, on to my next experiment :) I want to have an ostringstream like class for nice string formatting. Therefor I took a look at the OutStream from Sam Cragg. Because he only supports cout / cin, I started to convert the whole thing to ostringstream. First of all, I converted the Register functions to be static so I can register just the class without needing to create an object first. The whole process was an addition of access violations and wrong pointers, at one point, the exectution ended in areas never seen befor :) But at the end I now have a quiet robust implementation. Because its so much, I did not wan't to post it here, but rather uploaded a .rar to my server ( stream.rar ). But :) The problem arises when trying to do something like this:

string s = ostringstream() << 100;
Befor the string assignment function gets called ( see Stream.cpp Line 102 & Line 46 ) the ostringstream / CTest object gets released. Directly after the release(), the ostreamToString function gets called, with a now invalid pointer. If i however use "format" instead of "ostringstream" ( both classes registered by me, just the << operators are different by @ and @+ ) the calling of the release and ostreamToString happen in the correct order. Is the bug on my side or yours ? Im suspecting my changing from RegisterObjectBehaviour to RegisterGlobalBehaviour in Line 67 in Stream.h to be the root of the problem, but I couldn't see why RegisterObjectBehaviour should be used there since the operators are totally global. As thankfull as always, Maddi

This topic is closed to new replies.

Advertisement