Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
audacity::sentry::AnonymizedMessage Class Referencefinal

A class, that stores anonymized message. More...

#include <AnonymizedMessage.h>

Collaboration diagram for audacity::sentry::AnonymizedMessage:
[legend]

Public Member Functions

 AnonymizedMessage ()=default
 Creates an empty message. More...
 
 AnonymizedMessage (const AnonymizedMessage &)=default
 
 AnonymizedMessage (AnonymizedMessage &&)=default
 
AnonymizedMessageoperator= (const AnonymizedMessage &)=default
 
AnonymizedMessageoperator= (AnonymizedMessage &&)=default
 
 AnonymizedMessage (std::string message)
 Creates a message from std::string. More...
 
 AnonymizedMessage (const std::wstring &message)
 Creates a message from std::wstring. More...
 
 AnonymizedMessage (const wxString &message)
 Creates a message from wxString. More...
 
 AnonymizedMessage (const char *message)
 Creates a message from const char*. More...
 
 AnonymizedMessage (const wchar_t *message)
 Creates a message from const wchar_t*. More...
 
bool Empty () const noexcept
 Checks, if the message is empty. More...
 
size_t Length () const noexcept
 Returns the length of the message. More...
 
const std::string & GetString () const noexcept
 Returns the UTF8 representation of the message. More...
 
wxString ToWXString () const noexcept
 Convert the message to wxString. More...
 
const char * c_str () const noexcept
 Checks, if the message is empty. More...
 
size_t length () const noexcept
 Returns the length of the message. More...
 

Private Member Functions

void CleanupPaths ()
 

Private Attributes

std::string mMessage
 

Detailed Description

A class, that stores anonymized message.

Input message is anonymized by looking for path-like patterns. Messages are stored in UTF8 format.

Definition at line 25 of file AnonymizedMessage.h.

Constructor & Destructor Documentation

◆ AnonymizedMessage() [1/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( )
default

Creates an empty message.

◆ AnonymizedMessage() [2/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( const AnonymizedMessage )
default

◆ AnonymizedMessage() [3/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( AnonymizedMessage &&  )
default

◆ AnonymizedMessage() [4/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( std::string  message)

Creates a message from std::string.

Definition at line 22 of file AnonymizedMessage.cpp.

23 : mMessage(std::move(message))
24{
26}

References CleanupPaths().

Here is the call graph for this function:

◆ AnonymizedMessage() [5/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( const std::wstring &  message)

Creates a message from std::wstring.

Definition at line 28 of file AnonymizedMessage.cpp.

29 : AnonymizedMessage(ToUTF8(message))
30{
31}
AnonymizedMessage()=default
Creates an empty message.
std::string ToUTF8(const std::wstring &wstr)

◆ AnonymizedMessage() [6/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( const wxString &  message)

Creates a message from wxString.

Definition at line 33 of file AnonymizedMessage.cpp.

34 : AnonymizedMessage(ToUTF8(message))
35{
36}

◆ AnonymizedMessage() [7/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( const char *  message)

Creates a message from const char*.

Definition at line 38 of file AnonymizedMessage.cpp.

39 : AnonymizedMessage(std::string(message))
40{
41}

◆ AnonymizedMessage() [8/8]

audacity::sentry::AnonymizedMessage::AnonymizedMessage ( const wchar_t *  message)

Creates a message from const wchar_t*.

Definition at line 43 of file AnonymizedMessage.cpp.

44 : AnonymizedMessage(ToUTF8(message))
45{
46}

Member Function Documentation

◆ c_str()

const char * audacity::sentry::AnonymizedMessage::c_str ( ) const
noexcept

Checks, if the message is empty.

Definition at line 68 of file AnonymizedMessage.cpp.

69{
70 return mMessage.c_str();
71}

References mMessage.

Referenced by audacity::sentry::Report::ReportImpl::ReportImpl(), and audacity::sentry::anonymous_namespace{SentryReport.cpp}::SerializeException().

Here is the caller graph for this function:

◆ CleanupPaths()

void audacity::sentry::AnonymizedMessage::CleanupPaths ( )
private

Definition at line 78 of file AnonymizedMessage.cpp.

79{
80 // Finding the path boundary in the arbitrary text is a hard task.
81 // We assume that spaces cannot be a part of the path.
82 // In the worst case - we will get <path> <path>
83 static const std::regex re(
84 R"(\b(?:(?:[a-zA-Z]:)?[\\/]?)?(?:[^<>:"/|\\/?\s*]+[\\/]+)*(?:[^<>:"/|\\/?*\s]+\.\w+)?)");
85
86 mMessage = std::regex_replace(
87 mMessage, re, "<path>", std::regex_constants::match_not_null);
88}

References mMessage.

Referenced by AnonymizedMessage().

Here is the caller graph for this function:

◆ Empty()

bool audacity::sentry::AnonymizedMessage::Empty ( ) const
noexcept

Checks, if the message is empty.

Definition at line 48 of file AnonymizedMessage.cpp.

49{
50 return mMessage.empty();
51}

References mMessage.

◆ GetString()

const std::string & audacity::sentry::AnonymizedMessage::GetString ( ) const
noexcept

Returns the UTF8 representation of the message.

Definition at line 58 of file AnonymizedMessage.cpp.

59{
60 return mMessage;
61}

References mMessage.

◆ Length()

size_t audacity::sentry::AnonymizedMessage::Length ( ) const
noexcept

Returns the length of the message.

Definition at line 53 of file AnonymizedMessage.cpp.

54{
55 return mMessage.size();
56}

References mMessage.

◆ length()

size_t audacity::sentry::AnonymizedMessage::length ( ) const
noexcept

Returns the length of the message.

Definition at line 73 of file AnonymizedMessage.cpp.

74{
75 return mMessage.length();
76}

References mMessage.

Referenced by audacity::sentry::Report::ReportImpl::ReportImpl(), and audacity::sentry::anonymous_namespace{SentryReport.cpp}::SerializeException().

Here is the caller graph for this function:

◆ operator=() [1/2]

AnonymizedMessage & audacity::sentry::AnonymizedMessage::operator= ( AnonymizedMessage &&  )
default

◆ operator=() [2/2]

AnonymizedMessage & audacity::sentry::AnonymizedMessage::operator= ( const AnonymizedMessage )
default

◆ ToWXString()

wxString audacity::sentry::AnonymizedMessage::ToWXString ( ) const
noexcept

Convert the message to wxString.

Definition at line 63 of file AnonymizedMessage.cpp.

64{
66}
wxString ToWXString(const std::string &str)

References mMessage, and audacity::ToWXString().

Here is the call graph for this function:

Member Data Documentation

◆ mMessage

std::string audacity::sentry::AnonymizedMessage::mMessage
private

Definition at line 66 of file AnonymizedMessage.h.

Referenced by c_str(), CleanupPaths(), Empty(), GetString(), Length(), length(), and ToWXString().


The documentation for this class was generated from the following files: