/usr/include/KF5/KUnitConversion/kunitconversion/unit.h is in libkf5unitconversion-dev 5.18.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | /*
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
* Copyright (C) 2014 John Layt <jlayt@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KUNITCONVERSION_UNIT_H
#define KUNITCONVERSION_UNIT_H
#include "kunitconversion/kunitconversion_export.h"
#include <QtCore/QString>
#include <QtCore/QExplicitlySharedDataPointer>
class KLocalizedString;
namespace KUnitConversion
{
enum CategoryId {
InvalidCategory = -1,
LengthCategory,
AreaCategory,
VolumeCategory,
TemperatureCategory,
VelocityCategory,
MassCategory,
PressureCategory,
EnergyCategory,
CurrencyCategory,
PowerCategory,
TimeCategory,
FuelEfficiencyCategory,
DensityCategory,
AccelerationCategory,
AngleCategory,
FrequencyCategory,
ForceCategory
};
enum UnitId {
InvalidUnit = -1,
NoUnit = 0,
Percent = 1,
// Area
SquareYottameter = 1000, SquareZettameter, SquareExameter, SquarePetameter, SquareTerameter,
SquareGigameter, SquareMegameter, SquareKilometer, SquareHectometer, SquareDecameter,
SquareMeter, SquareDecimeter, SquareCentimeter, SquareMillimeter, SquareMicrometer,
SquareNanometer, SquarePicometer, SquareFemtometer, SquareAttometer, SquareZeptometer,
SquareYoctometer, Acre, SquareFoot, SquareInch, SquareMile,
// Length
Yottameter = 2000, Zettameter, Exameter, Petameter, Terameter, Gigameter, Megameter,
Kilometer, Hectometer, Decameter, Meter, Decimeter, Centimeter, Millimeter, Micrometer,
Nanometer, Picometer, Femtometer, Attometer, Zeptometer, Yoctometer, Inch, Foot, Yard,
Mile, NauticalMile, LightYear, Parsec, AstronomicalUnit, Thou, Angstrom,
// Volume
CubicYottameter = 3000, CubicZettameter, CubicExameter, CubicPetameter, CubicTerameter,
CubicGigameter, CubicMegameter, CubicKilometer, CubicHectometer, CubicDecameter, CubicMeter,
CubicDecimeter, CubicCentimeter, CubicMillimeter, CubicMicrometer, CubicNanometer,
CubicPicometer, CubicFemtometer, CubicAttometer, CubicZeptometer, CubicYoctometer,
Yottaliter, Zettaliter, Exaliter, Petaliter, Teraliter, Gigaliter, Megaliter, Kiloliter,
Hectoliter, Decaliter, Liter, Deciliter, Centiliter, Milliliter, Microliter, Nanoliter,
Picoliter, Femtoliter, Attoliter, Zeptoliter, Yoctoliter, CubicFoot, CubicInch, CubicMile,
FluidOunce, Cup, GallonUS, PintImperial,
// Mass
Yottagram = 4000, Zettagram, Exagram, Petagram, Teragram, Gigagram, Megagram, Kilogram,
Hectogram, Decagram, Gram, Decigram, Centigram, Milligram, Microgram, Nanogram, Picogram,
Femtogram, Attogram, Zeptogram, Yoctogram, Ton, Carat, Pound, Ounce, TroyOunce, MassNewton,
Kilonewton,
// Pressure
Yottapascal = 5000, Zettapascal, Exapascal, Petapascal, Terapascal, Gigapascal, Megapascal,
Kilopascal, Hectopascal, Decapascal, Pascal, Decipascal, Centipascal, Millipascal,
Micropascal, Nanopascal, Picopascal, Femtopascal, Attopascal, Zeptopascal, Yoctopascal,
Bar, Millibar, Decibar, Torr, TechnicalAtmosphere, Atmosphere, PoundForcePerSquareInch,
InchesOfMercury, MillimetersOfMercury,
// Temperature
Kelvin = 6000, Celsius, Fahrenheit, Rankine, Delisle, TemperatureNewton, Reaumur, Romer,
// Energy
Yottajoule = 7000, Zettajoule, Exajoule, Petajoule, Terajoule, Gigajoule, Megajoule,
Kilojoule, Hectojoule, Decajoule, Joule, Decijoule, Centijoule, Millijoule, Microjoule,
Nanojoule, Picojoule, Femtojoule, Attojoule, Zeptojoule, Yoctojoule, GuidelineDailyAmount,
Electronvolt, Rydberg, Kilocalorie, PhotonWavelength, KiloJoulePerMole, JoulePerMole,
// Currency
Eur = 8000, Ats, Bef, Nlg, Fim, Frf, Dem, Iep, Itl, Luf, Pte, Esp, Grd, Sit, Cyp, Mtl, Skk,
Usd, Jpy, Bgn, Czk, Dkk, Eek, Gbp, Huf, Ltl, Lvl, Pln, Ron, Sek, Chf, Nok, Hrk, Rub, Try,
Aud, Brl, Cad, Cny, Hkd, Idr, Inr, Krw, Mxn, Myr, Nzd, Php, Sgd, Thb, Zar,
// Velocity
MeterPerSecond = 9000, KilometerPerHour, MilePerHour, FootPerSecond, InchPerSecond, Knot,
Mach, SpeedOfLight, Beaufort,
// Power
Yottawatt = 10000, Zettawatt, Exawatt, Petawatt, Terawatt, Gigawatt, Megawatt, Kilowatt,
Hectowatt, Decawatt, Watt, Deciwatt, Centiwatt, Milliwatt, Microwatt, Nanowatt, Picowatt,
Femtowatt, Attowatt, Zeptowatt, Yoctowatt, Horsepower,
// Time
Yottasecond = 11000, Zettasecond, Exasecond, Petasecond, Terasecond, Gigasecond, Megasecond,
Kilosecond, Hectosecond, Decasecond, Second, Decisecond, Centisecond, Millisecond,
Microsecond, Nanosecond, Picosecond, Femtosecond, Attosecond, Zeptosecond, Yoctosecond,
Minute, Hour, Day, Week, JulianYear, LeapYear, Year,
// FuelEfficiency
LitersPer100Kilometers = 12000, MilePerUsGallon, MilePerImperialGallon, KilometrePerLitre,
// Density
YottakilogramsPerCubicMeter = 13000, ZettakilogramPerCubicMeter, ExakilogramPerCubicMeter,
PetakilogramPerCubicMeter, TerakilogramPerCubicMeter, GigakilogramPerCubicMeter,
MegakilogramPerCubicMeter, KilokilogramPerCubicMeter, HectokilogramsPerCubicMeter,
DecakilogramsPerCubicMeter, KilogramsPerCubicMeter, DecikilogramsPerCubicMeter,
CentikilogramsPerCubicMeter, MillikilogramsPerCubicMeter, MicrokilogramsPerCubicMeter,
NanokilogramsPerCubicMeter, PicokilogramsPerCubicMeter, FemtokilogramsPerCubicMeter,
AttokilogramsPerCubicMeter, ZeptokilogramsPerCubicMeter, YoctokilogramsPerCubicMeter,
KilogramPerLiter, GramPerLiter, GramPerMilliliter,
OuncePerCubicInch, OuncePerCubicFoot, OuncePerCubicYard,
PoundPerCubicInch, PoundPerCubicFoot, PoundPerCubicYard,
// Acceleration
MetresPerSecondSquared = 14000, FeetPerSecondSquared, StandardGravity,
// Force
Yottanewton = 15000, Zettanewton, Exanewton, Petanewton, Teranewton, Giganewton, Meganewton,
KilonewtonForce, Hectonewton, Decanewton, Newton, Decinewton, Centinewton, Millinewton, Micronewton,
Nanonewton, Piconewton, Femtonewton, Attonewton, Zeptonewton, Yoctonewton, Dyne, Kilopond,
PoundForce, Poundal,
// Angle
Degree = 16000, Radian, Gradian, ArcMinute, ArcSecond,
// Frequency
Yottahertz = 17000, Zettahertz, Exahertz, Petahertz, Terahertz, Gigahertz, Megahertz,
Kilohertz, Hectohertz, Decahertz, Hertz, Decihertz, Centihertz, Millihertz, Microhertz,
Nanohertz, Picohertz, Femtohertz, Attohertz, Zeptohertz, Yoctohertz, RPM
};
class UnitCategory;
class UnitPrivate;
/**
* @short Class to define a unit of measurement
*
* @since 4.4
*
* This is a class to define a unit of measurement.
*
* @b license GNU-LGPL v.2 or later
*
* @see Converter, UnitCategory, Value
*
* @author Petri Damstén <damu@iki.fi>
* @author John Layt <jlayt@kde.org>
*/
class KUNITCONVERSION_EXPORT Unit
{
public:
/**
* Null constructor
**/
Unit();
/**
* Copy constructor, copy @param other to this.
**/
Unit(const Unit &other);
virtual ~Unit();
/**
* Assignment operator, assign @param other to this.
**/
Unit &operator=(const Unit &other);
#ifdef Q_COMPILER_RVALUE_REFS
/**
* Move-assigns \a other to this Unit instance, transferring the
* ownership of the managed pointer to this instance.
**/
Unit &operator=(Unit &&other) { swap(other); return *this; }
#endif
/**
* Swaps this Unit with \a other. This function is very fast and never fails.
**/
void swap(Unit &other) { d.swap(other.d); }
/**
* @return Returns true if this Unit is equal to the @param other Unit.
**/
bool operator==(const Unit &other) const;
/**
* @return Returns true if this Unit is not equal to the @param other Unit.
**/
bool operator!=(const Unit &other) const;
/**
* @return returns true if this Unit is null
**/
bool isNull() const;
/**
* @return if unit is valid.
**/
bool isValid() const;
/**
* @return unit id.
**/
UnitId id() const;
/**
* @return category id.
**/
CategoryId categoryId() const;
/**
* @return unit category.
**/
UnitCategory category() const;
/**
* @return translated name for unit.
**/
QString description() const;
/**
* @return symbol for the unit.
**/
QString symbol() const;
/**
* @param value number value
* @param fieldWidth width of the formatted field, padded by spaces.
* Positive value aligns right, negative aligns left
* @param format type of floating point formating, like in QString::arg
* @param precision number of digits after the decimal separator
* @param fillChar the character used to fill up the empty places when
* field width is greater than argument width
* @return value + unit string
**/
QString toString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1,
const QChar &fillChar = QLatin1Char(' ')) const;
/**
* @param value number value
* @param fieldWidth width of the formatted field, padded by spaces.
* Positive value aligns right, negative aligns left
* @param format type of floating point formating, like in QString::arg
* @param precision number of digits after the decimal separator
* @param fillChar the character used to fill up the empty places when
* field width is greater than argument width
* @return value + unit string
**/
QString toSymbolString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1,
const QChar &fillChar = QLatin1Char(' ')) const;
protected:
qreal toDefault(qreal value) const;
qreal fromDefault(qreal value) const;
private:
friend class CustomUnit;
friend class UnitCategory;
friend class UnitCategoryPrivate;
friend class CurrencyCategoryPrivate;
Unit(UnitPrivate *dd);
void setUnitMultiplier(qreal multiplier);
QExplicitlySharedDataPointer<UnitPrivate> d;
};
#define U(id, m, s, d, sy, r, i) (KUnitConversion::Unit(*this, id, m, s, d, sy, r, i))
} // KUnitConversion namespace
#endif
|