/* PIP - Platform Independent Primitives Information units Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #include "piunits_class_information.h" PIString PIUnits::Class::Information::name(int type) const { switch (type) { case Bit: return "bit"_tr("PIUnitsInformation"); case Byte: return "byte"_tr("PIUnitsInformation"); } return Class::Internal::unknown; } PIString PIUnits::Class::Information::unit(int type) const { switch (type) { case Bit: return "b"_tr("PIUnitsInformation"); case Byte: return "B"_tr("PIUnitsInformation"); } return Class::Internal::unknown; } double PIUnits::Class::Information::convert(double v, int from, int to) const { switch (to) { case Bit: return v * 8; case Byte: return v / 8; } return v; } PIString PIUnits::Class::Information::valueToString(double v, char format, int prec) const { return PIString::fromNumber(static_cast(v)); } bool PIUnits::Class::Information::supportPrefixes(int type) const { return true; } bool PIUnits::Class::Information::supportPrefixesNon3(int type) const { return false; } bool PIUnits::Class::Information::supportPrefixesGreater(int type) const { return true; } bool PIUnits::Class::Information::supportPrefixesSmaller(int type) const { return false; }