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 #if !UCONFIG_NO_FORMATTING 00009 #ifndef U_HIDE_DRAFT_API 00010 00011 #include "unicode/appendable.h" 00012 #include "unicode/fpositer.h" 00013 #include "unicode/unistr.h" 00014 #include "unicode/uformattedvalue.h" 00015 00016 U_NAMESPACE_BEGIN 00017 00040 class U_I18N_API ConstrainedFieldPosition : public UMemory { 00041 public: 00042 00050 ConstrainedFieldPosition(); 00051 00053 ~ConstrainedFieldPosition(); 00054 00063 void reset(); 00064 00087 void constrainCategory(int32_t category); 00088 00112 void constrainField(int32_t category, int32_t field); 00113 00123 inline int32_t getCategory() const { 00124 return fCategory; 00125 } 00126 00136 inline int32_t getField() const { 00137 return fField; 00138 } 00139 00148 inline int32_t getStart() const { 00149 return fStart; 00150 } 00151 00160 inline int32_t getLimit() const { 00161 return fLimit; 00162 } 00163 00168 00179 inline int64_t getInt64IterationContext() const { 00180 return fContext; 00181 } 00182 00191 void setInt64IterationContext(int64_t context); 00192 00203 UBool matchesField(int32_t category, int32_t field) const; 00204 00219 void setState( 00220 int32_t category, 00221 int32_t field, 00222 int32_t start, 00223 int32_t limit); 00224 00225 private: 00226 int64_t fContext = 0LL; 00227 int32_t fField = 0; 00228 int32_t fStart = 0; 00229 int32_t fLimit = 0; 00230 int32_t fCategory = UFIELD_CATEGORY_UNDEFINED; 00231 int8_t fConstraint = 0; 00232 }; 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 00313 U_NAMESPACE_END 00314 00315 #endif /* U_HIDE_DRAFT_API */ 00316 #endif /* #if !UCONFIG_NO_FORMATTING */ 00317 #endif // __FORMATTEDVALUE_H__
1.6.1