1c3ac87e8SOliver Tappe #include <Format.h> 2c3ac87e8SOliver Tappe 3a9faf943SOliver Tappe #include <new> 4a9faf943SOliver Tappe 544f11d09SAdrien Destugues #include <Autolock.h> 6a9faf943SOliver Tappe #include <Locale.h> 744f11d09SAdrien Destugues #include <LocaleRoster.h> 8a9faf943SOliver Tappe 9a9faf943SOliver Tappe BFormat(const BLocale * locale)10*5d5ec05bSAdrien DestuguesBFormat::BFormat(const BLocale* locale) 11c3ac87e8SOliver Tappe { 12*5d5ec05bSAdrien Destugues if (locale == NULL) 13*5d5ec05bSAdrien Destugues locale = BLocaleRoster::Default()->GetDefaultLocale(); 14*5d5ec05bSAdrien Destugues 15*5d5ec05bSAdrien Destugues if (locale == NULL) { 16*5d5ec05bSAdrien Destugues fInitStatus = B_BAD_DATA; 17*5d5ec05bSAdrien Destugues return; 18*5d5ec05bSAdrien Destugues } 19*5d5ec05bSAdrien Destugues 20*5d5ec05bSAdrien Destugues _Initialize(*locale); 21*5d5ec05bSAdrien Destugues } 22*5d5ec05bSAdrien Destugues 23*5d5ec05bSAdrien Destugues BFormat(const BLanguage & language,const BFormattingConventions & conventions)24*5d5ec05bSAdrien DestuguesBFormat::BFormat(const BLanguage& language, 25*5d5ec05bSAdrien Destugues const BFormattingConventions& conventions) 26*5d5ec05bSAdrien Destugues { 27*5d5ec05bSAdrien Destugues _Initialize(language, conventions); 28c3ac87e8SOliver Tappe } 29c3ac87e8SOliver Tappe 30a9faf943SOliver Tappe BFormat(const BFormat & other)31a9faf943SOliver TappeBFormat::BFormat(const BFormat &other) 32*5d5ec05bSAdrien Destugues : 33*5d5ec05bSAdrien Destugues fConventions(other.fConventions), 34*5d5ec05bSAdrien Destugues fLanguage(other.fLanguage), 35*5d5ec05bSAdrien Destugues fInitStatus(other.fInitStatus) 36a9faf943SOliver Tappe { 37a9faf943SOliver Tappe } 38a9faf943SOliver Tappe 39a9faf943SOliver Tappe ~BFormat()40c3ac87e8SOliver TappeBFormat::~BFormat() 41c3ac87e8SOliver Tappe { 42c3ac87e8SOliver Tappe } 43c3ac87e8SOliver Tappe 44a9faf943SOliver Tappe 45a9faf943SOliver Tappe status_t InitCheck() const46a9faf943SOliver TappeBFormat::InitCheck() const 47c3ac87e8SOliver Tappe { 48a9faf943SOliver Tappe return fInitStatus; 49c3ac87e8SOliver Tappe } 50c3ac87e8SOliver Tappe 51a9faf943SOliver Tappe 52a9faf943SOliver Tappe status_t _Initialize(const BLocale & locale)53*5d5ec05bSAdrien DestuguesBFormat::_Initialize(const BLocale& locale) 54a9faf943SOliver Tappe { 5544f11d09SAdrien Destugues BFormattingConventions conventions; 5644f11d09SAdrien Destugues BLanguage language; 5744f11d09SAdrien Destugues 5844f11d09SAdrien Destugues fInitStatus = locale.GetFormattingConventions(&conventions); 5944f11d09SAdrien Destugues if (fInitStatus != B_OK) 6044f11d09SAdrien Destugues return fInitStatus; 6144f11d09SAdrien Destugues 6244f11d09SAdrien Destugues fInitStatus = locale.GetLanguage(&language); 6344f11d09SAdrien Destugues if (fInitStatus != B_OK) 6444f11d09SAdrien Destugues return fInitStatus; 65*5d5ec05bSAdrien Destugues 66*5d5ec05bSAdrien Destugues return _Initialize(language, conventions); 67*5d5ec05bSAdrien Destugues } 68*5d5ec05bSAdrien Destugues 69*5d5ec05bSAdrien Destugues 70*5d5ec05bSAdrien Destugues status_t _Initialize(const BLanguage & language,const BFormattingConventions & conventions)71*5d5ec05bSAdrien DestuguesBFormat::_Initialize(const BLanguage& language, 72*5d5ec05bSAdrien Destugues const BFormattingConventions& conventions) 73*5d5ec05bSAdrien Destugues { 74*5d5ec05bSAdrien Destugues fConventions = conventions; 75*5d5ec05bSAdrien Destugues fLanguage = language; 76*5d5ec05bSAdrien Destugues fInitStatus = B_OK; 7744f11d09SAdrien Destugues return fInitStatus; 78a9faf943SOliver Tappe } 79