blob: f2a1443ff454c4da459db45ab217e2b4277d9d0f [file] [log] [blame]
robertphillips@google.com4991b8f2013-01-28 20:21:59 +00001/*
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
Hal Canary6b20a552017-02-07 14:09:38 -050011#include "SkScalar.h"
12
robertphillips@google.com4991b8f2013-01-28 20:21:59 +000013class SkString;
14
15/**
skia.committer@gmail.comcdcb2ce2013-01-29 07:05:52 +000016 * 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
robertphillips@google.com4991b8f2013-01-28 20:21:59 +000019 * methods.
20 */
skia.committer@gmail.comcdcb2ce2013-01-29 07:05:52 +000021void SkAddFlagToString(SkString* string, bool flag,
robertphillips@google.com4991b8f2013-01-28 20:21:59 +000022 const char* flagStr, bool* needSeparator);
23
24
reede05fed02014-12-15 07:59:53 -080025enum SkScalarAsStringType {
26 kDec_SkScalarAsStringType,
27 kHex_SkScalarAsStringType,
28};
29
30void SkAppendScalar(SkString*, SkScalar, SkScalarAsStringType);
31
32static inline void SkAppendScalarDec(SkString* str, SkScalar value) {
33 SkAppendScalar(str, value, kDec_SkScalarAsStringType);
34}
35
36static inline void SkAppendScalarHex(SkString* str, SkScalar value) {
37 SkAppendScalar(str, value, kHex_SkScalarAsStringType);
38}
39
bsalomon53469832015-08-18 09:20:09 -070040/** Indents every non-empty line of the string by tabCnt tabs */
41SkString SkTabString(const SkString& string, int tabCnt);
42
Hal Canaryee08b4a2018-03-01 15:56:37 -050043SkString SkStringFromUTF16(const uint16_t* src, size_t count);
44
reed@google.com75847192013-01-28 20:53:22 +000045#endif