FreeCAD

Форк
0
/
Quantity.cpp 
556 строк · 18.9 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2013 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
#ifdef FC_OS_WIN32
26
#define _USE_MATH_DEFINES
27
#endif  // FC_OS_WIN32
28
#include <array>
29
#endif
30

31
#include <Base/Tools.h>
32
#include "Quantity.h"
33
#include "Exception.h"
34
#include "UnitsApi.h"
35
#include <boost/math/special_functions/fpclassify.hpp>
36

37
/** \defgroup Units Units system
38
    \ingroup BASE
39
    \brief The quantities and units system enables FreeCAD to work transparently with many different
40
   units
41
*/
42

43
// suppress annoying warnings from generated source files
44
#ifdef _MSC_VER
45
#pragma warning(disable : 4003)
46
#pragma warning(disable : 4018)
47
#pragma warning(disable : 4065)
48
#pragma warning(disable : 4273)
49
#pragma warning(disable : 4335)  // disable MAC file format warning on VC
50
#endif
51

52
using namespace Base;
53

54
// ====== Static attributes =========================
55
// NOLINTNEXTLINE
56
int QuantityFormat::defaultDenominator = 8;  // for 1/8"
57

58

59
QuantityFormat::QuantityFormat()
60
    : option(OmitGroupSeparator | RejectGroupSeparator)
61
    , format(Fixed)
62
    , precision(UnitsApi::getDecimals())
63
    , denominator(defaultDenominator)
64
{}
65

66
QuantityFormat::QuantityFormat(QuantityFormat::NumberFormat format, int decimals)
67
    : option(OmitGroupSeparator | RejectGroupSeparator)
68
    , format(format)
69
    , precision(decimals < 0 ? UnitsApi::getDecimals() : decimals)
70
    , denominator(defaultDenominator)
71
{}
72

73
// ----------------------------------------------------------------------------
74

75
Quantity::Quantity()
76
    : myValue {0.0}
77
{}
78

79
Quantity::Quantity(double value, const Unit& unit)
80
    : myValue {value}
81
    , myUnit {unit}
82
{}
83

84
Quantity::Quantity(double value, const QString& unit)
85
    : myValue {0.0}
86
{
87
    if (unit.isEmpty()) {
88
        this->myValue = value;
89
        this->myUnit = Unit();
90
        return;
91
    }
92

93
    try {
94
        auto tmpQty = parse(unit);
95
        this->myUnit = tmpQty.getUnit();
96
        this->myValue = value * tmpQty.getValue();
97
    }
98
    catch (const Base::ParserError&) {
99
        this->myValue = 0.0;
100
        this->myUnit = Unit();
101
    }
102
}
103

104
double Quantity::getValueAs(const Quantity& other) const
105
{
106
    return myValue / other.getValue();
107
}
108

109
bool Quantity::operator==(const Quantity& that) const
110
{
111
    return (this->myValue == that.myValue) && (this->myUnit == that.myUnit);
112
}
113

114
bool Quantity::operator!=(const Quantity& that) const
115
{
116
    return !(*this == that);
117
}
118

119
bool Quantity::operator<(const Quantity& that) const
120
{
121
    if (this->myUnit != that.myUnit) {
122
        throw Base::UnitsMismatchError(
123
            "Quantity::operator <(): quantities need to have same unit to compare");
124
    }
125

126
    return (this->myValue < that.myValue);
127
}
128

129
bool Quantity::operator>(const Quantity& that) const
130
{
131
    if (this->myUnit != that.myUnit) {
132
        throw Base::UnitsMismatchError(
133
            "Quantity::operator >(): quantities need to have same unit to compare");
134
    }
135

136
    return (this->myValue > that.myValue);
137
}
138

139
bool Quantity::operator<=(const Quantity& that) const
140
{
141
    if (this->myUnit != that.myUnit) {
142
        throw Base::UnitsMismatchError(
143
            "Quantity::operator <=(): quantities need to have same unit to compare");
144
    }
145

146
    return (this->myValue <= that.myValue);
147
}
148

