aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkString.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-01 15:44:08 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-01 15:44:08 +0000
commit8072e4fdc8261b1ca8937aa5c31db967280eae2a (patch)
tree321534079fe0b1c20bb8fd009ab8c7cff0304e8e /include/core/SkString.h
parentb652427197ddaac5d35010e1b199bcb431e656b7 (diff)
bump SkStrAppendScalar_MaxSize to 14 to accomodate the largest string now that
scalar->string uses %.8g. Floats have at most 8 significant digits, plus we add more space for sign, decimal point and exponent. add tests to check these limits. git-svn-id: http://skia.googlecode.com/svn/trunk@872 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkString.h')
-rw-r--r--include/core/SkString.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 4498bba768..5b41a78588 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -30,8 +30,21 @@ int SkStrStartsWithOneOf(const char string[], const char prefixes[]);
char* SkStrAppendS32(char buffer[], int32_t);
#define SkStrAppendS64_MaxSize 20
char* SkStrAppendS64(char buffer[], int64_t, int minDigits);
-#define SkStrAppendScalar_MaxSize 11
-char* SkStrAppendScalar(char buffer[], SkScalar);
+
+/**
+ * Floats have at most 8 significant digits, so we limit our %g to that.
+ * However, the total string could be 14 characters: -1.2345678e+38
+ */
+#define SkStrAppendScalar_MaxSize 14
+
+/**
+ * Write the scaler in decimal format into buffer, and return a pointer to
+ * the next char after the last one written. Note: a terminating 0 is not
+ * written into buffer, which must be at least SkStrAppendScalar_MaxSize.
+ * Thus if the caller wants to add a 0 at the end, buffer must be at least
+ * SkStrAppendScalar_MaxSize + 1 bytes large.
+ */
+char* SkStrAppendScalar(char buffer[], SkScalar);
/** \class SkString
@@ -127,7 +140,7 @@ public:
to never fail or throw.
*/
void swap(SkString& other);
-
+
private:
struct Rec {
public: