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 
00026 #if !UCONFIG_NO_FORMATTING
00027 
00028 #include "unicode/uobject.h"
00029 #include "unicode/unistr.h"
00030 #include "unicode/fmtable.h"
00031 #include "unicode/fieldpos.h"
00032 #include "unicode/parsepos.h"
00033 #include "unicode/parseerr.h" 
00034 
00035 U_NAMESPACE_BEGIN
00090 class U_I18N_API Format : public UObject {
00091 public:
00092 
00096     virtual ~Format();
00097 
00106     virtual UBool operator==(const Format& other) const = 0;
00107 
00115     UBool operator!=(const Format& other) const { return !operator==(other); }
00116 
00123     virtual Format* clone() const = 0;
00124 
00135     UnicodeString& format(const Formattable& obj,
00136                           UnicodeString& appendTo,
00137                           UErrorCode& status) const;
00138 
00155     virtual UnicodeString& format(const Formattable& obj,
00156                                   UnicodeString& appendTo,
00157                                   FieldPosition& pos,
00158                                   UErrorCode& status) const = 0;
00159 
00199     virtual void parseObject(const UnicodeString& source,
00200                              Formattable& result,
00201                              ParsePosition& parse_pos) const = 0;
00202 
00215     void parseObject(const UnicodeString& source,
00216                      Formattable& result,
00217                      UErrorCode& status) const;
00218 
00236     virtual UClassID getDynamicClassID() const = 0;
00237 
00238 protected:
00243     Format();
00244 
00248     Format(const Format&); // Does nothing; for subclasses only
00249 
00253     Format& operator=(const Format&); // Does nothing; for subclasses
00254 
00255        
00264     inline void syntaxError(const UnicodeString& pattern,
00265                             int32_t pos,
00266                             UParseError& parseError){
00267         parseError.offset = pos;
00268         parseError.line=0;  // we are not using line number
00269         
00270         // for pre-context
00271         int32_t start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
00272                                                                  /* subtract 1 so that we have room for null*/));
00273         int32_t stop  = pos;
00274         pattern.extract(start,stop-start,parseError.preContext,0);
00275         //null terminate the buffer
00276         parseError.preContext[stop-start] = 0;
00277     
00278         //for post-context
00279         start = pos+1;
00280         stop  = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) : 
00281                                                                 pattern.length();
00282         pattern.extract(start,stop-start,parseError.postContext,0);
00283         //null terminate the buffer
00284         parseError.postContext[stop-start]= 0;
00285     }
00286 };
00287 
00288 U_NAMESPACE_END
00289 
00290 #endif /* #if !UCONFIG_NO_FORMATTING */
00291 
00292 #endif // _FORMAT
00293 //eof

Generated on Wed Dec 18 16:49:35 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001