Flutter Engine
The Flutter Engine
Macros | Functions
SkSLString.cpp File Reference
#include "src/base/SkStringView.h"
#include "src/sksl/SkSLDefines.h"
#include "src/sksl/SkSLString.h"
#include <cerrno>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <locale>
#include <memory>
#include <sstream>
#include <string>
#include <string_view>

Go to the source code of this file.

Macros

#define BUFFER_SIZE   256
 

Functions

template<typename RoundtripType , int kFullPrecision>
static std::string to_string_impl (RoundtripType value)
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   256

Function Documentation

◆ to_string_impl()

template<typename RoundtripType , int kFullPrecision>
static std::string to_string_impl ( RoundtripType  value)
static

Definition at line 23 of file SkSLString.cpp.

23 {
24 std::stringstream buffer;
25 buffer.imbue(std::locale::classic());
26 buffer.precision(7);
27 buffer << value;
28 std::string text = buffer.str();
29
30 double roundtripped;
31 buffer >> roundtripped;
32 if (value != (RoundtripType)roundtripped && std::isfinite(value)) {
33 buffer.str({});
34 buffer.clear();
35 buffer.precision(kFullPrecision);
36 buffer << value;
37 text = buffer.str();
38 SkASSERTF((buffer >> roundtripped, value == (RoundtripType)roundtripped),
39 "%.17g -> %s -> %.17g", value, text.c_str(), roundtripped);
40 }
41
42 // We need to emit a decimal point to distinguish floats from ints.
43 if (!skstd::contains(text, '.') && !skstd::contains(text, 'e')) {
44 text += ".0";
45 }
46
47 return text;
48}
#define SkASSERTF(cond, fmt,...)
Definition: SkAssert.h:117
uint8_t value
std::u16string text
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
constexpr bool contains(std::string_view str, std::string_view needle)
Definition: SkStringView.h:41
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003