From 9913af3a8ed61333cafd0e611f214f7c86652423 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 24 Jun 2015 14:14:34 +0200 Subject: Linux/MacOSX: first dynamic mode implementation --- src/Platform/StringConverter.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/Platform/StringConverter.cpp') 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 @@ -259,6 +259,30 @@ namespace VeraCrypt if (ss.fail() || n == 0xffffFFFFU) 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; } @@ -283,6 +307,30 @@ namespace VeraCrypt if (ss.fail() || n == 0xffffFFFFffffFFFFULL) 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; } -- cgit v1.2.3