Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
CommandMessageTarget Class Referenceabstract

Interface for objects that can receive (string) messages from a command. More...

#include <CommandTargets.h>

Inheritance diagram for CommandMessageTarget:
[legend]
Collaboration diagram for CommandMessageTarget:
[legend]

Public Member Functions

 CommandMessageTarget ()
 
virtual ~CommandMessageTarget ()
 
virtual void Update (const wxString &message)=0
 
virtual void StartArray ()
 
virtual void EndArray ()
 
virtual void StartStruct ()
 
virtual void EndStruct ()
 
virtual void AddItem (const wxString &value, const wxString &name={})
 
virtual void AddBool (const bool value, const wxString &name={})
 
virtual void AddItem (const double value, const wxString &name={})
 
virtual void StartField (const wxString &name={})
 
virtual void EndField ()
 
virtual void Flush ()
 
wxString Escaped (const wxString &str)
 

Public Attributes

std::vector< int > mCounts
 

Detailed Description

Interface for objects that can receive (string) messages from a command.

Definition at line 74 of file CommandTargets.h.

Constructor & Destructor Documentation

◆ CommandMessageTarget()

CommandMessageTarget::CommandMessageTarget ( )
inline

Definition at line 77 of file CommandTargets.h.

77{mCounts.push_back(0);}
std::vector< int > mCounts

◆ ~CommandMessageTarget()

virtual CommandMessageTarget::~CommandMessageTarget ( )
inlinevirtual

Definition at line 78 of file CommandTargets.h.

78{ Flush();}

Member Function Documentation

◆ AddBool()

void CommandMessageTarget::AddBool ( const bool  value,
const wxString &  name = {} 
)
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 76 of file CommandTargets.cpp.

76 {
77 if( name.empty() )
78 Update( wxString::Format( "%s\"%s\"", (mCounts.back()>0)?", ":"", value?"true":"false"));
79 else
80 Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", name,value?"true":"false"));
81 mCounts.back() += 1;
82}
const TranslatableString name
Definition: Distortion.cpp:74
virtual void Update(const wxString &message)=0

References TranslatableString::empty(), mCounts, name, and Update().

Here is the call graph for this function:

◆ AddItem() [1/2]

void CommandMessageTarget::AddItem ( const double  value,
const wxString &  name = {} 
)
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 84 of file CommandTargets.cpp.

84 {
85 std::stringstream str;
86 std::locale nolocale("C");
87 str.imbue(nolocale);
88
89 if( name.empty() )
90 str << ((mCounts.back()>0)? ", " : "") << value;
91 else
92 str << ((mCounts.back()>0)? ", " : "") << "\"" << name << "\"" << ":" << value;
93
94 Update( str.str() );
95 mCounts.back() += 1;
96}
#define str(a)

References TranslatableString::empty(), mCounts, name, str, and Update().

Here is the call graph for this function:

◆ AddItem() [2/2]

void CommandMessageTarget::AddItem ( const wxString &  value,
const wxString &  name = {} 
)
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 65 of file CommandTargets.cpp.

65 {
66 wxString Padding;
67 Padding.Pad( mCounts.size() *2 -2);
68 Padding = (( value.length() < 15 ) || (mCounts.back()<=0)) ? wxString{} : wxString("\n") + Padding;
69 if( name.empty() )
70 Update( wxString::Format( "%s%s\"%s\"", (mCounts.back()>0)?", ":"", Padding, Escaped(value)));
71 else
72 Update( wxString::Format( "%s%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", Padding, name, Escaped(value)));
73 mCounts.back() += 1;
74}
wxString Escaped(const wxString &str)

References TranslatableString::empty(), Escaped(), mCounts, name, and Update().

Here is the call graph for this function:

◆ EndArray()

void CommandMessageTarget::EndArray ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 46 of file CommandTargets.cpp.

46 {
47 if( mCounts.size() > 1 ){
48 mCounts.pop_back();
49 }
50 Update( " ]" );
51}

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::EndArray().

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

◆ EndField()

void CommandMessageTarget::EndField ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 107 of file CommandTargets.cpp.

107 {
108 if( mCounts.size() > 1 ){
109 mCounts.pop_back();
110 }
111}

References mCounts.

Referenced by CommandMessageTargetDecorator::EndField().

Here is the caller graph for this function:

◆ EndStruct()

void CommandMessageTarget::EndStruct ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 59 of file CommandTargets.cpp.

59 {
60 if( mCounts.size() > 1 ){
61 mCounts.pop_back();
62 }
63 Update( " }" );
64}

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::EndStruct().

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

◆ Escaped()

wxString CommandMessageTarget::Escaped ( const wxString &  str)

Definition at line 116 of file CommandTargets.cpp.

116 {
117 wxString Temp = str;
118 Temp.Replace( "\"", "\\\"");
119 return Temp;
120}

References str.

Referenced by AddItem(), and LispyCommandMessageTarget::AddItem().

Here is the caller graph for this function:

◆ Flush()

void CommandMessageTarget::Flush ( )
virtual

Reimplemented in MessageDialogTarget, CommandMessageTargetDecorator, and ResponseTarget.

Definition at line 113 of file CommandTargets.cpp.

113 {
114}

Referenced by CommandMessageTargetDecorator::Flush().

Here is the caller graph for this function:

◆ StartArray()

void CommandMessageTarget::StartArray ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 37 of file CommandTargets.cpp.

38{
39 wxString Padding;
40 Padding.Pad( mCounts.size() *2 -2);
41 Update( wxString::Format( "%s%s[ ", ( mCounts.back() > 0 ) ? ",\n" : "\n", Padding ));
42 mCounts.back() += 1;
43 mCounts.push_back( 0 );
44}

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::StartArray().

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

◆ StartField()

void CommandMessageTarget::StartField ( const wxString &  name = {})
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 98 of file CommandTargets.cpp.

98 {
99 if( name.empty() )
100 Update( wxString::Format( "%s", (mCounts.back()>0)? ", " : ""));
101 else
102 Update( wxString::Format( "%s\"%s\":", (mCounts.back()>0) ?", ":"", name));
103 mCounts.back() += 1;
104 mCounts.push_back( 0 );
105}

References TranslatableString::empty(), mCounts, name, and Update().

Here is the call graph for this function:

◆ StartStruct()

void CommandMessageTarget::StartStruct ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 52 of file CommandTargets.cpp.

52 {
53 wxString Padding;
54 Padding.Pad( mCounts.size() *2 -2);
55 Update( wxString::Format( "%s%s{ ", ( mCounts.back() > 0 ) ? ",\n" : "\n", Padding ));
56 mCounts.back() += 1;
57 mCounts.push_back( 0 );
58}

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::StartStruct().

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

◆ Update()

virtual void CommandMessageTarget::Update ( const wxString &  message)
pure virtual

Implemented in NullMessageTarget, MessageDialogTarget, CommandMessageTargetDecorator, MessageBoxTarget, StatusBarTarget, ResponseTarget, and CombinedMessageTarget.

Referenced by AddBool(), AddItem(), EndArray(), EndStruct(), StartArray(), StartField(), StartStruct(), and CommandMessageTargetDecorator::Update().

Here is the caller graph for this function:

Member Data Documentation

◆ mCounts

std::vector<int> CommandMessageTarget::mCounts

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