haiku/headers/os/locale/Format.h
Adrien Destugues 5d5ec05b1d B*Format: make immutable and remove locking
The language and formatting conventions can now only be set when
creating the objects. This removed the needs for locking them when
formatting to avoid some other thread changing the format while it's
being used.

Adjust tests and DeskBar TimeView to the API changes.
2014-10-27 14:08:42 +01:00

70 lines
1.4 KiB
C++

/*
* Copyright 2003-2010, Haiku, Inc.
* Distributed under the terms of the MIT Licence.
*/
#ifndef _B_FORMAT_H_
#define _B_FORMAT_H_
#include <FormatParameters.h>
#include <FormattingConventions.h>
#include <Locker.h>
#include <Language.h>
#include <SupportDefs.h>
// types of fields contained in formatted strings
enum {
// number format fields
B_CURRENCY_FIELD,
B_DECIMAL_SEPARATOR_FIELD,
B_EXPONENT_FIELD,
B_EXPONENT_SIGN_FIELD,
B_EXPONENT_SYMBOL_FIELD,
B_FRACTION_FIELD,
B_GROUPING_SEPARATOR_FIELD,
B_INTEGER_FIELD,
B_PERCENT_FIELD,
B_PERMILLE_FIELD,
B_SIGN_FIELD,
// date format fields
// TODO: ...
};
// structure filled in while formatting
struct format_field_position {
uint32 field_type;
int32 start;
int32 length;
};
class BLocale;
class BFormat {
public:
status_t InitCheck() const;
protected:
BFormat(const BLocale* locale = NULL);
BFormat(const BLanguage& language,
const BFormattingConventions& conventions);
BFormat(const BFormat& other);
virtual ~BFormat();
private:
BFormat& operator=(const BFormat& other);
status_t _Initialize(const BLocale& locale);
status_t _Initialize(const BLanguage& language,
const BFormattingConventions& conventions);
protected:
BFormattingConventions fConventions;
BLanguage fLanguage;
status_t fInitStatus;
};
#endif // _B_FORMAT_H_