149
bool Quantity::operator>=(const Quantity& that) const
150
{
151
    if (this->myUnit != that.myUnit) {
152
        throw Base::UnitsMismatchError(
153
            "Quantity::operator >=(): quantities need to have same unit to compare");
154
    }
155

156
    return (this->myValue >= that.myValue);
157
}
158

159
Quantity Quantity::operator*(const Quantity& other) const
160
{
161
    return Quantity(this->myValue * other.myValue, this->myUnit * other.myUnit);
162
}
163

164
Quantity Quantity::operator*(double factor) const
165
{
166
    return Quantity(this->myValue * factor, this->myUnit);
167
}
168

169
Quantity Quantity::operator/(const Quantity& other) const
170
{
171
    return Quantity(this->myValue / other.myValue, this->myUnit / other.myUnit);
172
}
173

174
Quantity Quantity::operator/(double factor) const
175
{
176
    return Quantity(this->myValue / factor, this->myUnit);
177
}
178

179
Quantity Quantity::pow(const Quantity& other) const
180
{
181
    if (!other.myUnit.isEmpty()) {
182
        throw Base::UnitsMismatchError("Quantity::pow(): exponent must not have a unit");
183
    }
184

185
    return Quantity(std::pow(this->myValue, other.myValue),
186
                    this->myUnit.pow(static_cast<signed char>(other.myValue)));
187
}
188

189
Quantity Quantity::pow(double exp) const
190
{
191
    return Quantity(std::pow(this->myValue, exp), this->myUnit.pow(exp));
192
}
193

194
Quantity Quantity::operator+(const Quantity& other) const
195
{
196
    if (this->myUnit != other.myUnit) {
197
        throw Base::UnitsMismatchError("Quantity::operator +(): Unit mismatch in plus operation");
198
    }
199

200
    return Quantity(this->myValue + other.myValue, this->myUnit);
201
}
202

203
Quantity& Quantity::operator+=(const Quantity& other)
204
{
205
    if (this->myUnit != other.myUnit) {
206
        throw Base::UnitsMismatchError("Quantity::operator +=(): Unit mismatch in plus operation");
207
    }
208

209
    myValue += other.myValue;
210

211
    return *this;
212
}
213

214
Quantity Quantity::operator-(const Quantity& other) const
215
{
216
    if (this->myUnit != other.myUnit) {
217
        throw Base::UnitsMismatchError("Quantity::operator -(): Unit mismatch in minus operation");
218
    }
219

220
    return Quantity(this->myValue - other.myValue, this->myUnit);
221
}
222

223
Quantity& Quantity::operator-=(const Quantity& other)
224
{
225
    if (this->myUnit != other.myUnit) {
226
        throw Base::UnitsMismatchError("Quantity::operator -=(): Unit mismatch in minus operation");
227
    }
228

229
    myValue -= other.myValue;
230

231
    return *this;
232
}
233

234
Quantity Quantity::operator-() const
235
{
236
    return Quantity(-(this->myValue), this->myUnit);
237
}
238

239
QString Quantity::getUserString(double& factor, QString& unitString) const
240
{
241
    return Base::UnitsApi::schemaTranslate(*this, factor, unitString);
242
}
243

244
QString Quantity::getUserString(UnitsSchema* schema, double& factor, QString& unitString) const
245
{
246
    return schema->schemaTranslate(*this, factor, unitString);
247
}
248

249
QString Quantity::getSafeUserString() const
250
{
251
    auto retString = getUserString();
252
    if (Q_LIKELY(this->myValue != 0)) {
253
        auto feedbackQty = parse(retString);
254
        auto feedbackVal = feedbackQty.getValue();
255
        if (feedbackVal == 0) {
256
            retString = QStringLiteral("%1 %2").arg(this->myValue).arg(this->getUnit().getString());
257
        }
258
    }
259
    retString =
260
        QString::fromStdString(Base::Tools::escapeQuotesFromString(retString.toStdString()));
261
    return retString;
262
}
263

264
/// true if it has a number without a unit
265
bool Quantity::isDimensionless() const
266
{
267
    return isValid() && myUnit.isEmpty();
268
}
269

