VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/StringConverter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/StringConverter.cpp')
-rw-r--r--src/Platform/StringConverter.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Platform/StringConverter.cpp b/src/Platform/StringConverter.cpp
index cbd89e1f..c7ecc143 100644
--- a/src/Platform/StringConverter.cpp
+++ b/src/Platform/StringConverter.cpp
@@ -260,6 +260,30 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
return n;
+ }
+
+ int32 StringConverter::ToInt32 (const string &str)
+ {
+ int32 n;
+ stringstream ss (str);
+
+ ss >> n;
+ if (ss.fail() || n == 0x7fffFFFF || n == -0x7fffFFFF)
+ throw ParameterIncorrect (SRC_POS);
+
+ return n;
+ }
+
+ int32 StringConverter::ToInt32 (const wstring &str)
+ {
+ int32 n;
+ wstringstream ss (str);
+
+ ss >> n;
+ if (ss.fail() || n == 0x7fffFFFF || n == -0x7fffFFFF)
+ throw ParameterIncorrect (SRC_POS);
+
+ return n;
}
uint64 StringConverter::ToUInt64 (const string &str)
@@ -284,6 +308,30 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
return n;
+ }
+
+ int64 StringConverter::ToInt64 (const string &str)
+ {
+ int64 n;
+ stringstream ss (str);
+
+ ss >> n;
+ if (ss.fail() || n == 0x7fffFFFFffffFFFFLL || n == -0x7fffFFFFffffFFFFLL)
+ throw ParameterIncorrect (SRC_POS);
+
+ return n;
+ }
+
+ int64 StringConverter::ToInt64 (const wstring &str)
+ {
+ int64 n;
+ wstringstream ss (str);
+
+ ss >> n;
+ if (ss.fail() || n == 0x7fffFFFFffffFFFFLL || n == -0x7fffFFFFffffFFFFLL)
+ throw ParameterIncorrect (SRC_POS);
+
+ return n;
}
string StringConverter::ToUpper (const string &str)