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 97 of file Validators.h.

Member Function Documentation

◆ AddOption()

void OptionValidator::AddOption ( const wxString &  option)

Definition at line 103 of file Validators.h.

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

References mOptions.

◆ AddOptions()

void OptionValidator::AddOptions ( const wxArrayString &  options)

Definition at line 107 of file Validators.h.

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

References mOptions.

◆ GetClone()

Holder OptionValidator::GetClone ( ) const

Implements Validator.

Definition at line 128 of file Validators.h.

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

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 116 of file Validators.h.

117 {
118 wxString desc = wxT("one of: ");
119 int optionCount = mOptions.size();
120 int i = 0;
121 for (i = 0; i+1 < optionCount; ++i)
122 {
123 desc += mOptions[i] + wxT(", ");
124 }
125 desc += mOptions[optionCount-1];
126 return desc;
127 }
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 111 of file Validators.h.

112 {
113 SetConverted(v);
114 return make_iterator_range( mOptions ).contains( v.GetString() );
115 }
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:448
void SetConverted(const wxVariant &v)
Definition: Validators.h:60

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 100 of file Validators.h.

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

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