99 const std::string type = node.
getProperty(
"type",
"");
112 if (uLevel.name() ==
"level")
116 ul.
count = uLevel.getProperty(
"count", -1);
117 ul.
round = uLevel.getProperty(
"round", bu.
round);
126 Log::info(
"Error bad unit count: %d for %s in %s",
137 if (type ==
"weight")
139 else if (type ==
"currency")
142 Log::info(
"Error unknown unit type: %s in %s", type.c_str(), filename.c_str());
170 int levelAmount = (int) amount;
173 levelAmount /= ul.
count;
175 amount -= levelAmount * ul.
count;
183 for (
unsigned int i = 2; i < ud.
levels.size(); i++)
188 nextAmount = levelAmount / ul.
count;
189 levelAmount %= ul.
count;
191 if (levelAmount > 0) output =
strprintf(
"%d%s",
192 levelAmount, pl.
symbol.c_str()) + output;
196 levelAmount = nextAmount;
202 for (
unsigned int i = 0; i < ud.
levels.size(); i++)
205 if (amount < ul.count && ul.count > 0)
static std::string formatCurrency(int value)
Formats the given number in the correct currency format.
static void readUnitNode(XML::Node node, const std::string &filename)
static std::string formatWeight(int value)
Formats the given number in the correct weight/mass format.
static void checkStatus()
int getProperty(const char *name, int def) const
Children children() const
void info(const char *log_text,...) LOG_PRINTF_ATTR
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::vector< UnitLevel > levels
std::string formatUnit(int value, int type)
UnitDescription units[UNIT_END]