Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: Best text accumulator

Text gets accumulates piecemeal before being sent to client.

Now we use own class that allocates memory for each piece as char massive. (Anyway, works like char[][] + std::list<char*>).

Then we build the whole string, convert it into std::sting and then create boost::asio::streambuf using it. That's slow enough, I assume. Correct me if I'm wrong.

I know, in many cases simple FILE type from stdio.h is used. How does it works? Allocates memory at every write into it. So, is it faster and is there any way to read into boost::asio::streambuf from FILE?

ADD: Hm. I've forgot one big thing :). The compilation of dlls and main application is made under few compilers, so it should have no stl stuff inside it ... Because it usually cause a lot of problems, while executing dlls.

like image 251
Ben Usman Avatar asked Jan 20 '26 18:01

Ben Usman


1 Answers

I have no idea how efficient it is, but I usually use a ostringstream for that sort of thing

like image 103
psm321 Avatar answered Jan 23 '26 14:01

psm321



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!