Audacity  2.2.2
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:
CombinedMessageTarget CommandMessageTargetDecorator MessageBoxTarget MessageDialogTarget NullMessageTarget ResponseQueueTarget StatusBarTarget BriefCommandMessageTarget LispyCommandMessageTarget ShuttleGetDefinition ShuttleGuiGetDefinition

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

wxArrayInt mCounts
 

Detailed Description

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

Definition at line 75 of file CommandTargets.h.

Constructor & Destructor Documentation

CommandMessageTarget::CommandMessageTarget ( )
inline

Definition at line 78 of file CommandTargets.h.

References mCounts.

78 {mCounts.push_back(0);}
virtual CommandMessageTarget::~CommandMessageTarget ( )
inlinevirtual

Definition at line 79 of file CommandTargets.h.

References Flush().

79 { Flush();}
virtual void Flush()

Member Function Documentation

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

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 69 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::AddBool().

69  {
70  if( name.IsEmpty() )
71  Update( wxString::Format( "%s\"%s\"", (mCounts.Last()>0)?", ":"", value?"true":"false"));
72  else
73  Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.Last()>0)?", ":"", name,value?"true":"false"));
74  mCounts.Last() += 1;
75 }
const wxChar * name
Definition: Distortion.cpp:94
virtual void Update(const wxString &message)=0
void CommandMessageTarget::AddItem ( const wxString &  value,
const wxString &  name = "" 
)
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 58 of file CommandTargets.cpp.

References Escaped(), mCounts, and Update().

Referenced by CommandMessageTargetDecorator::AddItem().

58  {
59  wxString Padding;
60  Padding.Pad( mCounts.GetCount() *2 -2);
61  Padding = (( value.length() < 15 ) || (mCounts.Last()<=0)) ? "" : wxString("\n") + Padding;
62  if( name.IsEmpty() )
63  Update( wxString::Format( "%s%s\"%s\"", (mCounts.Last()>0)?", ":"", Padding, Escaped(value)));
64  else
65  Update( wxString::Format( "%s%s\"%s\":\"%s\"", (mCounts.Last()>0)?", ":"", Padding, name, Escaped(value)));
66  mCounts.Last() += 1;
67 }
wxString Escaped(const wxString &str)
const wxChar * name
Definition: Distortion.cpp:94
virtual void Update(const wxString &message)=0
void CommandMessageTarget::AddItem ( const double  value,
const wxString &  name = "" 
)
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 76 of file CommandTargets.cpp.

References mCounts, and Update().

76  {
77  if( name.IsEmpty() )
78  Update( wxString::Format( "%s%g", (mCounts.Last()>0)?", ":"", value));
79  else
80  Update( wxString::Format( "%s\"%s\":%g", (mCounts.Last()>0)?", ":"", name,value));
81  mCounts.Last() += 1;
82 }
const wxChar * name
Definition: Distortion.cpp:94
virtual void Update(const wxString &message)=0
void CommandMessageTarget::EndArray ( )
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 39 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::EndArray().

39  {
40  if( mCounts.GetCount() > 1 ){
41  mCounts.pop_back();
42  }
43  Update( " ]" );
44 }
virtual void Update(const wxString &message)=0
void CommandMessageTarget::EndField ( )
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 93 of file CommandTargets.cpp.

References mCounts.

Referenced by CommandMessageTargetDecorator::EndField().

93  {
94  if( mCounts.GetCount() > 1 ){
95  mCounts.pop_back();
96  }
97 }
void CommandMessageTarget::EndStruct ( )
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 52 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::EndStruct().

52  {
53  if( mCounts.GetCount() > 1 ){
54  mCounts.pop_back();
55  }
56  Update( " }" );
57 }
virtual void Update(const wxString &message)=0
wxString CommandMessageTarget::Escaped ( const wxString &  str)

Definition at line 102 of file CommandTargets.cpp.

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

102  {
103  wxString Temp = str;
104  Temp.Replace( "\"", "\\\"");
105  return Temp;
106 }
void CommandMessageTarget::Flush ( )
virtual

Reimplemented in MessageDialogTarget, and CommandMessageTargetDecorator.

Definition at line 99 of file CommandTargets.cpp.

Referenced by CommandMessageTargetDecorator::Flush(), and ~CommandMessageTarget().

99  {
100 }
void CommandMessageTarget::StartArray ( )
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 30 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::StartArray().

31 {
32  wxString Padding;
33  Padding.Pad( mCounts.GetCount() *2 -2);
34  Update( wxString::Format( "%s%s[ ", ( mCounts.Last() > 0 ) ? ",\n" : "\n", Padding ));
35  mCounts.Last() += 1;
36  mCounts.push_back( 0 );
37 }
virtual void Update(const wxString &message)=0
void CommandMessageTarget::StartField ( const wxString &  name = "")
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 84 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::StartField().

84  {
85  if( name.IsEmpty() )
86  Update( wxString::Format( "%s", (mCounts.Last()>0)? ", " : ""));
87  else
88  Update( wxString::Format( "%s\"%s\":", (mCounts.Last()>0) ?", ":"", name));
89  mCounts.Last() += 1;
90  mCounts.push_back( 0 );
91 }
const wxChar * name
Definition: Distortion.cpp:94
virtual void Update(const wxString &message)=0
void CommandMessageTarget::StartStruct ( )
virtual

Reimplemented in BriefCommandMessageTarget, LispyCommandMessageTarget, and CommandMessageTargetDecorator.

Definition at line 45 of file CommandTargets.cpp.

References mCounts, and Update().

Referenced by CommandMessageTargetDecorator::StartStruct().

45  {
46  wxString Padding;
47  Padding.Pad( mCounts.GetCount() *2 -2);
48  Update( wxString::Format( "%s%s{ ", ( mCounts.Last() > 0 ) ? ",\n" : "\n", Padding ));
49  mCounts.Last() += 1;
50  mCounts.push_back( 0 );
51 }
virtual void Update(const wxString &message)=0
virtual void CommandMessageTarget::Update ( const wxString &  message)
pure virtual

Member Data Documentation

wxArrayInt CommandMessageTarget::mCounts

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