Added "enabled" parameter for LIB_TABLE_ROW

- Read and write from lib-table working
This commit is contained in:
Oliver 2017-11-15 16:48:31 +11:00 committed by Wayne Stambaugh
parent f17f604072
commit 7cdb78e852
5 changed files with 44 additions and 8 deletions

View File

@ -6,3 +6,4 @@ type
uri
options
descr
disabled

View File

@ -87,12 +87,20 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
wxString uri = GetFullURI();
uri.Replace( '\\', '/' );
out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n",
wxString extraOptions;
if( !GetIsEnabled() )
{
extraOptions += "(disabled)";
}
out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s)%s)\n",
out->Quotew( GetNickName() ).c_str(),
out->Quotew( GetType() ).c_str(),
out->Quotew( uri ).c_str(),
out->Quotew( GetOptions() ).c_str(),
out->Quotew( GetDescr() ).c_str()
out->Quotew( GetDescr() ).c_str(),
extraOptions.ToStdString().c_str()
);
}

View File

@ -124,10 +124,11 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
// After (name), remaining (lib) elements are order independent, and in
// some cases optional.
bool sawType = false;
bool sawOpts = false;
bool sawDesc = false;
bool sawUri = false;
bool sawType = false;
bool sawOpts = false;
bool sawDesc = false;
bool sawUri = false;
bool sawDisabled = false;
while( ( tok = in->NextTok() ) != T_RIGHT )
{
@ -173,6 +174,13 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
row->SetDescr( in->FromUTF8() );
break;
case T_disabled:
if( sawDisabled )
in->Duplicate( tok );
sawDisabled = true;
row->SetEnabled( false );
break;
default:
in->Unexpected( tok );
}
@ -219,7 +227,9 @@ void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) cons
aOutput->Print( aIndentLevel, "(sym_lib_table\n" );
for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
{
it->Format( aOutput, aIndentLevel+1 );
}
aOutput->Print( aIndentLevel, ")\n" );
}

View File

@ -51,11 +51,13 @@ public:
LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
{
SetType( aType );
SetEnabled( true );
}
SYMBOL_LIB_TABLE_ROW() :
type( SCH_IO_MGR::SCH_LEGACY )
{
SetEnabled( true );
}
bool operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const;
@ -77,6 +79,7 @@ protected:
LIB_TABLE_ROW( aRow ),
type( aRow.type )
{
SetEnabled( aRow.GetIsEnabled() );
}
private:

View File

@ -78,7 +78,8 @@ public:
LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aOptions,
const wxString& aDescr = wxEmptyString ) :
nickName( aNick ),
description( aDescr )
description( aDescr ),
enabled( true )
{
properties.reset();
SetOptions( aOptions );
@ -99,6 +100,16 @@ public:
*/
void SetNickName( const wxString& aNickName ) { nickName = aNickName; }
/**
* @return the enabled status of this library row
*/
bool GetIsEnabled() const { return enabled; }
/**
* Change the enabled status of this library
*/
void SetEnabled( bool aEnabled = true ) { enabled = aEnabled; }
/**
* Return the type of library represented by this row.
*/
@ -175,7 +186,8 @@ protected:
uri_expanded( aRow.uri_expanded ),
#endif
options( aRow.options ),
description( aRow.description )
description( aRow.description ),
enabled( aRow.enabled )
{
if( aRow.properties )
properties.reset( new PROPERTIES( *aRow.properties.get() ) );
@ -200,6 +212,8 @@ private:
wxString options;
wxString description;
bool enabled = true; ///< Whether the LIB_TABLE_ROW is enabled
std::unique_ptr< PROPERTIES > properties;
};