bool KICADPCB::parsePCB( SEXPR::SEXPR* data ) { if( NULL == data ) return false; if( data->IsList() ) { size_t nc = data->GetNumberOfChildren(); SEXPR::SEXPR* child = data->GetChild( 0 ); std::string name = child->GetSymbol(); if( name != "kicad_pcb" ) { std::ostringstream ostr; ostr << "* data is not a valid PCB file: '" << m_filename << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } bool result = true; for( size_t i = 1; i < nc && result; ++i ) { child = data->GetChild( i ); if( !child->IsList() ) { std::ostringstream ostr; ostr << "* corrupt PCB file: '" << m_filename << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } std::string symname( child->GetChild( 0 )->GetSymbol() ); if( symname == "general" ) result = result && parseGeneral( child ); else if( symname == "module" ) result = result && parseModule( child ); else if( symname == "gr_arc" ) result = result && parseCurve( child, CURVE_ARC ); else if( symname == "gr_line" ) result = result && parseCurve( child, CURVE_LINE ); else if( symname == "gr_circle" ) result = result && parseCurve( child, CURVE_CIRCLE ); } return result; } std::ostringstream ostr; ostr << "* data is not a valid PCB file: '" << m_filename << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; }
// Config Loading--------------------------------------------- bool Save::load(){ char* line = new char[256]; char** keys = new char*[3]; u8 value; if (!selectFile()) return false; while(!feof(file)){ getLine(line); if (strlen(line) > 1 && getKeysAndValue(line, keys, &value)){ switch(currentPart){ // KAOSS case 0: parseKaoss(keys, value); break; // MIXER case 2: parseMixer(keys, value); break; //SLIDERS case 3: parseSliders(keys, value); break; //GENERAL case 4: parseGeneral(keys[0], value); break; //DEBUG case 5: parseDebug(keys[0], value); break; //MIDIIN case 6: parseMidiIn(keys[0], value); break; } } } delete line; delete keys; return true; }