Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
OptionValidator Class Referencefinal

Parameter must be one of the defined options. More...

#include <Validators.h>

Inheritance diagram for OptionValidator:
Collaboration diagram for OptionValidator:

Public Member Functions

void AddOption (const wxString &option)
void AddOptions (const wxArrayString &options)
bool Validate (const wxVariant &v) override
 Judge whether the passed value satisfies the Validator. More...
wxString GetDescription () const override
Holder GetClone () const override
- Public Member Functions inherited from Validator
 Validator ()
virtual ~Validator ()
void SetConverted (const wxVariant &v)
const wxVariant & GetConverted ()
virtual bool Validate (const wxVariant &v)
 Judge whether the passed value satisfies the Validator. More...
virtual wxString GetDescription () const
virtual Holder GetClone () const =0

Private Attributes

wxArrayString mOptions

Additional Inherited Members

- Public Types inherited from Validator
using Holder = std::unique_ptr< Validator >
 This MUST be overridden, to avoid slicing! More...

Detailed Description

Parameter must be one of the defined options.

Definition at line 98 of file Validators.h.

Member Function Documentation

◆ AddOption()

void OptionValidator::AddOption ( const wxString &  option)

Definition at line 104 of file Validators.h.

105 {
106 mOptions.push_back(option);
107 }
wxArrayString mOptions
Definition: Validators.h:101

References mOptions.

◆ AddOptions()

void OptionValidator::AddOptions ( const wxArrayString &  options)

Definition at line 108 of file Validators.h.

109 {
110 mOptions.insert(mOptions.begin(), options.begin(), options.end());
111 }

References mOptions.

◆ GetClone()

Holder OptionValidator::GetClone ( ) const

Implements Validator.

Definition at line 129 of file Validators.h.

130 {
131 auto v = std::make_unique<OptionValidator>();
132 v->mOptions = mOptions;
133 // This std::move is needed to "upcast" the pointer type
134 return std::move(v);
135 }

References mOptions.

◆ GetDescription()

wxString OptionValidator::GetDescription ( ) const

Return a description (for error messages) should be of the form 'v must be $description'

Reimplemented from Validator.

Definition at line 117 of file Validators.h.

118 {
119 wxString desc = wxT("one of: ");
120 int optionCount = mOptions.size();
121 int i = 0;
122 for (i = 0; i+1 < optionCount; ++i)
123 {
124 desc += mOptions[i] + wxT(", ");
125 }
126 desc += mOptions[optionCount-1];
127 return desc;
128 }
const TranslatableString desc
Definition: ExportPCM.cpp:51

References anonymous_namespace{ExportPCM.cpp}::desc, mOptions, and wxT().

Here is the call graph for this function:

◆ Validate()

bool OptionValidator::Validate ( const wxVariant &  v)

Judge whether the passed value satisfies the Validator.

Reimplemented from Validator.

Definition at line 112 of file Validators.h.

113 {
114 SetConverted(v);
115 return make_iterator_range( mOptions ).contains( v.GetString() );
116 }
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
void SetConverted(const wxVariant &v)
Definition: Validators.h:61

References make_iterator_range(), mOptions, and Validator::SetConverted().

Here is the call graph for this function:

Member Data Documentation

◆ mOptions

wxArrayString OptionValidator::mOptions

Definition at line 101 of file Validators.h.

Referenced by AddOption(), AddOptions(), GetClone(), GetDescription(), and Validate().

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