Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

format.h

00001 /* 00002 ******************************************************************************** 00003 * Copyright (C) {1997-1999}, International Business Machines Corporation and others. All Rights Reserved. 00004 ******************************************************************************** 00005 * 00006 * File FORMAT.H 00007 * 00008 * Modification History: 00009 * 00010 * Date Name Description 00011 * 02/19/97 aliu Converted from java. 00012 * 03/17/97 clhuang Updated per C++ implementation. 00013 * 03/27/97 helena Updated to pass the simple test after code review. 00014 ******************************************************************************** 00015 */ 00016 // ***************************************************************************** 00017 // This file was generated from the java source file Format.java 00018 // ***************************************************************************** 00019 00020 #ifndef FORMAT_H 00021 #define FORMAT_H 00022 00023 00024 #include "unicode/utypes.h" 00025 #include "unicode/unistr.h" 00026 #include "unicode/fmtable.h" 00027 #include "unicode/fieldpos.h" 00028 #include "unicode/parsepos.h" 00029 #include "unicode/parseerr.h" 00030 00031 U_NAMESPACE_BEGIN 00086 class U_I18N_API Format { 00087 public: 00088 00089 virtual ~Format(); 00090 00096 virtual UBool operator==(const Format& other) const = 0; 00097 00103 UBool operator!=(const Format& other) const { return !operator==(other); } 00104 00110 virtual Format* clone() const = 0; 00111 00122 UnicodeString& format(const Formattable& obj, 00123 UnicodeString& result, 00124 UErrorCode& status) const; 00125 00142 virtual UnicodeString& format(const Formattable& obj, 00143 UnicodeString& toAppendTo, 00144 FieldPosition& pos, 00145 UErrorCode& status) const = 0; 00146 00186 virtual void parseObject(const UnicodeString& source, 00187 Formattable& result, 00188 ParsePosition& parse_pos) const = 0; 00189 00202 void parseObject(const UnicodeString& source, 00203 Formattable& result, 00204 UErrorCode& status) const; 00205 00223 virtual UClassID getDynamicClassID() const = 0; 00224 00225 protected: 00230 Format(); 00231 00235 Format(const Format&); // Does nothing; for subclasses only 00236 00240 Format& operator=(const Format&); // Does nothing; for subclasses 00241 00242 00243 inline void syntaxError(const UnicodeString& pattern, 00244 int32_t pos, 00245 UParseError& parseError){ 00246 parseError.offset = pos; 00247 parseError.line=0; // we are not using line number 00248 00249 // for pre-context 00250 int32_t start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1 00251 /* subtract 1 so that we have room for null*/)); 00252 int32_t stop = pos; 00253 pattern.extract(start,stop-start,parseError.preContext,0); 00254 //null terminate the buffer 00255 parseError.preContext[stop-start] = 0; 00256 00257 //for post-context 00258 start = pos+1; 00259 stop = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) : 00260 pattern.length(); 00261 pattern.extract(start,stop-start,parseError.postContext,0); 00262 //null terminate the buffer 00263 parseError.postContext[stop-start]= 0; 00264 } 00265 }; 00266 00267 U_NAMESPACE_END 00268 00269 #endif // _FORMAT 00270 //eof

Generated on Fri Aug 13 09:53:50 2004 for ICU 2.1 by doxygen 1.3.7