Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » simple bug? passing String::GetVoid() to StringStream
simple bug? passing String::GetVoid() to StringStream [message #49770] Sat, 28 April 2018 12:06 Go to next message
luoganda is currently offline  luoganda
Messages: 193
Registered: November 2016
Experienced Member
is this a bug? if is, this is for any Stream based class
If fname does not exist(down code), LoadFile ret String::GetVoid(), then pass this to StringStream constructor,
but ss.IsError() and ss.IsOpen doesn't react on it(doesn't take into consideration that String::GetVoid() was passed.
StringStream ss(LoadFile(fname));if(ss.IsError()){errline("Can't load file %s",~fname);return false;}

Of course, this can easily be solved by checking if FileExists before passing it to StringStream
Re: simple bug? passing String::GetVoid() to StringStream [message #49772 is a reply to message #49770] Sun, 29 April 2018 19:52 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
luoganda wrote on Sat, 28 April 2018 12:06
is this a bug? if is, this is for any Stream based class
If fname does not exist(down code), LoadFile ret String::GetVoid(), then pass this to StringStream constructor,
but ss.IsError() and ss.IsOpen doesn't react on it(doesn't take into consideration that String::GetVoid() was passed.
StringStream ss(LoadFile(fname));if(ss.IsError()){errline("Can't load file %s",~fname);return false;}

Of course, this can easily be solved by checking if FileExists before passing it to StringStream


Well, it is not a bug, although your reasoning has a logic in it.

Anyway, for all purposes GetVoid is considered equal to empty string, with the only difference being that you can test for IsVoid. So it was meant to be used as this:

String data = LoadFile(fname);
if(data.IsVoid()) {
   errline("...");
   return false;
}
StringString ss(data);


Previous Topic: [BUG #1855, + PATCH] FormatIntAlpha oes not always give the right results.
Next Topic: Returning Tuple that contains Vector is not possible
Goto Forum:
  


Current Time: Fri Mar 29 16:41:07 CET 2024

Total time taken to generate the page: 0.01596 seconds