Audacity  3.0.3
Namespaces | Classes | Typedefs | Functions | Variables
audacity Namespace Reference

Namespaces

 anonymous_namespace{Uuid.cpp}
 
 network_manager
 
 sentry
 

Classes

struct  GoldenRatio
 
struct  GoldenRatio< 4 >
 
struct  GoldenRatio< 8 >
 
class  Uuid
 Utility class that generates and parses UUIDs. More...
 

Typedefs

using SystemTime = std::chrono::system_clock::time_point
 

Functions

std::string ToUTF8 (const std::wstring &wstr)
 
std::string ToUTF8 (const wchar_t *wstr)
 
std::string ToUTF8 (const wxString &wstr)
 
std::wstring ToWString (const std::string &str)
 
std::wstring ToWString (const char *str)
 
std::wstring ToWString (const wxString &str)
 
wxString ToWXString (const std::string &str)
 
wxString ToWXString (const std::wstring &str)
 
bool ParseRFC822Date (const std::string &dateString, SystemTime *time)
 
std::string SerializeRFC822Date (SystemTime timePoint)
 
uint8_t HexCharToNum (char c) noexcept
 
std::string UrlDecode (const std::string &url)
 
std::string UrlEncode (const std::string &url)
 

Variables

constexpr int BRACED_UUID_LENGTH = 38
 
constexpr int UUID_LENGTH = 36
 
constexpr int HEX_UUID_LENGTH = 32
 

Typedef Documentation

◆ SystemTime

using audacity::SystemTime = typedef std::chrono::system_clock::time_point

Definition at line 19 of file DateTimeConversions.h.

Function Documentation

◆ HexCharToNum()

uint8_t audacity::HexCharToNum ( char  c)
inlinenoexcept

Definition at line 20 of file HexHelpers.h.

21 {
22  assert (std::isxdigit (c) != 0);
23 
24  if ('0' <= c && c <= '9')
25  return c - '0';
26  else if ('A' <= c && c <= 'F')
27  return c - 'A' + 10;
28  else if ('a' <= c && c <= 'f')
29  return c - 'a' + 10;
30 
31  return 0;
32 }

Referenced by audacity::anonymous_namespace{Uuid.cpp}::readByte(), and UrlDecode().

Here is the caller graph for this function:

◆ ParseRFC822Date()

STRING_UTILS_API bool audacity::ParseRFC822Date ( const std::string &  dateString,
SystemTime time 
)

Definition at line 20 of file DateTimeConversions.cpp.

21 {
22  wxDateTime dt;
23  wxString::const_iterator end;
24 
25  if (!dt.ParseRfc822Date (dateString, &end))
26  return false;
27 
28  if (time != nullptr)
29  *time = std::chrono::system_clock::from_time_t (dt.GetTicks ());
30 
31  return true;
32 }

Referenced by audacity::network_manager::Cookie::Parse().

Here is the caller graph for this function:

◆ SerializeRFC822Date()

STRING_UTILS_API std::string audacity::SerializeRFC822Date ( SystemTime  timePoint)

Definition at line 34 of file DateTimeConversions.cpp.

35 {
36  const wxDateTime dt (
37  time_t (std::chrono::duration_cast<std::chrono::seconds> (
38  timePoint.time_since_epoch ()
39  ).count ()));
40 
41  return ToUTF8 (dt.Format("%a, %d %b %Y %H:%M:%S %z"));
42 }

References ToUTF8().

Referenced by audacity::network_manager::Cookie::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToUTF8() [1/3]

STRING_UTILS_API std::string audacity::ToUTF8 ( const std::wstring &  wstr)

Definition at line 19 of file CodeConversions.cpp.

20 {
21  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
22 }

Referenced by audacity::sentry::anonymous_namespace{SentryReport.cpp}::AddOSContext(), ErrorReportDialog::ErrorReportDialog(), ExportFFmpegOptions::ExportFFmpegOptions(), ExportFFmpegOptions::FetchCompatibleFormatList(), ExportFFmpeg::InitCodecs(), LV2Effect::LoadFactoryPreset(), ErrorReportDialog::OnSend(), and SerializeRFC822Date().

Here is the caller graph for this function:

◆ ToUTF8() [2/3]

STRING_UTILS_API std::string audacity::ToUTF8 ( const wchar_t *  wstr)

Definition at line 24 of file CodeConversions.cpp.

25 {
26  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().to_bytes (wstr);
27 }

◆ ToUTF8() [3/3]

STRING_UTILS_API std::string audacity::ToUTF8 ( const wxString &  wstr)

Definition at line 29 of file CodeConversions.cpp.

30 {
31  return wstr.ToStdString (wxGet_wxConvUTF8 ());
32 }

◆ ToWString() [1/3]

STRING_UTILS_API std::wstring audacity::ToWString ( const char *  str)

Definition at line 39 of file CodeConversions.cpp.

40 {
41  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
42 }

◆ ToWString() [2/3]

STRING_UTILS_API std::wstring audacity::ToWString ( const std::string &  str)

Definition at line 34 of file CodeConversions.cpp.

35 {
36  return std::wstring_convert<std::codecvt_utf8<wchar_t>> ().from_bytes (str);
37 }

Referenced by ProjectFileIO::ShowError().

Here is the caller graph for this function:

◆ ToWString() [3/3]

STRING_UTILS_API std::wstring audacity::ToWString ( const wxString &  str)

Definition at line 44 of file CodeConversions.cpp.

45 {
46  return str.ToStdWstring ();
47 }

◆ ToWXString() [1/2]

STRING_UTILS_API wxString audacity::ToWXString ( const std::string &  str)

Definition at line 49 of file CodeConversions.cpp.

50 {
51  return wxString::FromUTF8 (str);
52 }

Referenced by audacity::sentry::AnonymizedMessage::ToWXString().

Here is the caller graph for this function:

◆ ToWXString() [2/2]

STRING_UTILS_API wxString audacity::ToWXString ( const std::wstring &  str)

Definition at line 54 of file CodeConversions.cpp.

55 {
56  return wxString (str);
57 }

◆ UrlDecode()

STRING_UTILS_API std::string audacity::UrlDecode ( const std::string &  url)

Definition at line 18 of file UrlDecode.cpp.

19 {
20  std::string result;
21 
22  const size_t length = url.length ();
23 
24  for (auto it = url.begin (), end = url.end (); it != end; ++it)
25  {
26  const char c = *it;
27 
28  if (c != '%')
29  {
30  result.push_back (c);
31  }
32  else
33  {
34  if (++it == url.end ())
35  break; // Malformed input string
36 
37  const char c1 = *it;
38 
39  if (++it == url.end ())
40  break; // Malformed input string
41 
42  const char c2 = *it;
43 
44  result.push_back (HexCharToNum (c1) << 4 | HexCharToNum (c2));
45  }
46  }
47 
48  return result;
49 }

References HexCharToNum().

Here is the call graph for this function:

◆ UrlEncode()

STRING_UTILS_API std::string audacity::UrlEncode ( const std::string &  url)

Definition at line 16 of file UrlEncode.cpp.

17 {
18  std::string escaped;
19 
20  for (char c : url)
21  {
22  if (('0' <= c && c <= '9') ||
23  ('A' <= c && c <= 'Z') ||
24  ('a' <= c && c <= 'z') ||
25  (c == '~' || c == '-' || c == '_' || c == '.')
26  )
27  {
28  escaped.push_back (c);
29  }
30  else
31  {
32  static const char symbolLookup[] = "0123456789ABCDEF";
33 
34  escaped.push_back ('%');
35 
36  escaped.push_back (symbolLookup[(c & 0xF0) >> 4]);
37  escaped.push_back (symbolLookup[(c & 0x0F) >> 0]);
38  }
39  }
40 
41  return escaped;
42 }

Variable Documentation

◆ BRACED_UUID_LENGTH

constexpr int audacity::BRACED_UUID_LENGTH = 38
constexpr

Definition at line 37 of file Uuid.cpp.

Referenced by audacity::Uuid::FromString().

◆ HEX_UUID_LENGTH

constexpr int audacity::HEX_UUID_LENGTH = 32
constexpr

Definition at line 39 of file Uuid.cpp.

Referenced by audacity::Uuid::ToHexString().

◆ UUID_LENGTH

constexpr int audacity::UUID_LENGTH = 36
constexpr

Definition at line 38 of file Uuid.cpp.

Referenced by audacity::Uuid::FromString(), and audacity::Uuid::ToString().

audacity::HexCharToNum
uint8_t HexCharToNum(char c) noexcept
Definition: HexHelpers.h:20
audacity::ToUTF8
std::string ToUTF8(const std::wstring &wstr)
Definition: CodeConversions.cpp:19