Raised This Month: $51 Target: $400
 12% 

CS2 Metamod Plugin std::stringstream


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Toxa
New Member
Join Date: Jan 2024
Old 01-06-2024 , 07:42   CS2 Metamod Plugin std::stringstream
Reply With Quote #1

Hi there!

Can someone please tell me why is stringstream not working with int's inside the metamod plugin?
E.g.:
Code:
//this works
std::stringstream ss;
ss << "123";
//ss.bad() == false here
Code:
//this not works
std::stringstream ss;
ss << 123;
//ss.bad() == true here
Seems like all streams (std::cout, std::clog, std::cerr) not working with any numbers (int/double). If cout, clog, cerr is objects and engine or metamod can replace e.g. rdbuf for them so why even stringstream not working?

Last edited by Toxa; 01-06-2024 at 08:00. Reason: Update info
Toxa is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-06-2024 , 08:00   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #2

There are many c++ examples, what use also string and stringstream.

Also, try this:
Create variable int with value.
Add that in your stringstream ss <<
__________________
Do not Private Message @me
Bacardi is offline
Toxa
New Member
Join Date: Jan 2024
Old 01-06-2024 , 08:19   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
There are many c++ examples, what use also string and stringstream.

Also, try this:
Create variable int with value.
Add that in your stringstream ss <<
Not works as well.
Code:
std::stringstream ss;
int a = 777;
ss << a;
//ss.bad() == true here, ss.str() is empty
Im using s1_stub_mm example from latest mm sources and latest hl2sdk-cs2. This code was launched inside the Load function.
Toxa is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-06-2024 , 09:15   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #4

I would start looking <string> and format.
https://en.cppreference.com/w/cpp/utility/format/format

Forget stringstream :S


Edit
Sprintf https://forums.alliedmods.net/showpo...65&postcount=5
__________________
Do not Private Message @me

Last edited by Bacardi; 01-06-2024 at 09:28.
Bacardi is offline
Toxa
New Member
Join Date: Jan 2024
Old 01-06-2024 , 09:42   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
I would start looking <string> and format.
https://en.cppreference.com/w/cpp/utility/format/format

Forget stringstream :S


Edit
Sprintf https://forums.alliedmods.net/showpo...65&postcount=5
Thanks, I know about the formatting functions. But stringstream is used inside some libraries that I want to use. And they break when loading from mm.

I will try to investigate more
Toxa is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-06-2024 , 14:34   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #6

What if you do:

ss << 123 << " ";
__________________
Do not Private Message @me
Bacardi is offline
Toxa
New Member
Join Date: Jan 2024
Old 01-07-2024 , 01:56   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
What if you do:

ss << 123 << " ";
Same. After ss << 123 stream state is bad.
Toxa is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-07-2024 , 05:28   Re: CS2 Metamod Plugin std::stringstream
Reply With Quote #8

If this has something to do iostream badbit...

What if you use:
ss.clear();

...after you declare stringstream variable?

But something is off, can't say what.
Also, what require stringstream ?

If above thing not help.
Try use string and format.
Then finally, add that string into stringstream
__________________
Do not Private Message @me

Last edited by Bacardi; 01-07-2024 at 05:30.
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode