KUnitConversion::Converter

Search for usage in LXR

KUnitConversion::Converter Class Reference

#include <converter.h>

Public Member Functions

 Converter ()
 
 Converter (const Converter &other)
 
 ~Converter ()
 
QList< UnitCategorycategories () const
 
UnitCategory category (CategoryId categoryId) const
 
UnitCategory category (const QString &category) const
 
UnitCategory categoryForUnit (const QString &unit) const
 
Value convert (const Value &value, const QString &toUnit=QString()) const
 
Value convert (const Value &value, const Unit &toUnit) const
 
Value convert (const Value &value, UnitId toUnit) const
 
Converteroperator= (const Converter &other)
 
Converteroperator= (Converter &&other)
 
Unit unit (const QString &unitString) const
 
Unit unit (UnitId unitId) const
 

Detailed Description

Class for converting values between units of measurement.

This is a class to convert values between different units of measurement.

See also
Unit, UnitCategory, Value
Author
Petri Damstén damu@.nosp@m.iki..nosp@m.fi
John Layt jlayt.nosp@m.@kde.nosp@m..org

Definition at line 34 of file converter.h.

Constructor & Destructor Documentation

◆ Converter() [1/2]

KUnitConversion::Converter::Converter ( )

Creates a Converter instance.

Definition at line 90 of file converter.cpp.

◆ ~Converter()

KUnitConversion::Converter::~Converter ( )

Destroys this Converter instance.

Definition at line 95 of file converter.cpp.

◆ Converter() [2/2]

KUnitConversion::Converter::Converter ( const Converter & other)

Copy constructor.

Parameters
otherexisting Converter instance.

Definition at line 99 of file converter.cpp.

Member Function Documentation

◆ categories()

QList< UnitCategory > KUnitConversion::Converter::categories ( ) const

Returns a list of all unit categories.

Returns
list of unit categories.

Definition at line 196 of file converter.cpp.

◆ category() [1/2]

UnitCategory KUnitConversion::Converter::category ( CategoryId categoryId) const

Find unit category.

Parameters
categoryIdid of the category to find (LengthCategory, AreaCategory, etc.).
Returns
unit category which id is categoryId or invalid category.

Definition at line 187 of file converter.cpp.

◆ category() [2/2]

UnitCategory KUnitConversion::Converter::category ( const QString & category) const

Find unit category.

Parameters
categoryname of the category to find (length, area, mass, etc.).
Returns
unit category named category or invalid category.

Definition at line 175 of file converter.cpp.

◆ categoryForUnit()

UnitCategory KUnitConversion::Converter::categoryForUnit ( const QString & unit) const

Find unit category for unit.

Parameters
unitunit to find category for.
Returns
unit category for unit

Definition at line 140 of file converter.cpp.

◆ convert() [1/3]

Value KUnitConversion::Converter::convert ( const Value & value,
const QString & toUnit = QString() ) const

Convert value to another unit.

Parameters
valuevalue to convert
toUnitunit to convert to. If empty default unit is used.
Returns
converted value

Definition at line 116 of file converter.cpp.

◆ convert() [2/3]

Value KUnitConversion::Converter::convert ( const Value & value,
const Unit & toUnit ) const

Definition at line 132 of file converter.cpp.

◆ convert() [3/3]

Value KUnitConversion::Converter::convert ( const Value & value,
UnitId toUnit ) const

Definition at line 124 of file converter.cpp.

◆ operator=() [1/2]

Converter & KUnitConversion::Converter::operator= ( const Converter & other)

Assignment operator, assign other to this.

Definition at line 104 of file converter.cpp.

◆ operator=() [2/2]

Converter & KUnitConversion::Converter::operator= ( Converter && other)

Move-assigns other to this Converter instance, transferring the ownership of the managed pointer to this instance.

Definition at line 110 of file converter.cpp.

◆ unit() [1/2]

Unit KUnitConversion::Converter::unit ( const QString & unitString) const

Find unit for string unit.

Parameters
unitStringunit string to find unit for.
Returns
unit for string unit

Definition at line 151 of file converter.cpp.

◆ unit() [2/2]

Unit KUnitConversion::Converter::unit ( UnitId unitId) const

Find unit for unit enum.

Parameters
unitIdunit enum to find unit for.
Returns
unit for string unit

Definition at line 163 of file converter.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.