KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_rules_downgrade.h File Reference
#include <cctype>
#include <string>
#include <vector>
#include <wx/intl.h>
#include <downgrade_scan.h>
#include <downgrade_target.h>

Go to the source code of this file.

Classes

struct  DRC_RULES_FILTER_RESULT
 

Functions

wxString ExtractDrcRuleName (const std::string &aBlock)
 The rule name following a "(rule" head, for the report.
 
std::string StripDrcComments (const std::string &aText)
 Drop # comments, keeping quoted strings intact, so a comment cannot trip the token or unit scans below.
 
bool DrcRuleUnsupportedByTarget (const std::string &aRawBlock, const DOWNGRADE_TARGET &aTarget)
 True if the rule text uses something the target's parser or evaluator cannot handle.
 
bool IsDrcCommentAtStartOfLine (const std::string &aText, size_t aOffset)
 Match the full-line comment syntax of DSNLEXER, used by both target readers.
 
DRC_RULES_FILTER_RESULT FilterDrcRulesForTarget (const wxString &aRulesText, const DOWNGRADE_TARGET &aTarget)
 Filter a .kicad_dru file for the target.
 

Variables

static constexpr DATED_TOKEN DRC_RULE_TOKENS []
 Rule-file tokens dated by the board format of the first release that parses them.
 
static constexpr DATED_TOKEN DRC_RULE_PROPERTIES []
 Property names exposed by PCB expressions, normalized like the evaluator's underscore aliases.
 

Function Documentation

◆ DrcRuleUnsupportedByTarget()

bool DrcRuleUnsupportedByTarget ( const std::string & aRawBlock,
const DOWNGRADE_TARGET & aTarget )
inline

True if the rule text uses something the target's parser or evaluator cannot handle.

Definition at line 270 of file drc_rules_downgrade.h.

References ContainsSexprValue(), DRC_RULE_PROPERTIES, DRC_RULE_TOKENS, end, isWordChar(), DOWNGRADE_TARGET::m_boardVersion, name, next(), StripDrcComments(), and StripSexprStrings().

Referenced by FilterDrcRulesForTarget().

◆ ExtractDrcRuleName()

wxString ExtractDrcRuleName ( const std::string & aBlock)
inline

The rule name following a "(rule" head, for the report.

Definition at line 180 of file drc_rules_downgrade.h.

References name.

Referenced by FilterDrcRulesForTarget().

◆ FilterDrcRulesForTarget()

DRC_RULES_FILTER_RESULT FilterDrcRulesForTarget ( const wxString & aRulesText,
const DOWNGRADE_TARGET & aTarget )
inline

Filter a .kicad_dru file for the target.

Surviving rules are kept byte-identical, dropped rules are listed by name, and the version header is rewritten to what the target writes. A syntax error sets m_error; callers must refuse to write the partial result.

Definition at line 525 of file drc_rules_downgrade.h.

References _, DrcRuleUnsupportedByTarget(), ExtractDrcRuleName(), IsDrcCommentAtStartOfLine(), result, and text.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ClassifyProjectForDowngrade(), and ExportProjectForDowngrade().

◆ IsDrcCommentAtStartOfLine()

bool IsDrcCommentAtStartOfLine ( const std::string & aText,
size_t aOffset )
inline

Match the full-line comment syntax of DSNLEXER, used by both target readers.

Definition at line 510 of file drc_rules_downgrade.h.

Referenced by FilterDrcRulesForTarget().

◆ StripDrcComments()

std::string StripDrcComments ( const std::string & aText)
inline

Drop # comments, keeping quoted strings intact, so a comment cannot trip the token or unit scans below.

Definition at line 222 of file drc_rules_downgrade.h.

Referenced by DrcRuleUnsupportedByTarget().

Variable Documentation

◆ DRC_RULE_PROPERTIES

DATED_TOKEN DRC_RULE_PROPERTIES[]
staticconstexpr

Property names exposed by PCB expressions, normalized like the evaluator's underscore aliases.

A property absent from the released registry makes the whole rules file fail to compile.

Definition at line 73 of file drc_rules_downgrade.h.

Referenced by DrcRuleUnsupportedByTarget().

◆ DRC_RULE_TOKENS

DATED_TOKEN DRC_RULE_TOKENS[]
staticconstexpr

Rule-file tokens dated by the board format of the first release that parses them.

A rule using a token newer than the target is dropped. Tokens dated 99999999 have no released parser yet and drop for every target.

Definition at line 39 of file drc_rules_downgrade.h.

Referenced by DrcRuleUnsupportedByTarget().