diff --git a/src/converter.h b/src/converter.h index e6e8c44..c8ce1de 100644 --- a/src/converter.h +++ b/src/converter.h @@ -1,162 +1,162 @@ /* * Copyright (C) 2008-2009 Petri Damstén * Copyright (C) 2014 John Layt * * 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_CONVERTER_H #define KUNITCONVERSION_CONVERTER_H #include #include "unitcategory.h" #include #include namespace KUnitConversion { class Value; class UnitCategory; class ConverterPrivate; /** * @short Class for converting values between units of measurement * * @since 4.4 * * This is a class to convert values between different units of measurement. * * @b license GNU-LGPL v.2 or later * * @see Unit, UnitCategory, Value * * @author Petri Damstén * @author John Layt */ class KUNITCONVERSION_EXPORT Converter { public: /** * Creates a Converter instance. */ Converter(); /** * Destroys this Converter instance. */ ~Converter(); /** * Copy constructor. * @param other existing Converter instance. */ Converter(const Converter &other); /** * Assignment operator, assign @p other to this. **/ Converter &operator=(const Converter &other); #ifdef Q_COMPILER_RVALUE_REFS /** - * Move-assigns \a other to this Converter instance, transferring the + * Move-assigns @p other to this Converter instance, transferring the * ownership of the managed pointer to this instance. **/ Converter &operator=(Converter &&other) { swap(other); return *this; } #endif /** - * Swaps this Converter with \a other. This function is very fast and never fails. + * Swaps this Converter with @p other. This function is very fast and never fails. **/ void swap(Converter &other) { d.swap(other.d); } /** - * @return Returns true if this Converter is equal to the @param other Converter. + * @return @c true if this Converter is equal to the @p other Converter. **/ bool operator==(const Converter &other) const; /** - * @return Returns true if this Converter is not equal to the @param other Converter. + * @return @c true if this Converter is not equal to the @p other Converter. **/ bool operator!=(const Converter &other) const; /** * Convert value to another unit. * * @param value value to convert * @param toUnit unit to convert to. If empty default unit is used. * @return converted value **/ Value convert(const Value &value, const QString &toUnit = QString()) const; Value convert(const Value &value, UnitId toUnit) const; Value convert(const Value &value, const Unit &toUnit) const; /** * Find unit category for unit. * * @param unit unit to find category for. * @return unit category for unit **/ UnitCategory categoryForUnit(const QString &unit) const; /** * Find unit for string unit. * * @param unitString unit string to find unit for. * @return unit for string unit **/ Unit unit(const QString &unitString) const; /** * Find unit for unit enum. * * @param unit unit enum to find unit for. * @return unit for string unit **/ Unit unit(UnitId unitId) const; /** * Find unit category. * * @param category name of the category to find (length, area, mass, etc.). * @return unit category named category or invalid category. **/ UnitCategory category(const QString &category) const; /** * Find unit category. * * @param categoryId id of the category to find (LengthCategory, AreaCategory, etc.). * @return unit category which id is categoryId or invalid category. **/ UnitCategory category(CategoryId categoryId) const; /** * Returns a list of all unit categories. * * @return list of unit categories. **/ QList categories() const; private: QExplicitlySharedDataPointer d; }; } // KUnitConversion namespace #endif diff --git a/src/unit.h b/src/unit.h index 381fade..d27f561 100644 --- a/src/unit.h +++ b/src/unit.h @@ -1,472 +1,472 @@ /* * Copyright (C) 2007-2009 Petri Damstén * Copyright (C) 2014 John Layt * * 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 #include 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, /** @since 5.27 */ ThermalConductivityCategory, /** @since 5.27 */ ThermalFluxCategory, /** @since 5.27 */ ThermalGenerationCategory, /** @since 5.27 */ VoltageCategory, /** @since 5.27 */ ElectricalCurrentCategory, /** @since 5.27 */ ElectricalResistanceCategory }; 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, /** @since 5.26 */ Stone, // 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, /** @since 5.27 */ Btu, /** @since 5.27 */ Erg, // 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, Ils, // 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, // Thermal Conductivity /** @since 5.27 */ WattPerMeterKelvin = 18000, /** @since 5.27 */ BtuPerFootHourFahrenheit, /** @since 5.27 */ BtuPerSquareFootHourFahrenheitPerInch, // Thermal Flux Density /** @since 5.27 */ WattPerSquareMeter = 19000, /** @since 5.27 */ BtuPerHourPerSquareFoot, // Thermal Generation per volume /** @since 5.27 */ WattPerCubicMeter = 20000, /** @since 5.27 */ BtuPerHourPerCubicFoot, // Voltage /** @since 5.27 */ Yottavolts = 30000, /** @since 5.27 */ Zettavolts, /** @since 5.27 */ Exavolts, /** @since 5.27 */ Petavolts, /** @since 5.27 */ Teravolts, /** @since 5.27 */ Gigavolts, /** @since 5.27 */ Megavolts, /** @since 5.27 */ Kilovolts, /** @since 5.27 */ Hectovolts, /** @since 5.27 */ Decavolts, /** @since 5.27 */ Volts, /** @since 5.27 */ Decivolts, /** @since 5.27 */ Centivolts, /** @since 5.27 */ Millivolts, /** @since 5.27 */ Microvolts, /** @since 5.27 */ Nanovolts, /** @since 5.27 */ Picovolts, /** @since 5.27 */ Femtovolts, /** @since 5.27 */ Attovolts, /** @since 5.27 */ Zeptovolts, /** @since 5.27 */ Yoctovolts, /** @since 5.27 */ Statvolts, // Electrical Current /** @since 5.27 */ Yottaampere = 31000, /** @since 5.27 */ Zettaampere, /** @since 5.27 */ Exaampere, /** @since 5.27 */ Petaampere, /** @since 5.27 */ Teraampere, /** @since 5.27 */ Gigaampere, /** @since 5.27 */ Megaampere, /** @since 5.27 */ Kiloampere, /** @since 5.27 */ Hectoampere, /** @since 5.27 */ Decaampere, /** @since 5.27 */ Ampere, /** @since 5.27 */ Deciampere, /** @since 5.27 */ Centiampere, /** @since 5.27 */ Milliampere, /** @since 5.27 */ Microampere, /** @since 5.27 */ Nanoampere, /** @since 5.27 */ Picoampere, /** @since 5.27 */ Femtoampere, /** @since 5.27 */ Attoampere, /** @since 5.27 */ Zeptoampere, /** @since 5.27 */ Yoctoampere, // Electrical Resistance /** @since 5.27 */ Yottaohms = 32000, /** @since 5.27 */ Zettaohms, /** @since 5.27 */ Exaohms, /** @since 5.27 */ Petaohms, /** @since 5.27 */ Teraohms, /** @since 5.27 */ Gigaohms, /** @since 5.27 */ Megaohms, /** @since 5.27 */ Kiloohms, /** @since 5.27 */ Hectoohms, /** @since 5.27 */ Decaohms, /** @since 5.27 */ Ohms, /** @since 5.27 */ Deciohms, /** @since 5.27 */ Centiohms, /** @since 5.27 */ Milliohms, /** @since 5.27 */ Microohms, /** @since 5.27 */ Nanoohms, /** @since 5.27 */ Picoohms, /** @since 5.27 */ Femtoohms, /** @since 5.27 */ Attoohms, /** @since 5.27 */ Zeptoohms, /** @since 5.27 */ Yoctoohms }; 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 * @author John Layt */ class KUNITCONVERSION_EXPORT Unit { public: /** * Null constructor **/ Unit(); /** - * Copy constructor, copy @param other to this. + * Copy constructor, copy @p other to this. **/ Unit(const Unit &other); virtual ~Unit(); /** - * Assignment operator, assign @param other to this. + * Assignment operator, assign @p other to this. **/ Unit &operator=(const Unit &other); #ifdef Q_COMPILER_RVALUE_REFS /** - * Move-assigns \a other to this Unit instance, transferring the + * Move-assigns @p 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. + * Swaps this Unit with @p 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. + * @return @c true if this Unit is equal to the @p other Unit. **/ bool operator==(const Unit &other) const; /** - * @return Returns true if this Unit is not equal to the @param other Unit. + * @return @c true if this Unit is not equal to the @p 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 d; }; } // KUnitConversion namespace #endif diff --git a/src/unitcategory.h b/src/unitcategory.h index 6223a2e..e6c30c9 100644 --- a/src/unitcategory.h +++ b/src/unitcategory.h @@ -1,194 +1,194 @@ /* * Copyright (C) 2007-2009 Petri Damstén * Copyright (C) 2014 John Layt * * 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_UNITCATEGORY_H #define KUNITCONVERSION_UNITCATEGORY_H #include "kunitconversion/kunitconversion_export.h" #include "value.h" #include "unit.h" #include #include #include namespace KUnitConversion { class UnitCategoryPrivate; /** * @short Class to define a category of units of measurement * * @since 4.4 * * This is a class to define a category of units of measurement. * * @b license GNU-LGPL v.2 or later * * @see Converter, Unit, Value * * @author Petri Damstén * @author John Layt */ class KUNITCONVERSION_EXPORT UnitCategory { public: /** * Null constructor **/ UnitCategory(); /** - * Copy constructor, copy @param other to this. + * Copy constructor, copy @p other to this. **/ UnitCategory(const UnitCategory &other); virtual ~UnitCategory(); /** - * Assignment operator, assign @param other to this. + * Assignment operator, assign @p other to this. **/ UnitCategory &operator=(const UnitCategory &other); #ifdef Q_COMPILER_RVALUE_REFS /** - * Move-assigns \a other to this UnitCategory instance, transferring the + * Move-assigns @p other to this UnitCategory instance, transferring the * ownership of the managed pointer to this instance. **/ UnitCategory &operator=(UnitCategory &&other) { swap(other); return *this; } #endif /** - * Swaps this UnitCategory with \a other. This function is very fast and never fails. + * Swaps this UnitCategory with @p other. This function is very fast and never fails. **/ void swap(UnitCategory &other) { d.swap(other.d); } /** - * @return Returns true if this UnitCategory is equal to the @param other UnitCategory. + * @return @c true if this UnitCategory is equal to the @p other UnitCategory. **/ bool operator==(const UnitCategory &other) const; /** - * @return Returns true if this UnitCategory is not equal to the @param other UnitCategory. + * @return @c true if this UnitCategory is not equal to the @p other UnitCategory. **/ bool operator!=(const UnitCategory &other) const; /** * @return returns true if this UnitCategory is null **/ bool isNull() const; /** * @return category id. **/ CategoryId id() const; /** * Returns name for the unit category. * * @return Translated name for category. **/ QString name() const; /** * @return unit category description **/ QString description() const; /** * Returns default unit. * * @return default unit. **/ Unit defaultUnit() const; /** * Check if unit category has a unit. * * @return True if unit is found **/ bool hasUnit(const QString &unit) const; /** * Return unit for string. * * @return Pointer to unit class. **/ Unit unit(const QString &s) const; /** * Return unit for unit enum. * * @return Pointer to unit class. **/ Unit unit(UnitId unitId) const; /** * Return units in this category. * * @return list of units. **/ QList units() const; /** * Return most common units in this category. * * @return list of units. **/ QList mostCommonUnits() const; /** * Return all unit names, short names and unit synonyms in this category. * * @return list of units. **/ QStringList allUnits() const; /** * Convert value to another unit. * * @param value value to convert * @param toUnit unit to convert to. If empty default unit is used. * @return converted value **/ Value convert(const Value &value, const QString &toUnit = QString()); Value convert(const Value &value, UnitId toUnit); virtual Value convert(const Value &value, const Unit &toUnit); protected: void addDefaultUnit(const Unit &unit); void addCommonUnit(const Unit &unit); void addUnit(const Unit &unit); private: friend class CustomCategory; friend class Unit; UnitCategory(UnitCategoryPrivate *dd); QExplicitlySharedDataPointer d; }; } // KUnitConversion namespace #endif diff --git a/src/value.h b/src/value.h index 16f55d6..e14c681 100644 --- a/src/value.h +++ b/src/value.h @@ -1,190 +1,190 @@ /* * Copyright (C) 2007-2009 Petri Damstén * Copyright (C) 2014 John Layt * * 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_VALUE_H #define KUNITCONVERSION_VALUE_H #include "kunitconversion/kunitconversion_export.h" #include "unit.h" #include #include class QVariant; namespace KUnitConversion { class ValuePrivate; /** * @short Class to hold a value in a unit of measurement * * @since 4.4 * * This is a class to hold a value in a unit of measurement. * * @b license GNU-LGPL v.2 or later * * @see Converter, Unit, UnitCategory * * @author Petri Damstén * @author John Layt */ class KUNITCONVERSION_EXPORT Value { public: /** * Creates a null value. */ Value(); /** * Creates a value with a unit instance */ Value(qreal number, const Unit &unit); /** * Creates a value with a unit (as a string). */ Value(qreal number, const QString &unitString); /** * Creates a value with a unit (as a enum value). */ Value(qreal number, UnitId unitId); /** * Creates a value based on a QVariant (calling toReal() on it) with a unit (as a string). */ Value(const QVariant &number, const QString &unitString); /** * Copy constructor, copy @p other to this. **/ Value(const Value &other); /** * Destroys this Value instance */ ~Value(); /** * Assignment operator, assign @p other to this. **/ Value &operator=(const Value &other); #ifdef Q_COMPILER_RVALUE_REFS /** - * Move-assigns \a other to this Value instance, transferring the + * Move-assigns @p other to this Value instance, transferring the * ownership of the managed pointer to this instance. **/ Value &operator=(Value &&other) { swap(other); return *this; } #endif /** - * Swaps this Value with \a other. This function is very fast and never fails. + * Swaps this Value with @p other. This function is very fast and never fails. **/ void swap(Value &other) { d.swap(other.d); } /** - * @return Returns true if this Value is equal to the @param other Value. + * @return @c true if this Value is equal to the @p other Value. **/ bool operator==(const Value &other) const; /** - * @return Returns true if this Value is not equal to the @param other Value. + * @return @c true if this Value is not equal to the @p other Value. **/ bool operator!=(const Value &other) const; /** * @return returns true if this Value is null **/ bool isNull() const; /** * Check if value is valid. * * @return True if value is valid **/ bool isValid() const; /** * Number part of the value **/ qreal number() const; /** * Unit part of the value **/ Unit unit() const; /** * Convert value to a string * @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 as a string **/ QString toString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const; /** * Convert value to a string with symbol * @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 as a string **/ QString toSymbolString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const; /** * rounds value to decimal count * @param decimals decimal count. **/ Value &round(uint decimals); /** * convert to another unit **/ Value convertTo(const Unit &unit) const; /** * convert to another unit **/ Value convertTo(UnitId unit) const; /** * convert to another unit **/ Value convertTo(const QString &unit) const; private: QSharedDataPointer d; }; } // KUnitConversion namespace #endif