ICU 73.2  73.2
formattedvalue.h
Go to the documentation of this file.
00001 // © 2018 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 
00004 #ifndef __FORMATTEDVALUE_H__
00005 #define __FORMATTEDVALUE_H__
00006 
00007 #include "unicode/utypes.h"
00008 
00009 #if U_SHOW_CPLUSPLUS_API
00010 
00011 #if !UCONFIG_NO_FORMATTING
00012 
00013 #include "unicode/appendable.h"
00014 #include "unicode/fpositer.h"
00015 #include "unicode/unistr.h"
00016 #include "unicode/uformattedvalue.h"
00017 
00018 U_NAMESPACE_BEGIN
00019 
00041 class U_I18N_API ConstrainedFieldPosition : public UMemory {
00042   public:
00043 
00051     ConstrainedFieldPosition();
00052 
00054     ~ConstrainedFieldPosition();
00055 
00064     void reset();
00065 
00088     void constrainCategory(int32_t category);
00089 
00113     void constrainField(int32_t category, int32_t field);
00114 
00124     inline int32_t getCategory() const {
00125         return fCategory;
00126     }
00127 
00137     inline int32_t getField() const {
00138         return fField;
00139     }
00140 
00149     inline int32_t getStart() const {
00150         return fStart;
00151     }
00152 
00161     inline int32_t getLimit() const {
00162         return fLimit;
00163     }
00164 
00169 
00180     inline int64_t getInt64IterationContext() const {
00181         return fContext;
00182     }
00183 
00192     void setInt64IterationContext(int64_t context);
00193 
00204     UBool matchesField(int32_t category, int32_t field) const;
00205 
00220     void setState(
00221         int32_t category,
00222         int32_t field,
00223         int32_t start,
00224         int32_t limit);
00225 
00226   private:
00227     int64_t fContext = 0LL;
00228     int32_t fField = 0;
00229     int32_t fStart = 0;
00230     int32_t fLimit = 0;
00231     int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
00232     int8_t fConstraint = 0;
00233 };
00234 
00241 class U_I18N_API FormattedValue /* not : public UObject because this is an interface/mixin class */ {
00242   public:
00244     virtual ~FormattedValue();
00245 
00256     virtual UnicodeString toString(UErrorCode& status) const = 0;
00257 
00272     virtual UnicodeString toTempString(UErrorCode& status) const = 0;
00273 
00285     virtual Appendable& appendTo(Appendable& appendable, UErrorCode& status) const = 0;
00286 
00309     virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0;
00310 };
00311 
00312 U_NAMESPACE_END
00313 
00314 #endif /* #if !UCONFIG_NO_FORMATTING */
00315 
00316 #endif /* U_SHOW_CPLUSPLUS_API */
00317 
00318 #endif // __FORMATTEDVALUE_H__