Audacity 3.2.0
ShuttleGetDefinition.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ShuttleGetDefinition.cpp
6
7 Paul Licameli split this out of Shuttle.cpp
8
9**********************************************************************/
10
13
15 bool result = pOptionalFlag !=NULL;
16 pOptionalFlag = NULL;
17 return result;
18}
19
20// Definition distinguishes optional from not.
22 pOptionalFlag = &var;
23 return *this;
24};
25
27{
28}
29
30// JSON definitions.
31void ShuttleGetDefinition::Define(bool, const wxChar * key,
32 bool vdefault, bool, bool, bool)
33{
35 AddItem( wxString(key), "key" );
36 AddItem( "bool", "type" );
37 if( IsOptional() )
38 AddItem( "unchanged", "default" );
39 else
40 AddItem( vdefault ? "True" : "False", "default" );
41 EndStruct();
42}
43
44void ShuttleGetDefinition::Define(int, const wxChar * key,
45 int vdefault, int, int, int)
46{
48 AddItem( wxString(key), "key" );
49 AddItem( "int", "type" );
50 if( IsOptional() )
51 AddItem( "unchanged", "default" );
52 else
53 AddItem( (double)vdefault, "default" );
54 EndStruct();
55}
56
57void ShuttleGetDefinition::Define(size_t, const wxChar * key,
58 int vdefault, int, int, int)
59{
61 AddItem( wxString(key), "key" );
62 AddItem( "size_t", "type" );
63 if( IsOptional() )
64 AddItem( "unchanged", "default" );
65 else
66 AddItem( (double)vdefault, "default" );
67 EndStruct();
68
69}
70
71void ShuttleGetDefinition::Define(float, const wxChar * key,
72 float vdefault, float, float, float)
73{
75 AddItem( wxString(key), "key" );
76 AddItem( "float", "type" );
77 if( IsOptional() )
78 AddItem( "unchanged", "default" );
79 else
80 AddItem( (double)vdefault, "default" );
81 EndStruct();
82}
83
84void ShuttleGetDefinition::Define(double, const wxChar * key,
85 float vdefault, float, float, float)
86{
88 AddItem( wxString(key), "key" );
89 AddItem( "float", "type" );
90 if( IsOptional() )
91 AddItem( "unchanged", "default" );
92 else
93 AddItem( (double)vdefault, "default" );
94 EndStruct();
95}
96
97void ShuttleGetDefinition::Define(double, const wxChar * key,
98 double vdefault, double, double, double)
99{
100 StartStruct();
101 AddItem( wxString(key), "key" );
102 AddItem( "double", "type" );
103 if( IsOptional() )
104 AddItem( "unchanged", "default" );
105 else
106 AddItem( (double)vdefault, "default" );
107 EndStruct();
108}
109
110
111void ShuttleGetDefinition::Define(const wxString &, const wxChar * key,
112 wxString vdefault, wxString, wxString, wxString)
113{
114 StartStruct();
115 AddItem( wxString(key), "key" );
116 AddItem( "string", "type" );
117 if( IsOptional() )
118 AddItem( "unchanged", "default" );
119 else
120 AddItem( vdefault, "default" );
121 EndStruct();
122}
123
124
125void ShuttleGetDefinition::DefineEnum(int, const wxChar * key,
126 int vdefault, const EnumValueSymbol strings[], size_t nStrings )
127{
128 StartStruct();
129 AddItem( wxString(key), "key" );
130 AddItem( "enum", "type" );
131 if( IsOptional() )
132 AddItem( "unchanged", "default" );
133 else
134 AddItem( strings[vdefault].Internal(), "default" );
135 StartField( "enum" );
136 StartArray();
137 for( size_t i = 0; i < nStrings; i++ )
138 AddItem( strings[i].Internal() );
139 EndArray();
140 EndField();
141 EndStruct();
142}
@ Internal
Indicates internal failure from Audacity.
static const AudacityProject::AttachedObjects::RegisteredFactory key
CommandMessageTargetDecorator is a CommandOutputTarget that forwards its work on to another one....
void StartField(const wxString &name={}) override
void AddItem(const wxString &value, const wxString &name={}) override
Interface for objects that can receive (string) messages from a command.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
std::conditional_t< Const, const bool, bool > * pOptionalFlag
ShuttleGetDefinition(CommandMessageTarget &target)
void DefineEnum(int var, const wxChar *key, int vdefault, const EnumValueSymbol strings[], size_t nStrings) override
void Define(bool var, const wxChar *key, bool vdefault, bool vmin, bool vmax, bool vscl) override
ConstSettingsVisitor & Optional(const bool &var) override