270
/// true if it has a specific unit or no dimension.
271
bool Quantity::isDimensionlessOrUnit(const Unit& unit) const
272
{
273
    return isDimensionless() || myUnit == unit;
274
}
275

276
// true if it has a number and a valid unit
277
bool Quantity::isQuantity() const
278
{
279
    return isValid() && !myUnit.isEmpty();
280
}
281

282
// true if it has a number with or without a unit
283
bool Quantity::isValid() const
284
{
285
    return !boost::math::isnan(myValue);
286
}
287

288
void Quantity::setInvalid()
289
{
290
    myValue = std::numeric_limits<double>::quiet_NaN();
291
}
292

293
// === Predefined types =====================================================
294

295
const Quantity Quantity::NanoMetre(1.0e-6, Unit(1));
296
const Quantity Quantity::MicroMetre(1.0e-3, Unit(1));
297
const Quantity Quantity::MilliMetre(1.0, Unit(1));
298
const Quantity Quantity::CentiMetre(10.0, Unit(1));
299
const Quantity Quantity::DeciMetre(100.0, Unit(1));
300
const Quantity Quantity::Metre(1.0e3, Unit(1));
301
const Quantity Quantity::KiloMetre(1.0e6, Unit(1));
302

303
const Quantity Quantity::MilliLiter(1000.0, Unit(3));
304
const Quantity Quantity::Liter(1.0e6, Unit(3));
305

306
const Quantity Quantity::Hertz(1.0, Unit(0, 0, -1));
307
const Quantity Quantity::KiloHertz(1.0e3, Unit(0, 0, -1));
308
const Quantity Quantity::MegaHertz(1.0e6, Unit(0, 0, -1));
309
const Quantity Quantity::GigaHertz(1.0e9, Unit(0, 0, -1));
310
const Quantity Quantity::TeraHertz(1.0e12, Unit(0, 0, -1));
311

312
const Quantity Quantity::MicroGram(1.0e-9, Unit(0, 1));
313
const Quantity Quantity::MilliGram(1.0e-6, Unit(0, 1));
314
const Quantity Quantity::Gram(1.0e-3, Unit(0, 1));
315
const Quantity Quantity::KiloGram(1.0, Unit(0, 1));
316
const Quantity Quantity::Ton(1.0e3, Unit(0, 1));
317

318
const Quantity Quantity::Second(1.0, Unit(0, 0, 1));
319
const Quantity Quantity::Minute(60.0, Unit(0, 0, 1));
320
const Quantity Quantity::Hour(3600.0, Unit(0, 0, 1));
321

322
const Quantity Quantity::Ampere(1.0, Unit(0, 0, 0, 1));
323
const Quantity Quantity::MilliAmpere(0.001, Unit(0, 0, 0, 1));
324
const Quantity Quantity::KiloAmpere(1000.0, Unit(0, 0, 0, 1));
325
const Quantity Quantity::MegaAmpere(1.0e6, Unit(0, 0, 0, 1));
326

327
const Quantity Quantity::Kelvin(1.0, Unit(0, 0, 0, 0, 1));
328
const Quantity Quantity::MilliKelvin(0.001, Unit(0, 0, 0, 0, 1));
329
const Quantity Quantity::MicroKelvin(0.000001, Unit(0, 0, 0, 0, 1));
330

331
const Quantity Quantity::MilliMole(0.001, Unit(0, 0, 0, 0, 0, 1));
332
const Quantity Quantity::Mole(1.0, Unit(0, 0, 0, 0, 0, 1));
333

334
const Quantity Quantity::Candela(1.0, Unit(0, 0, 0, 0, 0, 0, 1));
335

336
const Quantity Quantity::Inch(25.4, Unit(1));
337
const Quantity Quantity::Foot(304.8, Unit(1));
338
const Quantity Quantity::Thou(0.0254, Unit(1));
339
const Quantity Quantity::Yard(914.4, Unit(1));
340
const Quantity Quantity::Mile(1609344.0, Unit(1));
341

342
const Quantity Quantity::MilePerHour(447.04, Unit(1, 0, -1));
343
const Quantity Quantity::SquareFoot(92903.04, Unit(2));
344
const Quantity Quantity::CubicFoot(28316846.592, Unit(3));
345

346
const Quantity Quantity::Pound(0.45359237, Unit(0, 1));
347
const Quantity Quantity::Ounce(0.0283495231, Unit(0, 1));
348
const Quantity Quantity::Stone(6.35029318, Unit(0, 1));
349
const Quantity Quantity::Hundredweights(50.80234544, Unit(0, 1));
350

351
const Quantity Quantity::PoundForce(4448.22, Unit(1, 1, -2));  // lbf are ~= 4.44822 Newton
352

353
const Quantity Quantity::Newton(1000.0, Unit(1, 1, -2));  // Newton (kg*m/s^2)
354
const Quantity Quantity::MilliNewton(1.0, Unit(1, 1, -2));
355
const Quantity Quantity::KiloNewton(1e+6, Unit(1, 1, -2));
356
const Quantity Quantity::MegaNewton(1e+9, Unit(1, 1, -2));
357

358
const Quantity Quantity::NewtonPerMeter(1.00, Unit(0, 1, -2));  // Newton per meter (N/m or kg/s^2)
359
const Quantity Quantity::MilliNewtonPerMeter(1e-3, Unit(0, 1, -2));
360
const Quantity Quantity::KiloNewtonPerMeter(1e3, Unit(0, 1, -2));
361
const Quantity Quantity::MegaNewtonPerMeter(1e6, Unit(0, 1, -2));
362

363
const Quantity Quantity::Pascal(0.001, Unit(-1, 1, -2));  // Pascal (kg/m/s^2 or N/m^2)
364
const Quantity Quantity::KiloPascal(1.00, Unit(-1, 1, -2));
365
const Quantity Quantity::MegaPascal(1000.0, Unit(-1, 1, -2));
366
const Quantity Quantity::GigaPascal(1e+6, Unit(-1, 1, -2));
367

368
const Quantity Quantity::MilliBar(0.1, Unit(-1, 1, -2));
369
const Quantity Quantity::Bar(100.0, Unit(-1, 1, -2));  // 1 bar = 100 kPa
370

371
const Quantity
372
    Quantity::Torr(101.325 / 760.0,
373
                   Unit(-1, 1, -2));  // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
374
const Quantity
375
    Quantity::mTorr(0.101325 / 760.0,
376
                    Unit(-1, 1, -2));  // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
377
const Quantity
378
    Quantity::yTorr(0.000101325 / 760.0,
379
                    Unit(-1, 1, -2));  // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
380

381
const Quantity Quantity::PSI(6.894744825494, Unit(-1, 1, -2));   // pounds/in^2
382
const Quantity Quantity::KSI(6894.744825494, Unit(-1, 1, -2));   // 1000 x pounds/in^2
383
const Quantity Quantity::MPSI(6894744.825494, Unit(-1, 1, -2));  // 1000 ksi
384

385
const Quantity Quantity::Watt(1e+6, Unit(2, 1, -3));  // Watt (kg*m^2/s^3)
386
const Quantity Quantity::MilliWatt(1e+3, Unit(2, 1, -3));
387
const Quantity Quantity::KiloWatt(1e+9, Unit(2, 1, -3));
388
const Quantity Quantity::VoltAmpere(1e+6, Unit(2, 1, -3));  // VoltAmpere (kg*m^2/s^3)
389

390
const Quantity Quantity::Volt(1e+6, Unit(2, 1, -3, -1));  // Volt (kg*m^2/A/s^3)
391
const Quantity Quantity::MilliVolt(1e+3, Unit(2, 1, -3, -1));
392
const Quantity Quantity::KiloVolt(1e+9, Unit(2, 1, -3, -1));
393

394
const Quantity Quantity::MegaSiemens(1.0, Unit(-2, -1, 3, 2));
395
const Quantity Quantity::KiloSiemens(1e-3, Unit(-2, -1, 3, 2));
396
const Quantity Quantity::Siemens(1e-6, Unit(-2, -1, 3, 2));  // Siemens (A^2*s^3/kg/m^2)
397
const Quantity Quantity::MilliSiemens(1e-9, Unit(-2, -1, 3, 2));
398
const Quantity Quantity::MicroSiemens(1e-12, Unit(-2, -1, 3, 2));
399

