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 77 of file CommandTargets.cpp.

77 {
78 if( name.empty() )
79 Update( wxString::Format( "%s\"%s\"", (mCounts.back()>0)?", ":"", value?"true":"false"));
80 else
81 Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", name,value?"true":"false"));
82 mCounts.back() += 1;
83}
const TranslatableString name
Definition: Distortion.cpp:82
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 85 of file CommandTargets.cpp.

85 {
86 std::stringstream str;
87 std::locale nolocale("C");
88 str.imbue(nolocale);
89
90 if( name.empty() )
91 str << ((mCounts.back()>0)? ", " : "") << value;
92 else
93 str << ((mCounts.back()>0)? ", " : "") << "\"" << name << "\"" << ":" << value;
94
95 Update( str.str() );
96 mCounts.back() += 1;
97}
#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 66 of file CommandTargets.cpp.

66 {
67 wxString Padding;
68 Padding.Pad( mCounts.size() *2 -2);
69 Padding = (( value.length() < 15 ) || (mCounts.back()<=0)) ? wxString{} : wxString("\n") + Padding;
70 if( name.empty() )
71 Update( wxString::Format( "%s%s\"%s\"", (mCounts.back()>0)?", ":"", Padding, Escaped(value)));
72 else
73 Update( wxString::Format( "%s%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", Padding, name, Escaped(value)));
74 mCounts.back() += 1;
75}
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 47 of file CommandTargets.cpp.

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

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 108 of file CommandTargets.cpp.

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

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 60 of file CommandTargets.cpp.

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

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 117 of file CommandTargets.cpp.

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

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 114 of file CommandTargets.cpp.

114 {
115}

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 38 of file CommandTargets.cpp.

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

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 99 of file CommandTargets.cpp.

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

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 53 of file CommandTargets.cpp.

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

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: