Flutter Engine
base Namespace Reference

Namespaces

 internal
 
 testing
 
 win
 

Classes

class  AutoReset
 
struct  DefaultSingletonTraits
 
class  LogMessage
 
class  LogMessageVoidify
 
class  NoDestructor
 
class  scoped_nsobject
 
class  scoped_nsobject< id >
 
class  scoped_nsobject< NSAutoreleasePool >
 
class  scoped_nsprotocol
 
class  SimpleToken
 

Typedefs

using SizeT = StrictNumeric< size_t >
 

Functions

template<class T , class Allocator , class Predicate >
size_t EraseIf (std::vector< T, Allocator > &container, Predicate pred)
 
template<typename Container , typename Value >
bool Contains (const Container &container, const Value &value)
 
template<typename T >
bool Contains (const std::vector< T > &container, const T &value)
 
void KillProcess ()
 
template<class T >
constexpr const T & ClampToRange (const T &value, const T &min, const T &max)
 
template<typename T >
constexpr bool IsApproximatelyEqual (T lhs, T rhs, T tolerance)
 
template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst ClampFloor (Src value)
 
template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst ClampCeil (Src value)
 
template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst ClampRound (Src value)
 
template<class C >
void swap (scoped_nsprotocol< C > &p1, scoped_nsprotocol< C > &p2)
 
template<class C >
bool operator== (C p1, const scoped_nsprotocol< C > &p2)
 
template<class C >
bool operator!= (C p1, const scoped_nsprotocol< C > &p2)
 
std::ostream & operator<< (std::ostream &out, const SimpleToken &token)
 
std::optional< base::SimpleTokenValueToSimpleToken (std::string str)
 
std::string SimpleTokenToValue (const SimpleToken &token)
 
size_t SimpleTokenHash (const SimpleToken &SimpleToken)
 
std::u16string ASCIIToUTF16 (std::string src)
 
std::u16string UTF8ToUTF16 (std::string src)
 
std::string UTF16ToUTF8 (std::u16string src)
 
std::u16string WideToUTF16 (const std::wstring &src)
 
std::wstring UTF16ToWide (const std::u16string &src)
 
std::u16string NumberToString16 (float number)
 
std::u16string NumberToString16 (int32_t number)
 
std::u16string NumberToString16 (unsigned int number)
 
std::u16string NumberToString16 (double number)
 
std::string NumberToString (int32_t number)
 
std::string NumberToString (unsigned int number)
 
std::string NumberToString (float number)
 
std::string NumberToString (double number)
 
std::string JoinString (std::vector< std::string > tokens, std::string delimiter)
 
std::u16string JoinString (std::vector< std::u16string > tokens, std::u16string delimiter)
 
void ReplaceChars (std::string in, std::string from, std::string to, std::string *out)
 
void ReplaceChars (std::u16string in, std::u16string from, std::u16string to, std::u16string *out)
 
const std::string & EmptyString ()
 
std::string ToUpperASCII (std::string str)
 
std::string ToLowerASCII (std::string str)
 
bool LowerCaseEqualsASCII (std::string a, std::string b)
 
bool ContainsOnlyChars (std::u16string str, char16_t ch)
 
template<typename... Args>
std::string StringPrintf (const std::string &format, Args... args)
 
 TEST (StringUtilsTest, StringPrintfEmpty)
 
 TEST (StringUtilsTest, StringPrintfMisc)
 
 TEST (StringUtilsTest, StringPrintfErrno)
 
 TEST (StringUtilsTest, canASCIIToUTF16)
 
 TEST (StringUtilsTest, canUTF8ToUTF16)
 
 TEST (StringUtilsTest, canUTF16ToUTF8)
 
 TEST (StringUtilsTest, canNumberToString16)
 
 TEST (StringUtilsTest, numberToStringSimplifiesOutput)
 

Variables

constexpr double kPiDouble = 3.14159265358979323846
 
constexpr float kPiFloat = 3.14159265358979323846f
 
constexpr double kMeanGravityDouble = 9.80665
 
constexpr float kMeanGravityFloat = 9.80665f
 
constexpr size_t kRandomTokenLength = 10
 
constexpr char16_t kWhitespaceUTF16 = u' '
 

Typedef Documentation

◆ SizeT

using base::SizeT = typedef StrictNumeric<size_t>

Definition at line 357 of file safe_conversions.h.

Function Documentation

◆ ASCIIToUTF16()

◆ ClampCeil()

template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst base::ClampCeil ( Src  value)

Definition at line 373 of file safe_conversions.h.

References base::internal::saturated_cast(), and value.

Referenced by gfx::ScaleToEnclosingRectSafe(), gfx::ToCeiledPoint(), gfx::ToCeiledSize(), gfx::ToCeiledVector2d(), gfx::ToEnclosedRect(), and gfx::ToEnclosingRect().

373  {
374  return saturated_cast<Dst>(std::ceil(value));
375 }
uint8_t value
constexpr Dst saturated_cast(Src value)

◆ ClampFloor()

template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst base::ClampFloor ( Src  value)

Definition at line 366 of file safe_conversions.h.

References value.

Referenced by gfx::ScaleToEnclosingRectSafe(), gfx::ToEnclosedRect(), gfx::ToEnclosingRect(), gfx::ToFlooredPoint(), gfx::ToFlooredRectDeprecated(), gfx::ToFlooredSize(), and gfx::ToFlooredVector2d().

366  {
367  return saturated_cast<Dst>(std::floor(value));
368 }
uint8_t value
constexpr Dst saturated_cast(Src value)

◆ ClampRound()

template<typename Dst = int, typename Src , typename = std::enable_if_t<std::is_integral<Dst>::value && std::is_floating_point<Src>::value>>
Dst base::ClampRound ( Src  value)

Definition at line 380 of file safe_conversions.h.

References base::internal::saturated_cast().

Referenced by gfx::IsNearestRectWithinDistance(), gfx::ToNearestRect(), gfx::ToRoundedPoint(), gfx::ToRoundedRect(), gfx::ToRoundedSize(), and gfx::ToRoundedVector2d().

380  {
381  const Src rounded =
382  (value >= 0.0f) ? std::floor(value + 0.5f) : std::ceil(value - 0.5f);
383  return saturated_cast<Dst>(rounded);
384 }
uint8_t value
constexpr Dst saturated_cast(Src value)

◆ ClampToRange()

template<class T >
constexpr const T& base::ClampToRange ( const T &  value,
const T &  min,
const T &  max 
)

Definition at line 15 of file ranges.h.

Referenced by ui::TestAXNodeWrapper::AccessibilityPerformAction().

15  {
16  return std::min(std::max(value, min), max);
17 }
uint8_t value

◆ Contains() [1/2]

◆ Contains() [2/2]

template<typename T >
bool base::Contains ( const std::vector< T > &  container,
const T &  value 
)

Definition at line 27 of file container_utils.h.

References value.

27  {
28  return std::find(container.begin(), container.end(), value) !=
29  container.end();
30 }
uint8_t value

◆ ContainsOnlyChars()

bool base::ContainsOnlyChars ( std::u16string  str,
char16_t  ch 
)

Definition at line 204 of file string_utils.cc.

Referenced by ui::AXNodePosition::IsInWhiteSpace(), and StringPrintf().

204  {
205  return std::find_if(str.begin(), str.end(),
206  [ch](char16_t c) { return c != ch; }) == str.end();
207 }

◆ EmptyString()

◆ EraseIf()

template<class T , class Allocator , class Predicate >
size_t base::EraseIf ( std::vector< T, Allocator > &  container,
Predicate  pred 
)

Definition at line 14 of file container_utils.h.

Referenced by ui::AXNodeData::RemoveBoolAttribute(), ui::AXNodeData::RemoveFloatAttribute(), ui::AXNodeData::RemoveIntAttribute(), ui::AXNodeData::RemoveIntListAttribute(), ui::AXNodeData::RemoveStringAttribute(), and ui::AXNodeData::RemoveStringListAttribute().

14  {
15  auto it = std::remove_if(container.begin(), container.end(), pred);
16  size_t removed = std::distance(it, container.end());
17  container.erase(it, container.end());
18  return removed;
19 }

◆ IsApproximatelyEqual()

template<typename T >
constexpr bool base::IsApproximatelyEqual ( lhs,
rhs,
tolerance 
)

Definition at line 20 of file ranges.h.

References value.

20  {
21  static_assert(std::is_arithmetic<T>::value, "Argument must be arithmetic");
22  return std::abs(rhs - lhs) <= tolerance;
23 }
uint8_t value

◆ JoinString() [1/2]

std::string base::JoinString ( std::vector< std::string >  tokens,
std::string  delimiter 
)

Definition at line 128 of file string_utils.cc.

Referenced by ui::AXPlatformNodeBase::SanitizeTextAttributeValue(), StringPrintf(), ui::AXMode::ToString(), and ui::AXNodeData::ToString().

128  {
129  std::ostringstream imploded;
130  for (size_t i = 0; i < tokens.size(); i++) {
131  if (i == tokens.size() - 1) {
132  imploded << tokens[i];
133  } else {
134  imploded << tokens[i] << delimiter;
135  }
136  }
137  return imploded.str();
138 }

◆ JoinString() [2/2]

std::u16string base::JoinString ( std::vector< std::u16string >  tokens,
std::u16string  delimiter 
)

Definition at line 140 of file string_utils.cc.

References result.

141  {
142  std::u16string result;
143  for (size_t i = 0; i < tokens.size(); i++) {
144  if (i == tokens.size() - 1) {
145  result.append(tokens[i]);
146  } else {
147  result.append(tokens[i]);
148  result.append(delimiter);
149  }
150  }
151  return result;
152 }
GAsyncResult * result

◆ KillProcess()

void base::KillProcess ( )

◆ LowerCaseEqualsASCII()

bool base::LowerCaseEqualsASCII ( std::string  a,
std::string  b 
)

Definition at line 199 of file string_utils.cc.

References ToLowerASCII().

Referenced by ui::AXNodeData::GetHtmlAttribute(), and StringPrintf().

199  {
200  std::string lower_a = ToLowerASCII(a);
201  return lower_a.compare(ToLowerASCII(b)) == 0;
202 }
std::string ToLowerASCII(std::string str)

◆ NumberToString() [1/4]

◆ NumberToString() [2/4]

std::string base::NumberToString ( unsigned int  number)

Definition at line 116 of file string_utils.cc.

116  {
117  return std::to_string(number);
118 }

◆ NumberToString() [3/4]

std::string base::NumberToString ( float  number)

Definition at line 120 of file string_utils.cc.

120  {
121  return NumberToStringImpl(number, true);
122 }

◆ NumberToString() [4/4]

std::string base::NumberToString ( double  number)

Definition at line 124 of file string_utils.cc.

124  {
125  return NumberToStringImpl(number, false);
126 }

◆ NumberToString16() [1/4]

std::u16string base::NumberToString16 ( float  number)

Definition at line 96 of file string_utils.cc.

References ASCIIToUTF16(), and NumberToString().

Referenced by ui::AXPlatformNodeBase::GetRangeValueText(), StringPrintf(), TEST(), and ui::TEST_F().

96  {
97  return ASCIIToUTF16(NumberToString(number));
98 }
std::string NumberToString(double number)
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:66

◆ NumberToString16() [2/4]

std::u16string base::NumberToString16 ( int32_t  number)

Definition at line 100 of file string_utils.cc.

References ASCIIToUTF16(), and NumberToString().

100  {
101  return ASCIIToUTF16(NumberToString(number));
102 }
std::string NumberToString(double number)
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:66

◆ NumberToString16() [3/4]

std::u16string base::NumberToString16 ( unsigned int  number)

Definition at line 104 of file string_utils.cc.

References ASCIIToUTF16(), and NumberToString().

104  {
105  return ASCIIToUTF16(NumberToString(number));
106 }
std::string NumberToString(double number)
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:66

◆ NumberToString16() [4/4]

std::u16string base::NumberToString16 ( double  number)

Definition at line 108 of file string_utils.cc.

References ASCIIToUTF16(), and NumberToString().

108  {
109  return ASCIIToUTF16(NumberToString(number));
110 }
std::string NumberToString(double number)
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:66

◆ operator!=()

template<class C >
bool base::operator!= ( p1,
const scoped_nsprotocol< C > &  p2 
)

Definition at line 107 of file scoped_nsobject.h.

References base::scoped_nsprotocol< NST >::get().

Referenced by base::win::ScopedBstr::Get(), and base::win::ScopedSafearray::Get().

107  {
108  return p1 != p2.get();
109 }

◆ operator<<()

std::ostream & base::operator<< ( std::ostream &  out,
const SimpleToken token 
)

Definition at line 31 of file simple_token.cc.

References base::SimpleToken::ToString().

Referenced by base::SimpleToken::operator!=().

31  {
32  return out << "(" << token.ToString() << ")";
33 }

◆ operator==()

template<class C >
bool base::operator== ( p1,
const scoped_nsprotocol< C > &  p2 
)

Definition at line 102 of file scoped_nsobject.h.

References base::scoped_nsprotocol< NST >::get().

Referenced by base::win::ScopedBstr::Get(), and base::win::ScopedSafearray::Get().

102  {
103  return p1 == p2.get();
104 }

◆ ReplaceChars() [1/2]

void base::ReplaceChars ( std::string  in,
std::string  from,
std::string  to,
std::string *  out 
)

Definition at line 154 of file string_utils.cc.

Referenced by ui::AXPlatformNodeBase::SanitizeStringAttribute(), and StringPrintf().

157  {
158  size_t pos = in.find(from);
159  while (pos != std::string::npos) {
160  in.replace(pos, from.size(), to);
161  pos = in.find(from, pos + to.size());
162  }
163  *out = in;
164 }

◆ ReplaceChars() [2/2]

void base::ReplaceChars ( std::u16string  in,
std::u16string  from,
std::u16string  to,
std::u16string *  out 
)

Definition at line 166 of file string_utils.cc.

169  {
170  size_t pos = in.find(from);
171  while (pos != std::u16string::npos) {
172  in.replace(pos, from.size(), to);
173  pos = in.find(from, pos + to.size());
174  }
175  *out = in;
176 }

◆ SimpleTokenHash()

size_t base::SimpleTokenHash ( const SimpleToken SimpleToken)

Definition at line 43 of file simple_token.cc.

References base::SimpleToken::ToString().

Referenced by base::SimpleToken::operator!=(), and ui::AXTreeIDHash::operator()().

43  {
44  return std::hash<std::string>()(SimpleToken.ToString());
45 }

◆ SimpleTokenToValue()

std::string base::SimpleTokenToValue ( const SimpleToken token)

Definition at line 39 of file simple_token.cc.

References base::SimpleToken::ToString().

Referenced by base::SimpleToken::operator!=(), and ui::AXTreeID::ToString().

39  {
40  return token.ToString();
41 }

◆ StringPrintf()

template<typename... Args>
std::string base::StringPrintf ( const std::string &  format,
Args...  args 
)

Definition at line 18 of file string_utils.h.

References args, ASCIIToUTF16(), ContainsOnlyChars(), EmptyString(), JoinString(), LowerCaseEqualsASCII(), NumberToString(), NumberToString16(), ReplaceChars(), fml::size(), ToLowerASCII(), ToUpperASCII(), UTF16ToUTF8(), UTF16ToWide(), UTF8ToUTF16(), and WideToUTF16().

Referenced by TEST(), gfx::SizeF::ToString(), gfx::Vector2d::ToString(), gfx::Vector2dF::ToString(), gfx::Size::ToString(), gfx::Transform::ToString(), gfx::PointF::ToString(), gfx::InsetsF::ToString(), gfx::Point::ToString(), gfx::Range::ToString(), gfx::Insets::ToString(), gfx::RectF::ToString(), gfx::Rect::ToString(), and ui::AXNodeData::ToString().

18  {
19  // Calculate the buffer size.
20  int size = snprintf(nullptr, 0, format.c_str(), args...) + 1;
21  std::unique_ptr<char[]> buf(new char[size]);
22  snprintf(buf.get(), size, format.c_str(), args...);
23  return std::string(buf.get(), buf.get() + size - 1);
24 }
G_BEGIN_DECLS FlValue * args
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
uint32_t uint32_t * format

◆ swap()

template<class C >
void base::swap ( scoped_nsprotocol< C > &  p1,
scoped_nsprotocol< C > &  p2 
)

Definition at line 97 of file scoped_nsobject.h.

References base::scoped_nsprotocol< NST >::swap().

97  {
98  p1.swap(p2);
99 }

◆ TEST() [1/8]

base::TEST ( StringUtilsTest  ,
StringPrintfEmpty   
)

Definition at line 16 of file string_utils_unittest.cc.

References StringPrintf().

16  {
17  EXPECT_EQ("", base::StringPrintf("%s", ""));
18 }
std::string StringPrintf(const std::string &format, Args... args)
Definition: string_utils.h:18

◆ TEST() [2/8]

base::TEST ( StringUtilsTest  ,
StringPrintfMisc   
)

Definition at line 20 of file string_utils_unittest.cc.

References StringPrintf().

20  {
21  EXPECT_EQ("123hello w", StringPrintf("%3d%2s %1c", 123, "hello", 'w'));
22 }
std::string StringPrintf(const std::string &format, Args... args)
Definition: string_utils.h:18

◆ TEST() [3/8]

base::TEST ( StringUtilsTest  ,
StringPrintfErrno   
)

Definition at line 24 of file string_utils_unittest.cc.

References StringPrintf().

24  {
25  errno = 1;
26  EXPECT_EQ("", StringPrintf("%s", ""));
27  EXPECT_EQ(1, errno);
28 }
std::string StringPrintf(const std::string &format, Args... args)
Definition: string_utils.h:18

◆ TEST() [4/8]

base::TEST ( StringUtilsTest  ,
canASCIIToUTF16   
)

Definition at line 30 of file string_utils_unittest.cc.

References ASCIIToUTF16().

30  {
31  std::string ascii = "abcdefg";
32  EXPECT_EQ(ASCIIToUTF16(ascii).compare(u"abcdefg"), 0);
33 }
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:66

◆ TEST() [5/8]

base::TEST ( StringUtilsTest  ,
canUTF8ToUTF16   
)

Definition at line 35 of file string_utils_unittest.cc.

References UTF8ToUTF16().

35  {
36  std::string utf8 = "äåè";
37  EXPECT_EQ(UTF8ToUTF16(utf8).compare(u"äåè"), 0);
38 }
std::u16string UTF8ToUTF16(std::string src)
Definition: string_utils.cc:70

◆ TEST() [6/8]

base::TEST ( StringUtilsTest  ,
canUTF16ToUTF8   
)

Definition at line 40 of file string_utils_unittest.cc.

References UTF16ToUTF8().

40  {
41  std::u16string utf16 = u"äåè";
42  EXPECT_EQ(UTF16ToUTF8(utf16).compare("äåè"), 0);
43 }
std::string UTF16ToUTF8(std::u16string src)
Definition: string_utils.cc:79

◆ TEST() [7/8]

base::TEST ( StringUtilsTest  ,
canNumberToString16   
)