400
const Quantity Quantity::Ohm(1e+6, Unit(2, 1, -3, -2));  // Ohm (kg*m^2/A^2/s^3)
401
const Quantity Quantity::KiloOhm(1e+9, Unit(2, 1, -3, -2));
402
const Quantity Quantity::MegaOhm(1e+12, Unit(2, 1, -3, -2));
403

404
const Quantity Quantity::Coulomb(1.0, Unit(0, 0, 1, 1));  // Coulomb (A*s)
405

406
const Quantity Quantity::Tesla(1.0, Unit(0, 1, -2, -1));   // Tesla (kg/s^2/A)
407
const Quantity Quantity::Gauss(1e-4, Unit(0, 1, -2, -1));  // 1 G = 1e-4 T
408

409
const Quantity Quantity::Weber(1e6, Unit(2, 1, -2, -1));  // Weber (kg*m^2/s^2/A)
410

411
// disable Oersted because people need to input e.g. a field strength of
412
// 1 ampere per meter -> 1 A/m and not get the recalculation to Oersted
413
// const Quantity Quantity::Oersted(0.07957747, Unit(-1, 0, 0, 1));// Oersted (A/m)
414

415
const Quantity Quantity::PicoFarad(1e-18, Unit(-2, -1, 4, 2));
416
const Quantity Quantity::NanoFarad(1e-15, Unit(-2, -1, 4, 2));
417
const Quantity Quantity::MicroFarad(1e-12, Unit(-2, -1, 4, 2));
418
const Quantity Quantity::MilliFarad(1e-9, Unit(-2, -1, 4, 2));
419
const Quantity Quantity::Farad(1e-6, Unit(-2, -1, 4, 2));  // Farad (s^4*A^2/m^2/kg)
420

421
const Quantity Quantity::NanoHenry(1e-3, Unit(2, 1, -2, -2));
422
const Quantity Quantity::MicroHenry(1.0, Unit(2, 1, -2, -2));
423
const Quantity Quantity::MilliHenry(1e+3, Unit(2, 1, -2, -2));
424
const Quantity Quantity::Henry(1e+6, Unit(2, 1, -2, -2));  // Henry (kg*m^2/s^2/A^2)
425

426
const Quantity Quantity::Joule(1e+6, Unit(2, 1, -2));  // Joule (kg*m^2/s^2)
427
const Quantity Quantity::MilliJoule(1e+3, Unit(2, 1, -2));
428
const Quantity Quantity::KiloJoule(1e+9, Unit(2, 1, -2));
429
const Quantity Quantity::NewtonMeter(1e+6, Unit(2, 1, -2));              // Joule (kg*m^2/s^2)
430
const Quantity Quantity::VoltAmpereSecond(1e+6, Unit(2, 1, -2));         // Joule (kg*m^2/s^2)
431
const Quantity Quantity::WattSecond(1e+6, Unit(2, 1, -2));               // Joule (kg*m^2/s^2)
432
const Quantity Quantity::KiloWattHour(3.6e+12, Unit(2, 1, -2));          // 1 kWh = 3.6e6 J
433
const Quantity Quantity::ElectronVolt(1.602176634e-13, Unit(2, 1, -2));  // 1 eV = 1.602176634e-19 J
434
const Quantity Quantity::KiloElectronVolt(1.602176634e-10, Unit(2, 1, -2));
435
const Quantity Quantity::MegaElectronVolt(1.602176634e-7, Unit(2, 1, -2));
436
const Quantity Quantity::Calorie(4.1868e+6, Unit(2, 1, -2));  // 1 cal = 4.1868 J
437
const Quantity Quantity::KiloCalorie(4.1868e+9, Unit(2, 1, -2));
438

439
const Quantity Quantity::KMH(277.778, Unit(1, 0, -1));  // km/h
440
const Quantity Quantity::MPH(447.04, Unit(1, 0, -1));   // Mile/h
441

