Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1294)

Unified Diff: source/i18n/unicode/scientificformathelper.h

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/unicode/reldatefmt.h ('k') | source/i18n/unicode/smpdtfmt.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/unicode/scientificformathelper.h
diff --git a/source/i18n/unicode/scientificformathelper.h b/source/i18n/unicode/scientificformathelper.h
new file mode 100644
index 0000000000000000000000000000000000000000..e5b53794e68b97f40b1cab8ac05a4435c417f369
--- /dev/null
+++ b/source/i18n/unicode/scientificformathelper.h
@@ -0,0 +1,139 @@
+/*
+**********************************************************************
+* Copyright (c) 2014, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+*/
+#ifndef SCIFORMATHELPER_H
+#define SCIFORMATHELPER_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#ifndef U_HIDE_DRAFT_API
+
+#include "unicode/unistr.h"
+
+/**
+ * \file
+ * \brief C++ API: Formatter for measure objects.
+ */
+
+U_NAMESPACE_BEGIN
+
+class DecimalFormatSymbols;
+class FieldPositionIterator;
+class DecimalFormatStaticSets;
+
+/**
+ * A helper class for formatting numbers in standard scientific notation
+ * instead of E notation.
+ *
+ * Sample code:
+ * <pre>
+ * UErrorCode status = U_ZERO_ERROR;
+ * DecimalFormat *decfmt = (DecimalFormat *)
+ * NumberFormat::createScientificInstance("en", status);
+ * UnicodeString appendTo;
+ * FieldPositionIterator fpositer;
+ * decfmt->format(1.23456e-78, appendTo, &fpositer, status);
+ * ScientificFormatHelper helper(*decfmt->getDecimalFormatSymbols(), status);
+ * UnicodeString result;
+ *
+ * // result = "1.23456x10<sup>-78</sup>"
+ * helper.insertMarkup(appendTo, fpositer, "<sup>", "</sup>", result, status));
+ * </pre>
+ *
+ * @see NumberFormat
+ * @draft ICU 54
+ */
+class U_I18N_API ScientificFormatHelper : public UObject {
+ public:
+ /**
+ * Constructor.
+ * @param symbols comes from DecimalFormat instance used for default
+ * scientific notation.
+ * @param status any error reported here.
+ * @draft ICU 54
+ */
+ ScientificFormatHelper(const DecimalFormatSymbols &symbols, UErrorCode& status);
+
+ /**
+ * Copy constructor.
+ * @draft ICU 54
+ */
+ ScientificFormatHelper(const ScientificFormatHelper &other);
+
+ /**
+ * Assignment operator.
+ * @draft ICU 54
+ */
+ ScientificFormatHelper &operator=(const ScientificFormatHelper &other);
+
+ /**
+ * Destructor.
+ * @draft ICU 54
+ */
+ virtual ~ScientificFormatHelper();
+
+ /**
+ * Formats standard scientific notation by surrounding exponent with
+ * html to make it superscript.
+ * @param s the original formatted scientific notation
+ * e.g "6.02e23". s is output from
+ * NumberFormat::createScientificInstance()->format().
+ * @param fpi the FieldPositionIterator from the format call.
+ * fpi is output from
+ * NumberFormat::createScientificInstance()->format().
+ * @param beginMarkup the start html for the exponent e.g "<sup>"
+ * @param endMarkup the end html for the exponent e.g "</sup>"
+ * @param result standard scientific notation appended here.
+ * @param status any error returned here. When status is set to a
+ * non-zero error, the value of result is unspecified,
+ * and client should fallback to using s for scientific
+ * notation.
+ * @return the value stored in result.
+ * @draft ICU 54
+ */
+ UnicodeString &insertMarkup(
+ const UnicodeString &s,
+ FieldPositionIterator &fpi,
+ const UnicodeString &beginMarkup,
+ const UnicodeString &endMarkup,
+ UnicodeString &result,
+ UErrorCode &status) const;
+
+ /**
+ * Formats standard scientific notation by using superscript unicode
+ * points 0..9.
+ * @param s the original formatted scientific notation
+ * e.g "6.02e23". s is output from
+ * NumberFormat::createScientificInstance()->format().
+ * @param fpi the FieldPositionIterator from the format call.
+ * fpi is output from
+ * NumberFormat::createScientificInstance()->format().
+ * @param result standard scientific notation appended here.
+ * @param status any error returned here. When status is set to a
+ * non-zero error, the value of result is unspecified,
+ * and client should fallback to using s for scientific
+ * notation.
+ * @return the value stored in result.
+ * @draft ICU 54
+ */
+ UnicodeString &toSuperscriptExponentDigits(
+ const UnicodeString &s,
+ FieldPositionIterator &fpi,
+ UnicodeString &result,
+ UErrorCode &status) const;
+ private:
+ UnicodeString fPreExponent;
+ const DecimalFormatStaticSets *fStaticSets;
+};
+
+U_NAMESPACE_END
+
+#endif /* U_HIDE_DRAFT_API */
+
+#endif /* !UCONFIG_NO_FORMATTING */
+#endif
« no previous file with comments | « source/i18n/unicode/reldatefmt.h ('k') | source/i18n/unicode/smpdtfmt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698