Coverage Report

Created: 2021-08-22 09:07

/src/skia/include/private/SkSLString.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2017 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 SKSL_STRING
9
#define SKSL_STRING
10
11
#include "include/core/SkStringView.h"
12
#include "include/private/SkSLDefines.h"
13
#include <cstring>
14
#include <stdarg.h>
15
#include <string>
16
17
#ifndef SKSL_STANDALONE
18
#include "include/core/SkString.h"
19
#endif
20
21
namespace SkSL {
22
23
class String;
24
25
class SK_API String : public std::string {
26
public:
27
    using std::string::string;
28
29
920k
    explicit String(std::string s) : INHERITED(std::move(s)) {}
30
7.12M
    explicit String(skstd::string_view s) : INHERITED(s.data(), s.length()) {}
31
    // TODO(johnstiles): add operator skstd::string_view
32
33
    static String printf(const char* fmt, ...) SK_PRINTF_LIKE(1, 2);
34
    void appendf(const char* fmt, ...) SK_PRINTF_LIKE(2, 3);
35
    void vappendf(const char* fmt, va_list va);
36
37
173k
    bool starts_with(const char prefix[]) const {
38
173k
        return skstd::string_view(data(), size()).starts_with(prefix);
39
173k
    }
40
0
    bool ends_with(const char suffix[]) const {
41
0
        return skstd::string_view(data(), size()).ends_with(suffix);
42
0
    }
43
44
    bool consumeSuffix(const char suffix[]);
45
46
    String operator+(const char* s) const;
47
    String operator+(const String& s) const;
48
    String operator+(skstd::string_view s) const;
49
    String& operator+=(char c);
50
    String& operator+=(const char* s);
51
    String& operator+=(const String& s);
52
    String& operator+=(skstd::string_view s);
53
    friend String operator+(const char* s1, const String& s2);
54
55
private:
56
    using INHERITED = std::string;
57
};
58
59
String operator+(skstd::string_view left, skstd::string_view right);
60
61
String to_string(double value);
62
String to_string(int32_t value);
63
String to_string(uint32_t value);
64
String to_string(int64_t value);
65
String to_string(uint64_t value);
66
67
bool stod(const skstd::string_view& s, SKSL_FLOAT* value);
68
bool stoi(const skstd::string_view& s, SKSL_INT* value);
69
70
} // namespace SkSL
71
72
namespace std {
73
    template<> struct hash<SkSL::String> {
74
3.83M
        size_t operator()(const SkSL::String& s) const {
75
3.83M
            return hash<std::string>{}(s);
76
3.83M
        }
77
    };
78
} // namespace std
79
80
#endif