diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H index 3e8b2a3b057be4a7171ed5c1dd1193e356387d27..13a70e475e68730fb459dec1e49ac70aed879787 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,6 +58,14 @@ static const doubleScalar doubleScalarSMALL = 1.0e-15; static const doubleScalar doubleScalarVSMALL = 1.0e-300; static const doubleScalar doubleScalarROOTVSMALL = 1.0e-150; +//- Read whole of buf as a scalar. Return true if succesful. +inline bool readScalar(const char* buf, doubleScalar& s) +{ + char* endPtr; + s = strtod(buf, &endPtr); + + return (*endPtr == '\0'); +} #define Scalar doubleScalar #define ScalarVGREAT doubleScalarVGREAT diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H index 3386d3630e949b0afc35e0f25ff82916c18b7f06..5401bc79a6cd77035b79654f7d25ed38b7c6f3b3 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,6 +58,14 @@ static const floatScalar floatScalarSMALL = 1.0e-6; static const floatScalar floatScalarVSMALL = 1.0e-37; static const floatScalar floatScalarROOTVSMALL = 1.0e-18; +//- Read whole of buf as a scalar. Return true if succesful. +inline bool readScalar(const char* buf, floatScalar& s) +{ + char* endPtr; + s = strtof(buf, &endPtr); + + return (*endPtr == '\0'); +} #define Scalar floatScalar #define ScalarVGREAT floatScalarVGREAT diff --git a/src/OpenFOAM/primitives/ints/int/int.H b/src/OpenFOAM/primitives/ints/int/int.H index c734f3e583032a0dbc9927e3f239bc069c4fdd24..9f3a34c978d696b89fbd1626c89bd7fb0fcd6a78 100644 --- a/src/OpenFOAM/primitives/ints/int/int.H +++ b/src/OpenFOAM/primitives/ints/int/int.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,6 +54,7 @@ word name(const int); // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // int readInt(Istream&); +bool readInt(const char*, int&); Istream& operator>>(Istream&, int&); Ostream& operator<<(Ostream&, const int); diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C index fb9ff8b0e3165652bc8a78895c671f0eb6de0c3f..bd02519897de6e250c51ea77175392c5ddff3e62 100644 --- a/src/OpenFOAM/primitives/ints/int/intIO.C +++ b/src/OpenFOAM/primitives/ints/int/intIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,6 +88,15 @@ int Foam::readInt(Istream& is) } +bool Foam::readInt(const char* buf, int& s) +{ + char *endptr = NULL; + long l = strtol(buf, &endptr, 10); + s = int(l); + return (*endptr == 0); +} + + Foam::Ostream& Foam::operator<<(Ostream& os, const int i) { os.write(label(i)); diff --git a/src/OpenFOAM/primitives/ints/label/label.H b/src/OpenFOAM/primitives/ints/label/label.H index 17911aed1f795078e80b118dce5f5fa761b34b39..0e97dc7c576c950da96b78d4e00f9a53bba78a44 100644 --- a/src/OpenFOAM/primitives/ints/label/label.H +++ b/src/OpenFOAM/primitives/ints/label/label.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,6 +72,11 @@ namespace Foam return readInt(is); } + inline bool readLabel(const char* buf, label& s) + { + return readInt(buf, s); + } + } // End namespace Foam @@ -96,6 +101,11 @@ namespace Foam return readLong(is); } + inline bool readLabel(const char* buf, label& s) + { + return readLong(buf, s); + } + } // End namespace Foam @@ -122,6 +132,11 @@ namespace Foam return readLongLong(is); } + inline bool readLabel(const char* buf, label& s) + { + return readLongLong(buf, s); + } + } // End namespace Foam #endif diff --git a/src/OpenFOAM/primitives/ints/long/long.H b/src/OpenFOAM/primitives/ints/long/long.H index 5fbf2fa95be20354a16e9d932cda49c71e806d45..6e09fc2046be520ebef6851572d13fff47bb8678 100644 --- a/src/OpenFOAM/primitives/ints/long/long.H +++ b/src/OpenFOAM/primitives/ints/long/long.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,6 +53,7 @@ word name(const long); // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // long readLong(Istream&); +bool readLong(const char*, long&); Istream& operator>>(Istream&, long&); Ostream& operator<<(Ostream&, const long); diff --git a/src/OpenFOAM/primitives/ints/long/longIO.C b/src/OpenFOAM/primitives/ints/long/longIO.C index 3a9d8e3fe5303f1f78addb32807ad4e896dc1cbd..7e352bd9db3d06196c230a7badd25ace281a3c7c 100644 --- a/src/OpenFOAM/primitives/ints/long/longIO.C +++ b/src/OpenFOAM/primitives/ints/long/longIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,6 +85,13 @@ long Foam::readLong(Istream& is) return val; } +bool Foam::readLong(const char* buf, long& s) +{ + char *endptr = NULL; + s = strtol(buf, &endptr, 10); + return (*endptr == 0); +} + Foam::Ostream& Foam::operator<<(Ostream& os, const long l) { diff --git a/src/OpenFOAM/primitives/ints/longLong/longLong.H b/src/OpenFOAM/primitives/ints/longLong/longLong.H index 00d34b5d9241e16bb22ce1a8493cbd6f0f34dc44..e1595e8462d80d6a9e7d09caaa0d19c3c012575d 100644 --- a/src/OpenFOAM/primitives/ints/longLong/longLong.H +++ b/src/OpenFOAM/primitives/ints/longLong/longLong.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,6 +53,7 @@ word name(long long); // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // long long readLongLong(Istream&); +bool readLongLong(const char*, long long&); Istream& operator>>(Istream&, long long&); Ostream& operator<<(Ostream&, const long long); diff --git a/src/OpenFOAM/primitives/ints/longLong/longLongIO.C b/src/OpenFOAM/primitives/ints/longLong/longLongIO.C index 146bf011ea07fddc3bf1e1193c3bd0906dded9cf..384fe1bf1f056f584a1b4d545edb10b08bc3c262 100644 --- a/src/OpenFOAM/primitives/ints/longLong/longLongIO.C +++ b/src/OpenFOAM/primitives/ints/longLong/longLongIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,6 +87,14 @@ long long Foam::readLongLong(Istream& is) } +bool Foam::readLongLong(const char* buf, long long& s) +{ + char *endptr = NULL; + s = strtoll(buf, &endptr, 10); + return (*endptr == 0); +} + + Foam::Ostream& Foam::operator<<(Ostream& os, const long long l) { long long val = l;