?? component.cpp
字號:
//*****************************************************************************// Component.cpp *// --------------- *// Started : 14/05/2004 *// Last Update : 08/06/2005 *// Copyright : (C) 2004 by M.S.Waters *// Email : M.Waters@bom.gov.au *//*****************************************************************************//*****************************************************************************// *// This program is free software; you can redistribute it and/or modify *// it under the terms of the GNU General Public License as published by *// the Free Software Foundation; either version 2 of the License, or *// (at your option) any later version. *// *//*****************************************************************************#include "Component.hpp"//*****************************************************************************// Constructor.Component::Component( const wxChar * psLine ){ Clear( ); bSetLine( psLine );}//*****************************************************************************// Destructor.Component::~Component( ){}//*****************************************************************************// Parse a component definition string extracted from a net list.//// Argument List:// psLine - A string containing a component definition//// Return Values:// TRUE - Success (The component definition was parsed successfully)// FALSE - Failure (The component definition wasn't parsed successfully)bool Component::bParse( const wxChar * psLine ){ wxStringTokenizer oStrTok( psLine ); wxString os1=psLine; size_t szt1, szt2; // Do preliminary component definition validity checks if( os1.Length( ) < 7 ) return( FALSE ); // Test line length if( isalpha( os1.GetChar( 0 ) ) == 0 ) return( FALSE ); // Test first char. if( oStrTok.CountTokens( ) < 4 ) return( FALSE ); // Test field count // Determine the component type switch( toupper( os1.GetChar( 0 ) ) ) { case wxT('C'): m_eType = eCPNT_CAP; break; // Capacitor case wxT('D'): m_eType = eCPNT_DIODE; break; // Diode case wxT('E'): m_eType = eCPNT_VCVS; break; // Voltage Controlled Voltage Src case wxT('F'): m_eType = eCPNT_CCCS; break; // Current Controlled Current Src case wxT('G'): m_eType = eCPNT_VCCS; break; // Voltage Controlled Current Src case wxT('H'): m_eType = eCPNT_CCVS; break; // Current Controlled Voltage Src case wxT('I'): m_eType = eCPNT_ICS; break; // Independent Current Source case wxT('J'): m_eType = eCPNT_JFET; break; // Junction Field-Effect Transistor case wxT('K'): m_eType = eCPNT_CIND; break; // Coupled (Mutual) Inductors case wxT('L'): m_eType = eCPNT_IND; break; // Inductor case wxT('M'): m_eType = eCPNT_MOS; break; // Metal-Oxide Semiconductor FET case wxT('Q'): m_eType = eCPNT_BJT; break; // Bipolar Junction Transistor case wxT('R'): m_eType = eCPNT_RES; break; // Resistor case wxT('S'): m_eType = eCPNT_VCSW; break; // Voltage Controlled Switch case wxT('T'): m_eType = eCPNT_TLINE; break; // Transmission Line case wxT('U'): m_eType = eCPNT_LOGIC; break; // Logic Device case wxT('V'): m_eType = eCPNT_IVS; break; // Independent Voltage Source case wxT('W'): m_eType = eCPNT_CCSW; break; // Current Controlled Switch case wxT('X'): m_eType = eCPNT_SUBCKT; break; // Sub-circuit case wxT('Y'): m_eType = eCPNT_ADM; break; // Admittance default : m_eType = eCPNT_NONE; // None type selected } // Extract the component name m_osName = oStrTok.GetNextToken( ); // Extract the nodes the component is connected to szt2 = (size_t) oStrTok.CountTokens( ); for( szt1=1; szt1<szt2; szt1++ ) { m_oasNodes.Add( oStrTok.GetNextToken( ) ); if( szt1 >= 2 ) { if( m_eType == eCPNT_CAP ) break; // Capacitor if( m_eType == eCPNT_DIODE ) break; // Diode if( m_eType == eCPNT_ICS ) break; // Independent Current Source if( m_eType == eCPNT_IND ) break; // Inductor if( m_eType == eCPNT_RES ) break; // Resistor if( m_eType == eCPNT_IVS ) break; // Independent Voltage Source if( m_eType == eCPNT_ADM ) break; // Admittance } } // Extract the component value m_osValue = oStrTok.GetString( ); // Set the state of m_bIsOk flag m_bIsOk = TRUE; if( m_eType == eCPNT_NONE ) m_bIsOk = FALSE; if( m_osName.IsEmpty( ) ) m_bIsOk = FALSE; if( m_oasNodes.GetCount( ) < 2 ) m_bIsOk = FALSE; if( m_osValue.IsEmpty( ) ) m_bIsOk = FALSE; return( bIsOk( ) );}//*****************************************************************************// Clear the object attributes.void Component::Clear( void ){ m_osLine .Clear( ); m_osName .Clear( ); m_oasNodes.Clear( ); m_osValue .Clear( ); m_eType = eCPNT_NONE; m_bIsOk = FALSE;}//*****************************************************************************// Set the component definition string extracted from a net list.//// Argument List:// psLine - A string containing a component definition//// Return Values:// TRUE - Success (The component definition was valid)// FALSE - Failure (The component definition wasn't valid)bool Component::bSetLine( const wxChar * psLine ){ if( psLine == NULL ) return( FALSE ); Clear( ); if( ! bParse( psLine ) ) return( FALSE ); return( TRUE );}//*****************************************************************************
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -