Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

format.h

Go to the documentation of this file.
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/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&); // Does nothing; for subclasses only
00243 
00247     Format& operator=(const Format&); // Does nothing; for subclasses
00248 
00249        
00257     inline void syntaxError(const UnicodeString& pattern,
00258                             int32_t pos,
00259                             UParseError& parseError){
00260         parseError.offset = pos;
00261         parseError.line=0;  // we are not using line number
00262         
00263         // for pre-context
00264         int32_t start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
00265                                                                  /* subtract 1 so that we have room for null*/));
00266         int32_t stop  = pos;
00267         pattern.extract(start,stop-start,parseError.preContext,0);
00268         //null terminate the buffer
00269         parseError.preContext[stop-start] = 0;
00270     
00271         //for post-context
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         //null terminate the buffer
00277         parseError.postContext[stop-start]= 0;
00278     }
00279 };
00280 
00281 U_NAMESPACE_END
00282 
00283 #endif // _FORMAT
00284 //eof

Generated on Thu Aug 15 14:13:25 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001