summaryrefslogtreecommitdiff
path: root/src/game/PropertyTool.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-14 17:52:14 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-14 17:52:14 (GMT)
commit079b51a26c90718c7cd67033a570a0a45b2f38f6 (patch)
tree128ea8056ff5e653d682344b3184e17d9ca46b18 /src/game/PropertyTool.cpp
parentfcc17ee6522579eb355452a3b99fa902b74cc90a (diff)
downloadpowder-079b51a26c90718c7cd67033a570a0a45b2f38f6.zip
powder-079b51a26c90718c7cd67033a570a0a45b2f38f6.tar.gz
Stricter formatting for Property tool, attempts to address #109
Diffstat (limited to 'src/game/PropertyTool.cpp')
-rw-r--r--src/game/PropertyTool.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/game/PropertyTool.cpp b/src/game/PropertyTool.cpp
index bfb2609..67c276a 100644
--- a/src/game/PropertyTool.cpp
+++ b/src/game/PropertyTool.cpp
@@ -94,14 +94,16 @@ void PropertyWindow::SetProperty()
if(value.length() > 2 && value.substr(0, 2) == "0x")
{
//0xC0FFEE
- stringstream buffer;
+ std::stringstream buffer;
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(2);
buffer >> tempInt;
}
else if(value.length() > 1 && value[0] == '#')
{
//#C0FFEE
- stringstream buffer;
+ std::stringstream buffer;
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(1);
buffer >> tempInt;
}
@@ -119,12 +121,16 @@ void PropertyWindow::SetProperty()
}
else
{
- stringstream(value) >> tempInt;
+ std::stringstream buffer(value);
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
+ buffer >> tempInt;
}
}
else
{
- stringstream(value) >> tempInt;
+ std::stringstream buffer(value);
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
+ buffer >> tempInt;
}
}
#ifdef DEBUG
@@ -136,20 +142,24 @@ void PropertyWindow::SetProperty()
if(value.length() > 2 && value.substr(0, 2) == "0x")
{
//0xC0FFEE
- stringstream buffer;
+ std::stringstream buffer;
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(2);
buffer >> tempUInt;
}
else if(value.length() > 1 && value[0] == '#')
{
//#C0FFEE
- stringstream buffer;
+ std::stringstream buffer;
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(1);
buffer >> tempUInt;
}
else
{
- stringstream(value) >> tempUInt;
+ std::stringstream buffer(value);
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
+ buffer >> tempUInt;
}
#ifdef DEBUG
std::cout << "Got uint value " << tempUInt << std::endl;
@@ -157,11 +167,15 @@ void PropertyWindow::SetProperty()
propValue = &tempUInt;
break;
case StructProperty::Float:
- istringstream(value) >> tempFloat;
+ {
+ std::stringstream buffer(value);
+ buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
+ buffer >> tempFloat;
#ifdef DEBUG
std::cout << "Got float value " << tempFloat << std::endl;
#endif
propValue = &tempFloat;
+ }
break;
default:
new ErrorMessage("Could not set property", "Invalid property");