KiCad PCB EDA Suite
Loading...
Searching...
No Matches
STRING_INCREMENTER Class Reference

Heuristically increment a string's n'th part from the right. More...

#include <increment.h>

Public Member Functions

void SetSkipIOSQXZ (bool aSkip)
 If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.
 
void SetAlphabeticMaxIndex (int aMaxIndex)
 Set the maximum index for alphabetic parts.
 
std::optional< wxString > Increment (const wxString &aStr, int aDelta, size_t aRightIndex) const
 Increment the n-th part from the right of the given string.
 

Private Types

enum class  STRING_PART_TYPE { ALPHABETIC , INTEGER , SKIP }
 

Private Member Functions

bool incrementPart (wxString &aPart, STRING_PART_TYPE aType, int aDelta) const
 

Private Attributes

bool m_SkipIOSQXZ = true
 
int m_AlphabeticMaxIndex = 50
 

Detailed Description

Heuristically increment a string's n'th part from the right.

For example: incrementing the 0th part of A1 -> A2 1st part of A1 -> B1

This is a bit subjective as to what represents suitable "incrementable" parts, but it tries to be smart about it.

Definition at line 47 of file increment.h.

Member Enumeration Documentation

◆ STRING_PART_TYPE

enum class STRING_INCREMENTER::STRING_PART_TYPE
strongprivate
Enumerator
ALPHABETIC 
INTEGER 
SKIP 

Definition at line 74 of file increment.h.

Member Function Documentation

◆ Increment()

std::optional< wxString > STRING_INCREMENTER::Increment ( const wxString &  aStr,
int  aDelta,
size_t  aRightIndex 
) const

Increment the n-th part from the right of the given string.

Definition at line 85 of file increment.cpp.

References ALPHABETIC, incrementPart(), INTEGER, and SKIP.

Referenced by BOOST_AUTO_TEST_CASE(), SCH_EDIT_TOOL::Increment(), and SYMBOL_EDITOR_EDIT_TOOL::Increment().

◆ incrementPart()

bool STRING_INCREMENTER::incrementPart ( wxString &  aPart,
STRING_PART_TYPE  aType,
int  aDelta 
) const
private

◆ SetAlphabeticMaxIndex()

void STRING_INCREMENTER::SetAlphabeticMaxIndex ( int  aMaxIndex)
inline

Set the maximum index for alphabetic parts.

This means that if the index is greater than this, it will be treated as un-incrementable. This is to avoid incrementing things like "TX" or "CAN", which would be indexes of hundreds (unlikely to be a BGA row prefix, for example).

Setting < 0 disables the check (no limit)

Definition at line 66 of file increment.h.

◆ SetSkipIOSQXZ()

void STRING_INCREMENTER::SetSkipIOSQXZ ( bool  aSkip)
inline

If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.

(if one is already there, increment it anyway).

Definition at line 54 of file increment.h.

Referenced by BOOST_AUTO_TEST_CASE(), SCH_EDIT_TOOL::Increment(), SYMBOL_EDITOR_EDIT_TOOL::Increment(), and EDIT_TOOL::Increment().

Member Data Documentation

◆ m_AlphabeticMaxIndex

int STRING_INCREMENTER::m_AlphabeticMaxIndex = 50
private

Definition at line 84 of file increment.h.

Referenced by incrementPart().

◆ m_SkipIOSQXZ

bool STRING_INCREMENTER::m_SkipIOSQXZ = true
private

Definition at line 83 of file increment.h.

Referenced by incrementPart().


The documentation for this class was generated from the following files: