Line data Source code
1 : /*
2 : * Copyright 2013 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef SkStringUtils_DEFINED
9 : #define SkStringUtils_DEFINED
10 :
11 : #include "SkScalar.h"
12 :
13 : class SkString;
14 :
15 : /**
16 : * Add 'flagStr' to 'string' and set 'needSeparator' to true only if 'flag' is
17 : * true. If 'needSeparator' is true append a '|' before 'flagStr'. This method
18 : * is used to streamline the creation of ASCII flag strings within the toString
19 : * methods.
20 : */
21 : void SkAddFlagToString(SkString* string, bool flag,
22 : const char* flagStr, bool* needSeparator);
23 :
24 :
25 : enum SkScalarAsStringType {
26 : kDec_SkScalarAsStringType,
27 : kHex_SkScalarAsStringType,
28 : };
29 :
30 : void SkAppendScalar(SkString*, SkScalar, SkScalarAsStringType);
31 :
32 0 : static inline void SkAppendScalarDec(SkString* str, SkScalar value) {
33 0 : SkAppendScalar(str, value, kDec_SkScalarAsStringType);
34 0 : }
35 :
36 : static inline void SkAppendScalarHex(SkString* str, SkScalar value) {
37 : SkAppendScalar(str, value, kHex_SkScalarAsStringType);
38 : }
39 :
40 : /** Indents every non-empty line of the string by tabCnt tabs */
41 : SkString SkTabString(const SkString& string, int tabCnt);
42 :
43 : #endif
|