VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-06-24 14:14:34 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-06-24 15:33:16 +0200
commit9913af3a8ed61333cafd0e611f214f7c86652423 (patch)
treebae9cbe7b95cb56df9d210cf32b44a0c15574ce8 /src/Platform
parentf927ce9b58b137846bb78a47f5a83f7261eac9ff (diff)
downloadVeraCrypt-9913af3a8ed61333cafd0e611f214f7c86652423.tar.gz
VeraCrypt-9913af3a8ed61333cafd0e611f214f7c86652423.zip
Linux/MacOSX: first dynamic mode implementation
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/StringConverter.cpp48
-rw-r--r--src/Platform/StringConverter.h8
2 files changed, 54 insertions, 2 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)
diff --git a/src/Platform/StringConverter.h b/src/Platform/StringConverter.h
index 9a9e098f..7b68ff4d 100644
--- a/src/Platform/StringConverter.h
+++ b/src/Platform/StringConverter.h
@@ -32,9 +32,13 @@ namespace VeraCrypt
static wstring ToExceptionString (const exception &ex);
static string ToLower (const string &str);
static uint32 ToUInt32 (const string &str);
- static uint32 ToUInt32 (const wstring &str);
+ static uint32 ToUInt32 (const wstring &str);
+ static int32 ToInt32 (const string &str);
+ static int32 ToInt32 (const wstring &str);
static uint64 ToUInt64 (const string &str);
- static uint64 ToUInt64 (const wstring &str);
+ static uint64 ToUInt64 (const wstring &str);
+ static int64 ToInt64 (const string &str);
+ static int64 ToInt64 (const wstring &str);
static string ToSingle (double number) { return ToSingle (FromNumber (number)); }
static string ToSingle (int32 number) { return ToSingle (FromNumber (number)); }
static string ToSingle (uint32 number) { return ToSingle (FromNumber (number)); }