From a5bb534ab656e9eaab163c22df0325d3baa3ce40 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 9 Nov 2010 14:36:18 +0200 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B0=20=D1=81=D0=BF=D0=B5=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7?= =?utf8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?utf8?q?=D0=B9=20str2x=20=D0=B4=D0=BB=D1=8F=20long=20=D0=B8=20unsigned?= =?utf8?q?=20long=20(=D0=BD=D0=B0=20=20=20=20=20=20=20=20=2064-=D0=B1?= =?utf8?q?=D0=B8=D1=82=D0=BD=D1=8B=D1=85=20=D1=81=D0=B8=D1=81=D1=82=D0=B5?= =?utf8?q?=D0=BC=D0=B0=D1=85=20long=20!=3D=20int)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- stglibs/common.lib/common.cpp | 20 ++++++++++++++++++++ stglibs/common.lib/common.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index a5899dd2..eb39da6a 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -728,6 +728,26 @@ int str2x(const std::string & str, unsigned & x) { x = strtoul(str.c_str(), NULL, 10); +if (errno == ERANGE) + return -1; + +return 0; +} +//--------------------------------------------------------------------------- +int str2x(const std::string & str, long & x) +{ +x = strtol(str.c_str(), NULL, 10); + +if (errno == ERANGE) + return -1; + +return 0; +} +//--------------------------------------------------------------------------- +int str2x(const std::string & str, unsigned long & x) +{ +x = strtoul(str.c_str(), NULL, 10); + if (errno == ERANGE) return -1; diff --git a/stglibs/common.lib/common.h b/stglibs/common.lib/common.h index 971a2e72..904c6e47 100644 --- a/stglibs/common.lib/common.h +++ b/stglibs/common.lib/common.h @@ -215,6 +215,8 @@ const std::string & unsigned2str(varT x, std::string & s) //----------------------------------------------------------------------------- int str2x(const std::string & str, int & x); int str2x(const std::string & str, unsigned & x); +int str2x(const std::string & str, long & x); +int str2x(const std::string & str, unsigned long & x); int str2x(const std::string & str, long long & x); int str2x(const std::string & str, unsigned long long & x); //----------------------------------------------------------------------------- -- 2.44.2