00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FORMAT_H
00021 #define FORMAT_H
00022
00023
00024 #include "unicode/utypes.h"
00025 #include "unicode/uobject.h"
00026 #include "unicode/unistr.h"
00027 #include "unicode/fmtable.h"
00028 #include "unicode/fieldpos.h"
00029 #include "unicode/parsepos.h"
00030 #include "unicode/parseerr.h"
00031
00032 U_NAMESPACE_BEGIN
00087 class U_I18N_API Format : public UObject {
00088 public:
00089
00090 virtual ~Format();
00091
00100 virtual UBool operator==(const Format& other) const = 0;
00101
00109 UBool operator!=(const Format& other) const { return !operator==(other); }
00110
00117 virtual Format* clone() const = 0;
00118
00129 UnicodeString& format(const Formattable& obj,
00130 UnicodeString& result,
00131 UErrorCode& status) const;
00132
00149 virtual UnicodeString& format(const Formattable& obj,
00150 UnicodeString& toAppendTo,
00151 FieldPosition& pos,
00152 UErrorCode& status) const = 0;
00153
00193 virtual void parseObject(const UnicodeString& source,
00194 Formattable& result,
00195 ParsePosition& parse_pos) const = 0;
00196
00209 void parseObject(const UnicodeString& source,
00210 Formattable& result,
00211 UErrorCode& status) const;
00212
00230 virtual UClassID getDynamicClassID() const = 0;
00231
00232 protected:
00237 Format();
00238
00242 Format(const Format&);
00243
00247 Format& operator=(const Format&);
00248
00249
00257 inline void syntaxError(const UnicodeString& pattern,
00258 int32_t pos,
00259 UParseError& parseError){
00260 parseError.offset = pos;
00261 parseError.line=0;
00262
00263
00264 int32_t start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
00265 ));
00266 int32_t stop = pos;
00267 pattern.extract(start,stop-start,parseError.preContext,0);
00268
00269 parseError.preContext[stop-start] = 0;
00270
00271
00272 start = pos+1;
00273 stop = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) :
00274 pattern.length();
00275 pattern.extract(start,stop-start,parseError.postContext,0);
00276
00277 parseError.postContext[stop-start]= 0;
00278 }
00279 };
00280
00281 U_NAMESPACE_END
00282
00283 #endif // _FORMAT
00284