예제 #1
0
/* Read the section "libparts" like:
 * (libparts
 *   (libpart (lib device) (part C)
 *     (description "Condensateur non polarise")
 *     (footprints
 *       (fp SM*)
 *       (fp C?)
 *       (fp C1-1))
 *     (fields
 *       (field (name Reference) C)
 *       (field (name Value) C))
 *     (pins
 *       (pin (num 1) (name ~) (type passive))
 *       (pin (num 2) (name ~) (type passive))))
 *
 *  And add the strings giving the footprint filter (subsection footprints)
 *  of the corresponding module info
 */
void NETLIST_READER_KICAD_PARSER::ParseKicadLibpartList() throw( IO_ERROR, PARSE_ERROR )
{
   /* Parses a section like
     *   (libpart (lib device) (part C)
     *     (description "Condensateur non polarise")
     *     (footprints
     *       (fp SM*)
     *       (fp C?)
     *       (fp C1-1))
     *     (fields
     *       (field (name Reference) C)
     *       (field (name Value) C))
     *     (pins
     *       (pin (num 1) (name ~) (type passive))
     *       (pin (num 2) (name ~) (type passive))))
     *
     * Currently footprints section/fp are read and data stored
     * other fields (unused) are skipped
     */
    wxString device;
    wxString filter;
    LIPBART_INFO* libpart_info = NULL;

    // The last token read was libpart, so read the next token
    while( (token = NextTok()) != T_RIGHT )
    {
        if( token == T_LEFT )
            token = NextTok();
        switch( token )
        {
        case T_part:
            NeedSYMBOLorNUMBER();
            device = FROM_UTF8( CurText() );
            NeedRIGHT();
            libpart_info = new LIPBART_INFO( device );
            netlist_reader->AddLibpartInfo( libpart_info );
            break;

        case T_footprints:
            // Ensure "(part C)" was already read
            if( libpart_info == NULL )
                Expecting( T_part );
            // Read all fp elements (footprint filter item)
            while( (token = NextTok()) != T_RIGHT )
            {
                if( token == T_LEFT )
                    token = NextTok();
                if( token != T_fp )
                    Expecting( T_fp );
                NeedSYMBOLorNUMBER();
                filter = FROM_UTF8( CurText() );
                NeedRIGHT();
                libpart_info->m_FootprintFilter.Add( filter );
            }
            break;

        default:
            // Skip not used data (i.e all other tokens)
            SkipCurrent();
            break;
        }
    }
}