KiCad PCB EDA Suite
SCH_NETNAME_VALIDATOR Class Reference

#include <sch_validators.h>

Inheritance diagram for SCH_NETNAME_VALIDATOR:
NETNAME_VALIDATOR

Public Member Functions

 SCH_NETNAME_VALIDATOR (wxString *aVal=nullptr)
 
 SCH_NETNAME_VALIDATOR (bool aAllowSpaces)
 
 SCH_NETNAME_VALIDATOR (const SCH_NETNAME_VALIDATOR &aValidator)
 
virtual wxObject * Clone () const override
 
virtual bool TransferToWindow () override
 
virtual bool TransferFromWindow () override
 
virtual bool Validate (wxWindow *aParent) override
 

Protected Member Functions

wxString IsValid (const wxString &aVal) const override
 

Private Attributes

bool m_allowSpaces
 

Static Private Attributes

static wxRegEx m_busGroupRegex
 

Detailed Description

Definition at line 80 of file sch_validators.h.

Constructor & Destructor Documentation

◆ SCH_NETNAME_VALIDATOR() [1/3]

SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR ( wxString *  aVal = nullptr)
inline

Definition at line 83 of file sch_validators.h.

83 :
84 NETNAME_VALIDATOR( aVal )
85 { }
NETNAME_VALIDATOR(wxString *aVal=nullptr)
Definition: validators.cpp:319

Referenced by Clone().

◆ SCH_NETNAME_VALIDATOR() [2/3]

SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR ( bool  aAllowSpaces)
inline

Definition at line 87 of file sch_validators.h.

87 :
88 NETNAME_VALIDATOR( aAllowSpaces )
89 { }

◆ SCH_NETNAME_VALIDATOR() [3/3]

SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR ( const SCH_NETNAME_VALIDATOR aValidator)
inline

Definition at line 91 of file sch_validators.h.

91 :
92 NETNAME_VALIDATOR( aValidator )
93 { }

Member Function Documentation

◆ Clone()

virtual wxObject * SCH_NETNAME_VALIDATOR::Clone ( ) const
inlineoverridevirtual

Reimplemented from NETNAME_VALIDATOR.

Definition at line 95 of file sch_validators.h.

95{ return new SCH_NETNAME_VALIDATOR( *this ); }
SCH_NETNAME_VALIDATOR(wxString *aVal=nullptr)

References SCH_NETNAME_VALIDATOR().

◆ IsValid()

wxString SCH_NETNAME_VALIDATOR::IsValid ( const wxString &  aVal) const
overrideprotected
Returns
the error message if the contents of aVal are invalid.

Definition at line 209 of file sch_validators.cpp.

210{
211 wxString msg = NETNAME_VALIDATOR::IsValid( str );
212
213 if( !msg.IsEmpty() )
214 return msg;
215
216 // We don't do single-character validation here
217 if( str.Length() == 1 )
218 return wxString();
219
220 // Figuring out if the user "meant" to make a bus group is somewhat tricky because curly
221 // braces are also used for formatting and variable expansion
222
223 if( m_busGroupRegex.Matches( str ) && str.Contains( '}' ) )
224 {
225 if( !NET_SETTINGS::ParseBusGroup( str, nullptr, nullptr ) )
226 return _( "Signal name contains '{' and '}' but is not a valid bus name" );
227 }
228 else if( str.Contains( '[' ) || str.Contains( ']' ) )
229 {
230 if( !NET_SETTINGS::ParseBusVector( str, nullptr, nullptr ) )
231 return _( "Signal name contains '[' or ']' but is not a valid bus name." );
232 }
233
234 return wxString();
235}
wxString IsValid(const wxString &aVal) const override
Definition: validators.cpp:364
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
static wxRegEx m_busGroupRegex
#define _(s)

References _, NETNAME_VALIDATOR::IsValid(), m_busGroupRegex, NET_SETTINGS::ParseBusGroup(), and NET_SETTINGS::ParseBusVector().

◆ TransferFromWindow()

virtual bool NETNAME_VALIDATOR::TransferFromWindow ( )
inlineoverridevirtualinherited

Definition at line 212 of file validators.h.

212{ return true; }

◆ TransferToWindow()

virtual bool NETNAME_VALIDATOR::TransferToWindow ( )
inlineoverridevirtualinherited

Definition at line 210 of file validators.h.

210{ return true; }

◆ Validate()

bool NETNAME_VALIDATOR::Validate ( wxWindow *  aParent)
overridevirtualinherited

Definition at line 340 of file validators.cpp.

341{
342 // If window is disabled, simply return
343 if ( !m_validatorWindow->IsEnabled() )
344 return true;
345
346 wxTextEntry * const text = GetTextEntry();
347
348 if ( !text )
349 return false;
350
351 const wxString& errormsg = IsValid( text->GetValue() );
352
353 if( !errormsg.empty() )
354 {
355 m_validatorWindow->SetFocus();
356 wxMessageBox( errormsg, _( "Invalid signal name" ), wxOK | wxICON_EXCLAMATION, aParent );
357 return false;
358 }
359
360 return true;
361}

References _, NETNAME_VALIDATOR::IsValid(), and text.

Member Data Documentation

◆ m_allowSpaces

bool NETNAME_VALIDATOR::m_allowSpaces
privateinherited

Definition at line 221 of file validators.h.

Referenced by NETNAME_VALIDATOR::IsValid().

◆ m_busGroupRegex

wxRegEx SCH_NETNAME_VALIDATOR::m_busGroupRegex
staticprivate

Definition at line 102 of file sch_validators.h.

Referenced by IsValid().


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