本文整理汇总了C++中LIB_ID::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ID::Parse方法的具体用法?C++ LIB_ID::Parse怎么用?C++ LIB_ID::Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_ID
的用法示例。
在下文中一共展示了LIB_ID::Parse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelectComponentFromLibBrowser
SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser(
wxTopLevelWindow* aParent,
const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId,
int aUnit, int aConvert )
{
// Close any open non-modal Lib browser, and open a new one, in "modal" mode:
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
if( viewlibFrame )
viewlibFrame->Destroy();
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, aParent );
if( aFilter )
viewlibFrame->SetFilter( aFilter );
if( aPreselectedLibId.IsValid() )
{
viewlibFrame->SetSelectedLibrary( aPreselectedLibId.GetLibNickname() );
viewlibFrame->SetSelectedComponent( aPreselectedLibId.GetLibItemName() );
}
viewlibFrame->SetUnitAndConvert( aUnit, aConvert );
viewlibFrame->Refresh();
COMPONENT_SELECTION sel;
wxString symbol = sel.LibId.Format();
if( viewlibFrame->ShowModal( &symbol, aParent ) )
{
LIB_ID id;
if( id.Parse( symbol, LIB_ID::ID_SCH ) == -1 )
sel.LibId = id;
sel.Unit = viewlibFrame->GetUnit();
sel.Convert = viewlibFrame->GetConvert();
}
viewlibFrame->Destroy();
return sel;
}
示例2: ShowModal
bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
{
if( aFootprint && !aFootprint->IsEmpty() )
{
wxString msg;
LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
LIB_ID fpid;
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
if( fpid.IsValid() )
{
wxString nickname = fpid.GetLibNickname();
if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
{
msg.sprintf( _( "The current configuration does not include a library with the\n"
"nickname \"%s\". Use Manage Footprint Libraries\n"
"to edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
}
else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
{
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Footprint Libraries to\n"
"edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
}
else
{
setCurNickname( nickname );
setCurFootprintName( fpid.GetLibItemName() );
ReCreateFootprintList();
}
SelectAndViewFootprint( NEW_PART );
}
}
return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
}
示例3: ShowModal
bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
{
if( aSymbol && !aSymbol->IsEmpty() )
{
wxString msg;
LIB_TABLE* libTable = Prj().SchSymbolLibTable();
LIB_ID libid;
libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );
if( libid.IsValid() )
{
wxString nickname = libid.GetLibNickname();
if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
{
msg.sprintf( _( "The current configuration does not include a library with the\n"
"nickname \"%s\". Use Manage Symbol Libraries\n"
"to edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
}
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
{
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Symbol Libraries to\n"
"edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
}
else
{
SetSelectedLibrary( libid.GetLibNickname() );
SetSelectedComponent( libid.GetLibItemName() );
}
}
}
return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
}
示例4: SetNewPkg
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex )
{
COMPONENT* component;
if( m_netlist.IsEmpty() )
return;
component = m_netlist.GetComponent( aIndex );
if( component == NULL )
return;
LIB_ID fpid;
if( !aFootprintName.IsEmpty() )
{
wxCHECK_RET( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0,
wxString::Format( _( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) );
}
component->SetFPID( fpid );
// create the new component description
wxString description = wxString::Format( CMP_FORMAT, aIndex + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
// Set the new description and deselect the processed component
m_compListBox->SetString( aIndex, description );
// Mark this "session" as modified
m_modified = true;
// update the statusbar
DisplayStatus();
}
示例5: parseComponent
void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR, boost::bad_pointer )
{
/* Parses a section like
* (comp (ref P1)
* (value DB25FEMELLE)
* (footprint DB25FC)
* (libsource (lib conn) (part DB25))
* (sheetpath (names /) (tstamps /))
* (tstamp 3256759C))
*
* other fields (unused) are skipped
* A component need a reference, value, footprint name and a full time stamp
* The full time stamp is the sheetpath time stamp + the component time stamp
*/
LIB_ID fpid;
wxString footprint;
wxString ref;
wxString value;
wxString library;
wxString name;
wxString pathtimestamp, timestamp;
// The token comp was read, so the next data is (ref P1)
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_ref:
NeedSYMBOLorNUMBER();
ref = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_value:
NeedSYMBOLorNUMBER();
value = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_footprint:
NeedSYMBOLorNUMBER();
footprint = FromUTF8();
NeedRIGHT();
break;
case T_libsource:
// Read libsource
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_lib )
{
NeedSYMBOLorNUMBER();
library = FROM_UTF8( CurText() );
NeedRIGHT();
}
else if( token == T_part )
{
NeedSYMBOLorNUMBER();
name = FROM_UTF8( CurText() );
NeedRIGHT();
}
else
{
Expecting( "part or lib" );
}
}
break;
case T_sheetpath:
while( ( token = NextTok() ) != T_tstamps );
NeedSYMBOLorNUMBER();
pathtimestamp = FROM_UTF8( CurText() );
NeedRIGHT();
NeedRIGHT();
break;
case T_tstamp:
NeedSYMBOLorNUMBER();
timestamp = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default:
// Skip not used data (i.e all other tokens)
skipCurrent();
break;
}
}
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: <%s>\nline: %d\noffset: %d" ),
GetChars( CurSource() ), CurLineNumber(), CurOffset() );
//.........这里部分代码省略.........
示例6: Load
bool CMP_READER::Load( NETLIST* aNetlist )
{
wxCHECK_MSG( aNetlist != NULL,true, wxT( "No netlist passed to CMP_READER::Load()" ) );
wxString reference; // Stores value read from line like Reference = BUS1;
wxString timestamp; // Stores value read from line like TimeStamp = /32307DE2/AA450F67;
wxString footprint; // Stores value read from line like IdModule = CP6;
wxString buffer;
wxString value;
bool ok = true;
while( m_lineReader->ReadLine() )
{
buffer = FROM_UTF8( m_lineReader->Line() );
if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
continue;
// Begin component description.
reference.Empty();
footprint.Empty();
timestamp.Empty();
while( m_lineReader->ReadLine() )
{
buffer = FROM_UTF8( m_lineReader->Line() );
if( buffer.StartsWith( wxT( "EndCmp" ) ) )
break;
// store string value, stored between '=' and ';' delimiters.
value = buffer.AfterFirst( '=' );
value = value.BeforeLast( ';' );
value.Trim( true );
value.Trim( false );
if( buffer.StartsWith( wxT( "Reference" ) ) )
{
reference = value;
continue;
}
if( buffer.StartsWith( wxT( "IdModule =" ) ) )
{
footprint = value;
continue;
}
if( buffer.StartsWith( wxT( "TimeStamp =" ) ) )
{
timestamp = value;
continue;
}
}
// Find the corresponding item in component list:
COMPONENT* component = aNetlist->GetComponentByReference( reference );
// The corresponding component could no longer existing in the netlist. This
// can happen when it is removed from schematic and still exists in footprint
// assignment list. This is an usual case during the life of a design.
if( component )
{
LIB_ID fpid;
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid footprint ID in\nfile: \"%s\"\nline: %d" ),
GetChars( m_lineReader->GetSource() ),
m_lineReader->LineNumber() );
THROW_IO_ERROR( error );
}
// For checking purpose, store the existing LIB_ID (if any) in the alternate fpid copy
// if this existing LIB_ID differs from the LIB_ID read from the .cmp file.
// CvPcb can ask for user to chose the right LIB_ID.
// It happens if the LIB_ID was modified outside CvPcb.
if( fpid != component->GetFPID() && !component->GetFPID().empty() )
component->SetAltFPID( component->GetFPID() );
component->SetFPID( fpid );
}
else
{
ok = false; // can be used to display a warning in Pcbnew.
}
}
return ok;
}