Definition at line 45 of file string_utils_unittest.cc.

References NumberToString16().

45  {
46  EXPECT_EQ(NumberToString16(1.123f), std::u16string(u"1.123"));
47 }
std::u16string NumberToString16(float number)
Definition: string_utils.cc:96

◆ TEST() [8/8]

base::TEST ( StringUtilsTest  ,
numberToStringSimplifiesOutput   
)

Definition at line 49 of file string_utils_unittest.cc.

References NumberToString().

49  {
50  EXPECT_STREQ(NumberToString(0.0).c_str(), "0");
51  EXPECT_STREQ(NumberToString(0.0f).c_str(), "0");
52  EXPECT_STREQ(NumberToString(1.123).c_str(), "1.123");
53  EXPECT_STREQ(NumberToString(1.123f).c_str(), "1.123");
54  EXPECT_STREQ(NumberToString(-1.123).c_str(), "-1.123");
55  EXPECT_STREQ(NumberToString(-1.123f).c_str(), "-1.123");
56  EXPECT_STREQ(NumberToString(1.00001).c_str(), "1.00001");
57  EXPECT_STREQ(NumberToString(1.00001f).c_str(), "1.00001");
58  EXPECT_STREQ(NumberToString(1000.000001).c_str(), "1000.000001");
59  EXPECT_STREQ(NumberToString(10.00001f).c_str(), "10.00001");
60  EXPECT_STREQ(NumberToString(1.0 + 1e-8).c_str(), "1.00000001");
61  EXPECT_STREQ(NumberToString(1.0f + 1e-8f).c_str(), "1");
62  EXPECT_STREQ(NumberToString(1e-6).c_str(), "0.000001");
63  EXPECT_STREQ(NumberToString(1e-6f).c_str(), "0.000001");
64  EXPECT_STREQ(NumberToString(1e-8).c_str(), "1e-8");
65  EXPECT_STREQ(NumberToString(1e-8f).c_str(), "1e-8");
66  EXPECT_STREQ(NumberToString(100.0).c_str(), "100");
67  EXPECT_STREQ(NumberToString(100.0f).c_str(), "100");
68  EXPECT_STREQ(NumberToString(-1.0 - 1e-7).c_str(), "-1.0000001");
69  EXPECT_STREQ(NumberToString(-1.0f - 1e-7f).c_str(), "-1.0000001");
70  EXPECT_STREQ(NumberToString(0.00000012345678).c_str(), "1.2345678e-7");
71  // Difference in output is due to differences in double and float precision.
72  EXPECT_STREQ(NumberToString(0.00000012345678f).c_str(), "1.2345679e-7");
73  EXPECT_STREQ(NumberToString(-0.00000012345678).c_str(), "-1.2345678e-7");
74  // Difference in output is due to differences in double and float precision.
75  EXPECT_STREQ(NumberToString(-0.00000012345678f).c_str(), "-1.2345679e-7");
76  EXPECT_STREQ(NumberToString(static_cast<unsigned int>(11)).c_str(), "11");
77  EXPECT_STREQ(NumberToString(static_cast<int32_t>(-23)).c_str(), "-23");
78 }
std::string NumberToString(int32_t number)

◆ ToLowerASCII()

std::string base::ToLowerASCII ( std::string  str)

Definition at line 191 of file string_utils.cc.

Referenced by LowerCaseEqualsASCII(), and StringPrintf().

191  {
192  std::string ret;
193  ret.reserve(str.size());
194  for (size_t i = 0; i < str.size(); i++)
195  ret.push_back(std::tolower(str[i]));
196  return ret;
197 }

◆ ToUpperASCII()

std::string base::ToUpperASCII ( std::string  str)

Definition at line 183 of file string_utils.cc.

Referenced by StringPrintf().

183  {
184  std::string ret;
185  ret.reserve(str.size());
186  for (size_t i = 0; i < str.size(); i++)
187  ret.push_back(std::toupper(str[i]));
188  return ret;
189 }

◆ UTF16ToUTF8()

std::string base::UTF16ToUTF8 ( std::u16string  src)

Definition at line 79 of file string_utils.cc.

References UTF16ToWide(), and base::win::Utf8FromUtf16().

Referenced by ui::AXPlatformNodeMac::AnnounceText(), ui::AXPlatformNodeBase::ComputeAttributes(), AXPlatformNodeCocoa::detach, ui::AXNodeData::SetDescription(), ui::AXNodeData::SetName(), ui::AXNodeData::SetValue(), StringPrintf(), TEST(), and ui::AXPosition< AXNodePosition, AXNode >::ToString().

79  {
80 #if defined(_WIN32)
81  return win::Utf8FromUtf16(UTF16ToWide(src));
82 #else
83  std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
84  return convert.to_bytes(src);
85 #endif
86 }
std::string Utf8FromUtf16(const std::wstring_view utf16_string)
std::wstring UTF16ToWide(const std::u16string &src)
Definition: string_utils.cc:92

◆ UTF16ToWide()

std::wstring base::UTF16ToWide ( const std::u16string &  src)

Definition at line 92 of file string_utils.cc.

Referenced by StringPrintf(), and UTF16ToUTF8().

92  {
93  return std::wstring(src.begin(), src.end());
94 }

◆ UTF8ToUTF16()

std::u16string base::UTF8ToUTF16 ( std::string  src)

Definition at line 70 of file string_utils.cc.

References base::win::Utf16FromUtf8(), and WideToUTF16().

Referenced by ui::AXNodeData::GetHtmlAttribute(), ui::AXPlatformNodeBase::GetInheritedString16Attribute(), ui::AXNode::GetInheritedString16Attribute(), ui::AXPlatformNodeBase::GetNameAsString16(), ui::AXNodeData::GetString16Attribute(), ui::AXPlatformNodeBase::GetValue(), StringPrintf(), TEST(), and ui::TEST().

70  {
71 #if defined(_WIN32)
72  return WideToUTF16(win::Utf16FromUtf8(src));
73 #else
74  std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
75  return convert.from_bytes(src);
76 #endif
77 }
std::wstring Utf16FromUtf8(const std::string_view utf8_string)
std::u16string WideToUTF16(const std::wstring &src)
Definition: string_utils.cc:88

◆ ValueToSimpleToken()

std::optional< base::SimpleToken > base::ValueToSimpleToken ( std::string  str)

Definition at line 35 of file simple_token.cc.

Referenced by ui::AXTreeID::AXTreeID(), and base::SimpleToken::operator!=().

35  {
36  return std::make_optional<base::SimpleToken>(str);
37 }

◆ WideToUTF16()

std::u16string base::WideToUTF16 ( const std::wstring &  src)

Definition at line 88 of file string_utils.cc.

Referenced by StringPrintf(), ui::TEST_F(), and UTF8ToUTF16().

88  {
89  return std::u16string(src.begin(), src.end());
90 }

Variable Documentation

◆ kMeanGravityDouble

constexpr double base::kMeanGravityDouble = 9.80665

Definition at line 14 of file math_constants.h.

◆ kMeanGravityFloat

constexpr float base::kMeanGravityFloat = 9.80665f

Definition at line 15 of file math_constants.h.

◆ kPiDouble

constexpr double base::kPiDouble = 3.14159265358979323846

Definition at line 10 of file math_constants.h.

◆ kPiFloat

constexpr float base::kPiFloat = 3.14159265358979323846f

Definition at line 11 of file math_constants.h.

◆ kRandomTokenLength

constexpr size_t base::kRandomTokenLength = 10

Definition at line 12 of file simple_token.cc.

Referenced by base::SimpleToken::Create().

◆ kWhitespaceUTF16

constexpr char16_t base::kWhitespaceUTF16 = u' '

Definition at line 14 of file string_utils.h.

Referenced by ui::AXNodePosition::IsInWhiteSpace().