1/* 2 * Copyright 2011-2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Adrien Destugues, pulkomandy@pulkomandy.ath.cx 7 * John Scipione, jscipione@gmail.com 8 * 9 * Corresponds to: 10 * headers/os/locale/NumberFormat.h hrev48439 11 * src/kits/locale/NumberFormat.cpp hrev48439 12 */ 13 14 15/*! 16 \file NumberFormat.h 17 \ingroup locale 18 \ingroup libbe 19 \brief Contains BNumberFormat class, a number formatter and parser. 20*/ 21 22 23/*! 24 \class BNumberFormat 25 \ingroup locale 26 \ingroup libbe 27 \brief Formatter for numbers and monetary values. 28 29 \since Haiku R1 30*/ 31 32 33/*! 34 \fn BNumberFormat::BNumberFormat(const BNumberFormat& other) 35 \brief Copy Constructor. 36 37 \param other The BNumberFormat object to copy from. 38 39 \since Haiku R1 40*/ 41 42 43/*! 44 \fn BNumberFormat::~BNumberFormat() 45 \brief Destructor. 46 47 \since Haiku R1 48*/ 49 50 51/*! 52 \fn ssize_t BNumberFormat::Format(char* string, size_t maxSize, 53 const double value) 54 \brief Format the \c double \a value as a string and put the result 55 into \a string up to \a maxSize bytes in the current locale. 56 57 \param string The string to put the formatted number into. 58 \param maxSize The maximum of bytes to copy into \a string. 59 \param value The number that you want to get a formatted version of. 60 61 \returns The length of the string created or an error status code. 62 \retval B_ERROR Unable to lock the BNumberFormat. 63 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 64 object. 65 \retval B_BAD_VALUE There was not enough space to store the result. 66 67 \sa BNumberFormat::Format(char* string, size_t maxSize, 68 int32 value) const 69 \sa ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize, 70 double value) const 71 72 \since Haiku R1 73*/ 74 75 76/*! 77 \fn status_t BNumberFormat::Format(BString& string, const double value) 78 \brief \brief Format the \c double \a value as a string and put the 79 result into \a string in the current locale. 80 81 \param string The string to put the formatted number into. 82 \param value The number that you want to get a formatted version of. 83 84 \returns A status code. 85 \retval B_OK Everything went fine. 86 \retval B_ERROR Unable to lock the BNumberFormat. 87 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 88 object. 89 \retval B_BAD_VALUE There was not enough space to store the result. 90 91 \sa BNumberFormat::Format(BString* string, int32 value) const 92 \sa BNumberFormat::FormatMonetary(BString* string, double value) const 93 94 \since Haiku R1 95*/ 96 97 98/*! 99 \fn ssize_t BNumberFormat::Format(char* string, size_t maxSize, 100 const int32 value) 101 \brief Format the \c int32 \a value as a string and put the result 102 into \a string up to \a maxSize bytes in the current locale. 103 104 \param string The string to put the formatted number into. 105 \param maxSize The maximum of bytes to copy into \a string. 106 \param value The number that you want to get a formatted version of. 107 108 \returns The length of the string created or an error status code. 109 \retval B_ERROR Unable to lock the BNumberFormat. 110 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 111 object. 112 \retval B_BAD_VALUE There was not enough space to store the result. 113 114 \sa BNumberFormat::Format(char* string, size_t maxSize, 115 double value) const 116 \sa BNumberFormat::FormatMonetary(char* string, size_t maxSize, 117 double value) const 118 119 \since Haiku R1 120*/ 121 122 123/*! 124 \fn status_t BNumberFormat::Format(BString& string, const int32 value) 125 \brief Format the \c int32 \a value as a string and put the result 126 into \a string in the current locale. 127 128 \param string The string to put the formatted number into. 129 \param value The number that you want to get a formatted version of. 130 131 \returns A status code. 132 \retval B_OK Everything went fine. 133 \retval B_ERROR Unable to lock the BNumberFormat. 134 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 135 object. 136 \retval B_BAD_VALUE There was not enough space to store the result. 137 138 \sa BNumberFormat::Format(BString* string, double value) const 139 \sa BNumberFormat::FormatMonetary(BString* string, double value) const 140 141 \since Haiku R1 142*/ 143 144 145/*! 146 \fn ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize, 147 const double value) 148 \brief Format the \c double \a value as a monetary string and put the 149 result into \a string up to \a maxSize bytes in the current locale. 150 151 It uses the money symbol set by the Locale (€, $, ...) or the generic money 152 symbol (¤) if the locale is not country-specific. 153 154 \param string The \a string to put the monetary formatted number into. 155 \param maxSize The maximum of bytes to copy into \a string. 156 \param value The number to format as a monetary \a value. 157 158 \returns The length of the string created or an error status code. 159 \retval B_ERROR Unable to lock the BNumberFormat. 160 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 161 object. 162 \retval B_BAD_VALUE There was not enough space to store the result. 163 164 \sa BNumberFormat::Format(char* string, size_t maxSize, double value) const 165 \sa BNumberFormat::Format(char* string, size_t maxSize, int32 value) const 166 167 \since Haiku R1 168*/ 169 170 171/*! 172 \fn status_t BNumberFormat::FormatMonetary(BString& string, 173 const double value) 174 \brief Format the \c double \a value as a monetary string and put 175 the result into \a string in the current locale. 176 177 \param string The \a string to put the monetary formatted number into. 178 \param value The number to format as a monetary \a value. 179 180 \returns A status code. 181 \retval B_OK Everything went fine. 182 \retval B_ERROR Unable to lock the BNumberFormat. 183 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat 184 object. 185 \retval B_BAD_VALUE There was not enough space to store the result. 186 187 \sa BNumberFormat::Format(BString* string, double value) const 188 \sa BNumberFormat::Format(BString* string, int32 value) const 189 190 \since Haiku R1 191*/ 192