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 70 of file CommandTargets.h.

Constructor & Destructor Documentation

◆ CommandMessageTarget()

CommandMessageTarget::CommandMessageTarget ( )
inline

Definition at line 73 of file CommandTargets.h.

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

◆ ~CommandMessageTarget()

CommandMessageTarget::~CommandMessageTarget ( )
virtual

Definition at line 22 of file CommandTargets.cpp.

23{
24 Flush();
25}

References Flush().

Here is the call graph for this function:

Member Function Documentation

◆ AddBool()

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

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 66 of file CommandTargets.cpp.

66 {
67 if( name.empty() )
68 Update( wxString::Format( "%s\"%s\"", (mCounts.back()>0)?", ":"", value?"true":"false"));
69 else
70 Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", name,value?"true":"false"));
71 mCounts.back() += 1;
72}
wxString name
Definition: TagsEditor.cpp:166
virtual void Update(const wxString &message)=0

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

74 {
75 std::stringstream str;
76 std::locale nolocale("C");
77 str.imbue(nolocale);
78
79 if( name.empty() )
80 str << ((mCounts.back()>0)? ", " : "") << value;
81 else
82 str << ((mCounts.back()>0)? ", " : "") << "\"" << name << "\"" << ":" << value;
83
84 Update( str.str() );
85 mCounts.back() += 1;
86}
#define str(a)

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

55 {
56 wxString Padding;
57 Padding.Pad( mCounts.size() *2 -2);
58 Padding = (( value.length() < 15 ) || (mCounts.back()<=0)) ? wxString{} : wxString("\n") + Padding;
59 if( name.empty() )
60 Update( wxString::Format( "%s%s\"%s\"", (mCounts.back()>0)?", ":"", Padding, Escaped(value)));
61 else
62 Update( wxString::Format( "%s%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", Padding, name, Escaped(value)));
63 mCounts.back() += 1;
64}
wxString Escaped(const wxString &str)

References Escaped(), mCounts, name, anonymous_namespace{CommonTrackInfo.cpp}::Padding, and Update().

Here is the call graph for this function:

◆ EndArray()

void CommandMessageTarget::EndArray ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 36 of file CommandTargets.cpp.

36 {
37 if( mCounts.size() > 1 ){
38 mCounts.pop_back();
39 }
40 Update( " ]" );
41}

References mCounts, and Update().

Here is the call graph for this function:

◆ EndField()

void CommandMessageTarget::EndField ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 97 of file CommandTargets.cpp.

97 {
98 if( mCounts.size() > 1 ){
99 mCounts.pop_back();
100 }
101}

References mCounts.

◆ EndStruct()

void CommandMessageTarget::EndStruct ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 49 of file CommandTargets.cpp.

49 {
50 if( mCounts.size() > 1 ){
51 mCounts.pop_back();
52 }
53 Update( " }" );
54}

References mCounts, and Update().

Here is the call graph for this function:

◆ Escaped()

wxString CommandMessageTarget::Escaped ( const wxString &  str)

Definition at line 106 of file CommandTargets.cpp.

106 {
107 wxString Temp = str;
108 Temp.Replace( "\"", "\\\"");
109 return Temp;
110}

References str.

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

Here is the caller graph for this function:

◆ Flush()

void CommandMessageTarget::Flush ( )
virtual

Reimplemented in CommandMessageTargetDecorator, ResponseTarget, and MessageDialogTarget.

Definition at line 103 of file CommandTargets.cpp.

103 {
104}

Referenced by ~CommandMessageTarget().

Here is the caller graph for this function:

◆ StartArray()

void CommandMessageTarget::StartArray ( )
virtual

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 27 of file CommandTargets.cpp.

28{
29 wxString Padding;
30 Padding.Pad( mCounts.size() *2 -2);
31 Update( wxString::Format( "%s%s[ ", ( mCounts.back() > 0 ) ? ",\n" : "\n", Padding ));
32 mCounts.back() += 1;
33 mCounts.push_back( 0 );
34}

References mCounts, anonymous_namespace{CommonTrackInfo.cpp}::Padding, and Update().

Here is the call graph for this function:

◆ StartField()

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

Reimplemented in CommandMessageTargetDecorator, LispyCommandMessageTarget, and BriefCommandMessageTarget.

Definition at line 88 of file CommandTargets.cpp.

88 {
89 if( name.empty() )
90 Update( wxString::Format( "%s", (mCounts.back()>0)? ", " : ""));
91 else
92 Update( wxString::Format( "%s\"%s\":", (mCounts.back()>0) ?", ":"", name));
93 mCounts.back() += 1;
94 mCounts.push_back( 0 );
95}

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

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

References mCounts, anonymous_namespace{CommonTrackInfo.cpp}::Padding, and Update().

Here is the call graph for this function:

◆ Update()

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

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

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

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: