1 /* 2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 ** Distributed under the terms of the OpenBeOS License. 4 */ 5 6 7 #include <Country.h> 8 #include <String.h> 9 10 #include <monetary.h> 11 #include <stdarg.h> 12 13 14 const char *gStrings[] = { 15 // date/time format 16 "", 17 "", 18 "", 19 "", 20 // short date/time format 21 "", 22 "", 23 "", 24 "", 25 // am/pm string 26 "AM", 27 "PM", 28 // separators 29 ".", 30 ":", 31 " ", 32 ".", 33 ",", 34 // positive/negative sign 35 "+", 36 "-", 37 // currency/monetary 38 "US$" 39 " " 40 "." 41 "," 42 }; 43 44 45 BCountry::BCountry() 46 : 47 fStrings(gStrings) 48 { 49 } 50 51 52 BCountry::BCountry(const char **strings) 53 : 54 fStrings(strings) 55 { 56 } 57 58 59 BCountry::~BCountry() 60 { 61 } 62 63 64 const char * 65 BCountry::Name() const 66 { 67 return "United States Of America"; 68 } 69 70 71 const char * 72 BCountry::GetString(uint32 id) const 73 { 74 if (id < B_COUNTRY_STRINGS_BASE || id >= B_NUM_COUNTRY_STRINGS) 75 return NULL; 76 77 return gStrings[id - B_COUNTRY_STRINGS_BASE]; 78 } 79 80 81 void 82 BCountry::FormatDate(char *string, size_t maxSize, time_t time, bool longFormat) 83 { 84 // ToDo: implement us 85 } 86 87 88 void 89 BCountry::FormatDate(BString *string, time_t time, bool longFormat) 90 { 91 } 92 93 94 void 95 BCountry::FormatTime(char *string, size_t maxSize, time_t time, bool longFormat) 96 { 97 } 98 99 100 void 101 BCountry::FormatTime(BString *string, time_t time, bool longFormat) 102 { 103 } 104 105 106 const char * 107 BCountry::DateFormat(bool longFormat) const 108 { 109 return fStrings[longFormat ? B_DATE_FORMAT : B_SHORT_DATE_FORMAT]; 110 } 111 112 113 const char * 114 BCountry::TimeFormat(bool longFormat) const 115 { 116 return fStrings[longFormat ? B_TIME_FORMAT : B_SHORT_TIME_FORMAT]; 117 } 118 119 120 const char * 121 BCountry::DateSeparator() const 122 { 123 return fStrings[B_DATE_SEPARATOR]; 124 } 125 126 127 const char * 128 BCountry::TimeSeparator() const 129 { 130 return fStrings[B_TIME_SEPARATOR]; 131 } 132 133 134 void 135 BCountry::FormatNumber(char *string, size_t maxSize, double value) 136 { 137 } 138 139 140 void 141 BCountry::FormatNumber(BString *string, double value) 142 { 143 } 144 145 146 void 147 BCountry::FormatNumber(char *string, size_t maxSize, int32 value) 148 { 149 } 150 151 152 void 153 BCountry::FormatNumber(BString *string, int32 value) 154 { 155 } 156 157 158 const char * 159 BCountry::DecimalPoint() const 160 { 161 return fStrings[B_DECIMAL_POINT]; 162 } 163 164 165 const char * 166 BCountry::ThousandsSeparator() const 167 { 168 return fStrings[B_THOUSANDS_SEPARATOR]; 169 } 170 171 172 const char * 173 BCountry::Grouping() const 174 { 175 return fStrings[B_GROUPING]; 176 } 177 178 179 const char * 180 BCountry::PositiveSign() const 181 { 182 return fStrings[B_POSITIVE_SIGN]; 183 } 184 185 186 const char * 187 BCountry::NegativeSign() const 188 { 189 return fStrings[B_NEGATIVE_SIGN]; 190 } 191 192 193 int8 194 BCountry::Measurement() const 195 { 196 return B_US; 197 } 198 199 200 ssize_t 201 BCountry::FormatMonetary(char *string, size_t maxSize, char *format, ...) 202 { 203 va_list args; 204 va_start(args,format); 205 206 ssize_t status = vstrfmon(string, maxSize, format, args); 207 208 va_end(args); 209 210 return status; 211 } 212 213 214 ssize_t 215 BCountry::FormatMonetary(BString *string, char *format, ...) 216 { 217 return B_OK; 218 } 219 220 221 const char * 222 BCountry::CurrencySymbol() const 223 { 224 return fStrings[B_CURRENCY_SYMBOL]; 225 } 226 227 228 const char * 229 BCountry::InternationalCurrencySymbol() const 230 { 231 return fStrings[B_INT_CURRENCY_SYMBOL]; 232 } 233 234 235 const char * 236 BCountry::MonDecimalPoint() const 237 { 238 return fStrings[B_MON_DECIMAL_POINT]; 239 } 240 241 242 const char * 243 BCountry::MonThousandsSeparator() const 244 { 245 return fStrings[B_MON_THOUSANDS_SEPARATOR]; 246 } 247 248 249 const char * 250 BCountry::MonGrouping() const 251 { 252 return fStrings[B_MON_GROUPING]; 253 } 254 255 256 int32 257 BCountry::MonFracDigits() const 258 { 259 return 2; 260 } 261 262