442
const Quantity Quantity::AngMinute(1.0 / 60.0, Unit(0, 0, 0, 0, 0, 0, 0, 1));    // angular minute
443
const Quantity Quantity::AngSecond(1.0 / 3600.0, Unit(0, 0, 0, 0, 0, 0, 0, 1));  // angular second
444
const Quantity
445
    Quantity::Degree(1.0,
446
                     Unit(0, 0, 0, 0, 0, 0, 0, 1));  // degree         (internal standard angle)
447
const Quantity Quantity::Radian(180 / M_PI, Unit(0, 0, 0, 0, 0, 0, 0, 1));  // radian
448
const Quantity Quantity::Gon(360.0 / 400.0, Unit(0, 0, 0, 0, 0, 0, 0, 1));  // gon
449

450

451
// === Parser & Scanner stuff ===============================================
452

453
// include the Scanner and the Parser for the 'Quantity's
454

455
// NOLINTNEXTLINE
456
Quantity QuantResult;
457

458
/* helper function for tuning number strings with groups in a locale agnostic way... */
459
// NOLINTBEGIN
460
double num_change(char* yytext, char dez_delim, char grp_delim)
461
{
462
    double ret_val {};
463
    const int num = 40;
464
    std::array<char, num> temp {};
465
    int iter = 0;
466
    for (char* ch = yytext; *ch != '\0'; ch++) {
467
        // skip group delimiter
468
        if (*ch == grp_delim) {
469
            continue;
470
        }
471
        // check for a dez delimiter other then dot
472
        if (*ch == dez_delim && dez_delim != '.') {
473
            temp[iter++] = '.';
474
        }
475
        else {
476
            temp[iter++] = *ch;
477
        }
478
        // check buffer overflow
479
        if (iter >= num) {
480
            return 0.0;
481
        }
482
    }
483

484
    temp[iter] = '\0';
485

486
    ret_val = atof(temp.data());
487
    return ret_val;
488
}
489
// NOLINTEND
490

491
#if defined(__clang__)
492
#pragma clang diagnostic push
493
#pragma clang diagnostic ignored "-Wmissing-noreturn"
494
#endif
495

496
// error func
497
void Quantity_yyerror(const char* errorinfo)
498
{
499
    throw Base::ParserError(errorinfo);
500
}
501

502
#if defined(__clang__)
503
#pragma clang diagnostic pop
504
#endif
505

506

507
#if defined(__clang__)
508
#pragma clang diagnostic push
509
#pragma clang diagnostic ignored "-Wsign-compare"
510
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
511
#elif defined(__GNUC__)
512
#pragma GCC diagnostic push
513
#pragma GCC diagnostic ignored "-Wsign-compare"
514
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
515
#endif
516

517
namespace QuantityParser
518
{
519

520
// NOLINTNEXTLINE
521
#define YYINITDEPTH 20
522
// show parser the lexer method
523
#define yylex QuantityLexer
524
int QuantityLexer();
525

526
// Parser, defined in QuantityParser.y
527
// NOLINTNEXTLINE
528
#include "QuantityParser.c"
529

530
#ifndef DOXYGEN_SHOULD_SKIP_THIS
531
// Scanner, defined in QuantityParser.l
532
// NOLINTNEXTLINE
533
#include "QuantityLexer.c"
534
#endif  // DOXYGEN_SHOULD_SKIP_THIS
535
}  // namespace QuantityParser
536

537
#if defined(__clang__)
538
#pragma clang diagnostic pop
539
#elif defined(__GNUC__)
540
#pragma GCC diagnostic pop
541
#endif
542

543
Quantity Quantity::parse(const QString& string)
544
{
545
    // parse from buffer
546
    QuantityParser::YY_BUFFER_STATE my_string_buffer =
547
        QuantityParser::yy_scan_string(string.toUtf8().data());
548
    // set the global return variables
549
    QuantResult = Quantity(DOUBLE_MIN);
550
    // run the parser
551
    QuantityParser::yyparse();
552
    // free the scan buffer
553
    QuantityParser::yy_delete_buffer(my_string_buffer);
554

555
    return QuantResult;
556
}
557

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.