Debian Codegraph @

src/Base/UnitsSchema.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2009 Jürgen Riegel <[email protected]> *
5 * *
6 * This file is part of the FreeCAD CAx development system. *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Library General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Library General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Library General Public *
19 * License along with this library; see the file COPYING.LIB. If not, *
20 * write to the Free Software Foundation, Inc., 59 Temple Place, *
21 * Suite 330, Boston, MA 02111-1307, USA *
22 * *
23 ***************************************************************************/
24
25 #ifndef BASE_UNITSSCHEMA_H
26 #define BASE_UNITSSCHEMA_H
27
28 #include <string>
29 #include <memory>
30
31 #include "UnitsSchemasSpecs.h"
32 #include "Base/Quantity.h"
33
34 namespace Base
35 {
36 class Quantity;
37
38 /**
39 * An individual schema object
40 */
41 class BaseExport UnitsSchema
42 {
43 public:
44 explicit UnitsSchema(UnitsSchemaSpec spec);
45 UnitsSchema() = delete;
46
47 [[nodiscard]] bool isMultiUnitLength() const;
48 [[nodiscard]] bool isMultiUnitAngle() const;
49 [[nodiscard]] std::string getBasicLengthUnit() const;
50 [[nodiscard]] std::string getName() const;
51 [[nodiscard]] std::string getDescription() const;
52 [[nodiscard]] int getNum() const;
53
54 std::string translate(const Quantity& quant) const;
55 std::string translate(const Quantity& quant, double& factor, std::string& unitString) const;
56
57 private:
58 [[nodiscard]] static std::string toLocale(
59 const Quantity& quant,
60 double factor,
61 const std::string& unitString
62 );
63
64 UnitsSchemaSpec spec;
65 };
66
67
68 } // namespace Base
69 #endif // BASE_UNITSSCHEMA_H