You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

601 lines
21 KiB

5 years ago
5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 CERN
  5. * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Jon Evans <jon@craftyjon.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <config_params.h>
  22. #include <project.h>
  23. #include <project/net_settings.h>
  24. #include <settings/json_settings_internals.h>
  25. #include <project/project_file.h>
  26. #include <settings/common_settings.h>
  27. #include <settings/parameters.h>
  28. #include <wildcards_and_files_ext.h>
  29. #include <wx/config.h>
  30. #include <wx/log.h>
  31. ///! Update the schema version whenever a migration is required
  32. const int projectFileSchemaVersion = 1;
  33. PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
  34. JSON_SETTINGS( aFullPath, SETTINGS_LOC::PROJECT, projectFileSchemaVersion ),
  35. m_ErcSettings( nullptr ),
  36. m_SchematicSettings( nullptr ),
  37. m_BoardSettings(),
  38. m_sheets(),
  39. m_boards(),
  40. m_project( nullptr )
  41. {
  42. // Keep old files around
  43. m_deleteLegacyAfterMigration = false;
  44. m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "sheets", &m_sheets, {} ) );
  45. m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "boards", &m_boards, {} ) );
  46. m_params.emplace_back( new PARAM_WXSTRING_MAP( "text_variables", &m_TextVars, {} ) );
  47. m_params.emplace_back(
  48. new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) );
  49. m_params.emplace_back( new PARAM_LIST<wxString>(
  50. "libraries.pinned_footprint_libs", &m_PinnedFootprintLibs, {} ) );
  51. m_params.emplace_back(
  52. new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) );
  53. m_params.emplace_back(
  54. new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_BoardDrawingSheetFile, "" ) );
  55. m_params.emplace_back(
  56. new PARAM_PATH( "pcbnew.last_paths.netlist", &m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
  57. m_params.emplace_back(
  58. new PARAM_PATH( "pcbnew.last_paths.step", &m_PcbLastPath[LAST_PATH_STEP], "" ) );
  59. m_params.emplace_back(
  60. new PARAM_PATH( "pcbnew.last_paths.idf", &m_PcbLastPath[LAST_PATH_IDF], "" ) );
  61. m_params.emplace_back(
  62. new PARAM_PATH( "pcbnew.last_paths.vrml", &m_PcbLastPath[LAST_PATH_VRML], "" ) );
  63. m_params.emplace_back( new PARAM_PATH(
  64. "pcbnew.last_paths.specctra_dsn", &m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) );
  65. m_params.emplace_back(
  66. new PARAM_PATH( "pcbnew.last_paths.gencad", &m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
  67. m_params.emplace_back( new PARAM<wxString>( "schematic.legacy_lib_dir", &m_LegacyLibDir, "" ) );
  68. m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "schematic.legacy_lib_list",
  69. [&]() -> nlohmann::json
  70. {
  71. nlohmann::json ret = nlohmann::json::array();
  72. for( const wxString& libName : m_LegacyLibNames )
  73. ret.push_back( libName );
  74. return ret;
  75. },
  76. [&]( const nlohmann::json& aJson )
  77. {
  78. if( aJson.empty() || !aJson.is_array() )
  79. return;
  80. m_LegacyLibNames.clear();
  81. for( const nlohmann::json& entry : aJson )
  82. m_LegacyLibNames.push_back( entry.get<wxString>() );
  83. }, {} ) );
  84. m_NetSettings = std::make_shared<NET_SETTINGS>( this, "net_settings" );
  85. m_params.emplace_back( new PARAM_LAYER_PRESET( "board.layer_presets", &m_LayerPresets ) );
  86. }
  87. bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
  88. {
  89. bool ret = true;
  90. wxString str;
  91. long index = 0;
  92. std::set<wxString> group_blacklist;
  93. // Legacy files don't store board info; they assume board matches project name
  94. // We will leave m_boards empty here so it can be populated with other code
  95. // First handle migration of data that will be stored locally in this object
  96. auto loadPinnedLibs =
  97. [&]( const std::string& aDest )
  98. {
  99. int libIndex = 1;
  100. wxString libKey = wxT( "PinnedItems" );
  101. libKey << libIndex;
  102. nlohmann::json libs = nlohmann::json::array();
  103. while( aCfg->Read( libKey, &str ) )
  104. {
  105. libs.push_back( str );
  106. aCfg->DeleteEntry( libKey, true );
  107. libKey = wxT( "PinnedItems" );
  108. libKey << ++libIndex;
  109. }
  110. Set( aDest, libs );
  111. };
  112. aCfg->SetPath( wxT( "/LibeditFrame" ) );
  113. loadPinnedLibs( "libraries.pinned_symbol_libs" );
  114. aCfg->SetPath( wxT( "/ModEditFrame" ) );
  115. loadPinnedLibs( "libraries.pinned_footprint_libs" );
  116. aCfg->SetPath( wxT( "/cvpcb/equfiles" ) );
  117. {
  118. int eqIdx = 1;
  119. wxString eqKey = wxT( "EquName" );
  120. eqKey << eqIdx;
  121. nlohmann::json eqs = nlohmann::json::array();
  122. while( aCfg->Read( eqKey, &str ) )
  123. {
  124. eqs.push_back( str );
  125. eqKey = wxT( "EquName" );
  126. eqKey << ++eqIdx;
  127. }
  128. Set( "cvpcb.equivalence_files", eqs );
  129. }
  130. // All CvPcb params that we want to keep have been migrated above
  131. group_blacklist.insert( wxT( "/cvpcb" ) );
  132. aCfg->SetPath( wxT( "/eeschema" ) );
  133. fromLegacyString( aCfg, "LibDir", "schematic.legacy_lib_dir" );
  134. aCfg->SetPath( wxT( "/eeschema/libraries" ) );
  135. {
  136. int libIdx = 1;
  137. wxString libKey = wxT( "LibName" );
  138. libKey << libIdx;
  139. nlohmann::json libs = nlohmann::json::array();
  140. while( aCfg->Read( libKey, &str ) )
  141. {
  142. libs.push_back( str );
  143. libKey = wxT( "LibName" );
  144. libKey << ++libIdx;
  145. }
  146. Set( "schematic.legacy_lib_list", libs );
  147. }
  148. group_blacklist.insert( wxT( "/eeschema" ) );
  149. aCfg->SetPath( wxT( "/text_variables" ) );
  150. {
  151. int txtIdx = 1;
  152. wxString txtKey;
  153. txtKey << txtIdx;
  154. nlohmann::json vars = nlohmann::json();
  155. while( aCfg->Read( txtKey, &str ) )
  156. {
  157. wxArrayString tokens = wxSplit( str, ':' );
  158. if( tokens.size() == 2 )
  159. vars[ tokens[0].ToStdString() ] = tokens[1];
  160. txtKey.clear();
  161. txtKey << ++txtIdx;
  162. }
  163. Set( "text_variables", vars );
  164. }
  165. group_blacklist.insert( wxT( "/text_variables" ) );
  166. aCfg->SetPath( wxT( "/schematic_editor" ) );
  167. fromLegacyString( aCfg, "PageLayoutDescrFile", "schematic.page_layout_descr_file" );
  168. fromLegacyString( aCfg, "PlotDirectoryName", "schematic.plot_directory" );
  169. fromLegacyString( aCfg, "NetFmtName", "schematic.net_format_name" );
  170. fromLegacy<bool>( aCfg, "SpiceAjustPassiveValues", "schematic.spice_adjust_passive_values" );
  171. fromLegacy<int>( aCfg, "SubpartIdSeparator", "schematic.subpart_id_separator" );
  172. fromLegacy<int>( aCfg, "SubpartFirstId", "schematic.subpart_first_id" );
  173. fromLegacy<int>( aCfg, "LineThickness", "schematic.drawing.default_line_thickness" );
  174. fromLegacy<int>( aCfg, "WireThickness", "schematic.drawing.default_wire_thickness" );
  175. fromLegacy<int>( aCfg, "BusThickness", "schematic.drawing.default_bus_thickness" );
  176. fromLegacy<int>( aCfg, "LabSize", "schematic.drawing.default_text_size" );
  177. if( !fromLegacy<int>( aCfg, "PinSymbolSize", "schematic.drawing.pin_symbol_size" ) )
  178. {
  179. // Use the default symbol size algorithm of Eeschema V5 (based on pin name/number size)
  180. Set( "schematic.drawing.pin_symbol_size", 0 );
  181. }
  182. fromLegacy<int>( aCfg, "JunctionSize", "schematic.drawing.default_junction_size" );
  183. fromLegacyString( aCfg, "FieldNameTemplates", "schematic.drawing.field_names" );
  184. if( !fromLegacy<double>( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" ) )
  185. {
  186. // Use the spacing of Eeschema V5
  187. Set( "schematic.drawing.text_offset_ratio", 0.08 );
  188. Set( "schematic.drawing.label_size_ratio", 0.25 );
  189. }
  190. // All schematic_editor keys we keep are migrated above
  191. group_blacklist.insert( wxT( "/schematic_editor" ) );
  192. aCfg->SetPath( wxT( "/pcbnew" ) );
  193. fromLegacyString( aCfg, "PageLayoutDescrFile", "pcbnew.page_layout_descr_file" );
  194. fromLegacyString( aCfg, "LastNetListRead", "pcbnew.last_paths.netlist" );
  195. fromLegacyString( aCfg, "LastSTEPExportPath", "pcbnew.last_paths.step" );
  196. fromLegacyString( aCfg, "LastIDFExportPath", "pcbnew.last_paths.idf" );
  197. fromLegacyString( aCfg, "LastVRMLExportPath", "pcbnew.last_paths.vmrl" );
  198. fromLegacyString( aCfg, "LastSpecctraDSNExportPath", "pcbnew.last_paths.specctra_dsn" );
  199. fromLegacyString( aCfg, "LastGenCADExportPath", "pcbnew.last_paths.gencad" );
  200. std::string bp = "board.design_settings.";
  201. {
  202. int idx = 1;
  203. wxString key = wxT( "DRCExclusion" );
  204. key << idx;
  205. nlohmann::json exclusions = nlohmann::json::array();
  206. while( aCfg->Read( key, &str ) )
  207. {
  208. exclusions.push_back( str );
  209. key = wxT( "DRCExclusion" );
  210. key << ++idx;
  211. }
  212. Set( bp + "drc_exclusions", exclusions );
  213. }
  214. fromLegacy<bool>( aCfg, "AllowMicroVias", bp + "rules.allow_microvias" );
  215. fromLegacy<bool>( aCfg, "AllowBlindVias", bp + "rules.allow_blind_buried_vias" );
  216. fromLegacy<double>( aCfg, "MinClearance", bp + "rules.min_clearance" );
  217. fromLegacy<double>( aCfg, "MinTrackWidth", bp + "rules.min_track_width" );
  218. fromLegacy<double>( aCfg, "MinViaAnnulus", bp + "rules.min_via_annulus" );
  219. fromLegacy<double>( aCfg, "MinViaDiameter", bp + "rules.min_via_diameter" );
  220. if( !fromLegacy<double>( aCfg, "MinThroughDrill", bp + "rules.min_through_hole_diameter" ) )
  221. fromLegacy<double>( aCfg, "MinViaDrill", bp + "rules.min_through_hole_diameter" );
  222. fromLegacy<double>( aCfg, "MinMicroViaDiameter", bp + "rules.min_microvia_diameter" );
  223. fromLegacy<double>( aCfg, "MinMicroViaDrill", bp + "rules.min_microvia_drill" );
  224. fromLegacy<double>( aCfg, "MinHoleToHole", bp + "rules.min_hole_to_hole" );
  225. fromLegacy<double>( aCfg, "CopperEdgeClearance", bp + "rules.min_copper_edge_clearance" );
  226. fromLegacy<double>( aCfg, "SolderMaskClearance", bp + "rules.solder_mask_clearance" );
  227. fromLegacy<double>( aCfg, "SolderMaskMinWidth", bp + "rules.solder_mask_min_width" );
  228. fromLegacy<double>( aCfg, "SolderPasteClearance", bp + "rules.solder_paste_clearance" );
  229. fromLegacy<double>( aCfg, "SolderPasteRatio", bp + "rules.solder_paste_margin_ratio" );
  230. if( !fromLegacy<double>( aCfg, "SilkLineWidth", bp + "defaults.silk_line_width" ) )
  231. fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.silk_line_width" );
  232. if( !fromLegacy<double>( aCfg, "SilkTextSizeV", bp + "defaults.silk_text_size_v" ) )
  233. fromLegacy<double>( aCfg, "ModuleTextSizeV", bp + "defaults.silk_text_size_v" );
  234. if( !fromLegacy<double>( aCfg, "SilkTextSizeH", bp + "defaults.silk_text_size_h" ) )
  235. fromLegacy<double>( aCfg, "ModuleTextSizeH", bp + "defaults.silk_text_size_h" );
  236. if( !fromLegacy<double>( aCfg, "SilkTextSizeThickness", bp + "defaults.silk_text_thickness" ) )
  237. fromLegacy<double>( aCfg, "ModuleTextSizeThickness", bp + "defaults.silk_text_thickness" );
  238. fromLegacy<bool>( aCfg, "SilkTextItalic", bp + "defaults.silk_text_italic" );
  239. fromLegacy<bool>( aCfg, "SilkTextUpright", bp + "defaults.silk_text_upright" );
  240. if( !fromLegacy<double>( aCfg, "CopperLineWidth", bp + "defaults.copper_line_width" ) )
  241. fromLegacy<double>( aCfg, "DrawSegmentWidth", bp + "defaults.copper_line_width" );
  242. if( !fromLegacy<double>( aCfg, "CopperTextSizeV", bp + "defaults.copper_text_size_v" ) )
  243. fromLegacy<double>( aCfg, "PcbTextSizeV", bp + "defaults.copper_text_size_v" );
  244. if( !fromLegacy<double>( aCfg, "CopperTextSizeH", bp + "defaults.copper_text_size_h" ) )
  245. fromLegacy<double>( aCfg, "PcbTextSizeH", bp + "defaults.copper_text_size_h" );
  246. if( !fromLegacy<double>( aCfg, "CopperTextThickness", bp + "defaults.copper_text_thickness" ) )
  247. fromLegacy<double>( aCfg, "PcbTextThickness", bp + "defaults.copper_text_thickness" );
  248. fromLegacy<bool>( aCfg, "CopperTextItalic", bp + "defaults.copper_text_italic" );
  249. fromLegacy<bool>( aCfg, "CopperTextUpright", bp + "defaults.copper_text_upright" );
  250. if( !fromLegacy<double>( aCfg, "EdgeCutLineWidth", bp + "defaults.board_outline_line_width" ) )
  251. fromLegacy<double>( aCfg, "BoardOutlineThickness", bp + "defaults.board_outline_line_width" );
  252. fromLegacy<double>( aCfg, "CourtyardLineWidth", bp + "defaults.courtyard_line_width" );
  253. fromLegacy<double>( aCfg, "FabLineWidth", bp + "defaults.fab_line_width" );
  254. fromLegacy<double>( aCfg, "FabTextSizeV", bp + "defaults.fab_text_size_v" );
  255. fromLegacy<double>( aCfg, "FabTextSizeH", bp + "defaults.fab_text_size_h" );
  256. fromLegacy<double>( aCfg, "FabTextSizeThickness", bp + "defaults.fab_text_thickness" );
  257. fromLegacy<bool>( aCfg, "FabTextItalic", bp + "defaults.fab_text_italic" );
  258. fromLegacy<bool>( aCfg, "FabTextUpright", bp + "defaults.fab_text_upright" );
  259. if( !fromLegacy<double>( aCfg, "OthersLineWidth", bp + "defaults.other_line_width" ) )
  260. fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.other_line_width" );
  261. fromLegacy<double>( aCfg, "OthersTextSizeV", bp + "defaults.other_text_size_v" );
  262. fromLegacy<double>( aCfg, "OthersTextSizeH", bp + "defaults.other_text_size_h" );
  263. fromLegacy<double>( aCfg, "OthersTextSizeThickness", bp + "defaults.other_text_thickness" );
  264. fromLegacy<bool>( aCfg, "OthersTextItalic", bp + "defaults.other_text_italic" );
  265. fromLegacy<bool>( aCfg, "OthersTextUpright", bp + "defaults.other_text_upright" );
  266. fromLegacy<int>( aCfg, "DimensionUnits", bp + "defaults.dimension_units" );
  267. fromLegacy<int>( aCfg, "DimensionPrecision", bp + "defaults.dimension_precision" );
  268. std::string sev = bp + "rule_severities";
  269. fromLegacy<bool>( aCfg, "RequireCourtyardDefinitions", sev + "legacy_no_courtyard_defined" );
  270. fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_courtyards_overlap" );
  271. {
  272. int idx = 1;
  273. wxString keyBase = "TrackWidth";
  274. wxString key = keyBase;
  275. double val;
  276. nlohmann::json widths = nlohmann::json::array();
  277. key << idx;
  278. while( aCfg->Read( key, &val ) )
  279. {
  280. widths.push_back( val );
  281. key = keyBase;
  282. key << ++idx;
  283. }
  284. Set( bp + "track_widths", widths );
  285. }
  286. {
  287. int idx = 1;
  288. wxString keyBase = "ViaDiameter";
  289. wxString key = keyBase;
  290. double diameter;
  291. double drill = 1.0;
  292. nlohmann::json vias = nlohmann::json::array();
  293. key << idx;
  294. while( aCfg->Read( key, &diameter ) )
  295. {
  296. key = "ViaDrill";
  297. aCfg->Read( key << idx, &drill );
  298. nlohmann::json via = { { "diameter", diameter }, { "drill", drill } };
  299. vias.push_back( via );
  300. key = keyBase;
  301. key << ++idx;
  302. }
  303. Set( bp + "via_dimensions", vias );
  304. }
  305. {
  306. int idx = 1;
  307. wxString keyBase = "dPairWidth";
  308. wxString key = keyBase;
  309. double width;
  310. double gap = 1.0;
  311. double via_gap = 1.0;
  312. nlohmann::json pairs = nlohmann::json::array();
  313. key << idx;
  314. while( aCfg->Read( key, &width ) )
  315. {
  316. key = "dPairGap";
  317. aCfg->Read( key << idx, &gap );
  318. key = "dPairViaGap";
  319. aCfg->Read( key << idx, &via_gap );
  320. nlohmann::json pair = { { "width", width }, { "gap", gap }, { "via_gap", via_gap } };
  321. pairs.push_back( pair );
  322. key = keyBase;
  323. key << ++idx;
  324. }
  325. Set( bp + "diff_pair_dimensions", pairs );
  326. }
  327. group_blacklist.insert( wxT( "/pcbnew" ) );
  328. // General group is unused these days, we can throw it away
  329. group_blacklist.insert( wxT( "/general" ) );
  330. // Next load sheet names and put all other legacy data in the legacy dict
  331. aCfg->SetPath( wxT( "/" ) );
  332. auto loadSheetNames =
  333. [&]() -> bool
  334. {
  335. int sheet = 1;
  336. wxString entry;
  337. nlohmann::json arr = nlohmann::json::array();
  338. wxLogTrace( traceSettings, wxT( "Migrating sheet names" ) );
  339. aCfg->SetPath( wxT( "/sheetnames" ) );
  340. while( aCfg->Read( wxString::Format( "%d", sheet++ ), &entry ) )
  341. {
  342. wxArrayString tokens = wxSplit( entry, ':' );
  343. if( tokens.size() == 2 )
  344. {
  345. wxLogTrace( traceSettings, wxT( "%d: %s = %s" ), sheet, tokens[0],
  346. tokens[1] );
  347. arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) );
  348. }
  349. }
  350. Set( "sheets", arr );
  351. aCfg->SetPath( "/" );
  352. // TODO: any reason we want to fail on this?
  353. return true;
  354. };
  355. std::vector<wxString> groups;
  356. groups.emplace_back( "" );
  357. auto loadLegacyPairs =
  358. [&]( const std::string& aGroup ) -> bool
  359. {
  360. wxLogTrace( traceSettings, wxT( "Migrating group %s" ), aGroup );
  361. bool success = true;
  362. wxString keyStr;
  363. wxString val;
  364. index = 0;
  365. while( aCfg->GetNextEntry( keyStr, index ) )
  366. {
  367. if( !aCfg->Read( keyStr, &val ) )
  368. continue;
  369. std::string key( keyStr.ToUTF8() );
  370. wxLogTrace( traceSettings, wxT( " %s = %s" ), key, val );
  371. try
  372. {
  373. Set( "legacy." + aGroup + "." + key, val );
  374. }
  375. catch( ... )
  376. {
  377. success = false;
  378. }
  379. }
  380. return success;
  381. };
  382. for( size_t i = 0; i < groups.size(); i++ )
  383. {
  384. aCfg->SetPath( groups[i] );
  385. if( groups[i] == wxT( "/sheetnames" ) )
  386. {
  387. ret |= loadSheetNames();
  388. continue;
  389. }
  390. aCfg->DeleteEntry( wxT( "last_client" ), true );
  391. aCfg->DeleteEntry( wxT( "update" ), true );
  392. aCfg->DeleteEntry( wxT( "version" ), true );
  393. ret &= loadLegacyPairs( groups[i].ToStdString() );
  394. index = 0;
  395. while( aCfg->GetNextGroup( str, index ) )
  396. {
  397. wxString group = groups[i] + "/" + str;
  398. if( !group_blacklist.count( group ) )
  399. groups.emplace_back( group );
  400. }
  401. aCfg->SetPath( "/" );
  402. }
  403. return ret;
  404. }
  405. bool PROJECT_FILE::SaveToFile( const wxString& aDirectory, bool aForce )
  406. {
  407. wxASSERT( m_project );
  408. Set( "meta.filename", m_project->GetProjectName() + "." + ProjectFileExtension );
  409. return JSON_SETTINGS::SaveToFile( aDirectory, aForce );
  410. }
  411. bool PROJECT_FILE::SaveAs( const wxString& aDirectory, const wxString& aFile )
  412. {
  413. Set( "meta.filename", aFile + "." + ProjectFileExtension );
  414. SetFilename( aFile );
  415. // While performing Save As, we have already checked that we can write to the directory
  416. // so don't carry the previous flag
  417. SetReadOnly( false );
  418. return JSON_SETTINGS::SaveToFile( aDirectory, true );
  419. }
  420. wxString PROJECT_FILE::getFileExt() const
  421. {
  422. return ProjectFileExtension;
  423. }
  424. wxString PROJECT_FILE::getLegacyFileExt() const
  425. {
  426. return LegacyProjectFileExtension;
  427. }
  428. void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair )
  429. {
  430. aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } );
  431. }
  432. void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair )
  433. {
  434. wxCHECK( aJson.is_array() && aJson.size() == 2, /* void */ );
  435. aPair.first = KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) );
  436. aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 );
  437. }