KiCad PCB EDA Suite
Loading...
Searching...
No Matches
increment.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <optional>
23
24#include <wx/string.h>
25
26#include <kicommon.h>
27
31KICOMMON_API bool IncrementString( wxString& aStr, int aDelta );
32
33
44{
45public:
50 void SetSkipIOSQXZ( bool aSkip ) { m_SkipIOSQXZ = aSkip; }
51
62 void SetAlphabeticMaxIndex( int aMaxIndex ) { m_AlphabeticMaxIndex = aMaxIndex; }
63
67 std::optional<wxString> Increment( const wxString& aStr, int aDelta, size_t aRightIndex ) const;
68
69private:
76
77 bool incrementPart( wxString& aPart, STRING_PART_TYPE aType, int aDelta ) const;
78
79 bool m_SkipIOSQXZ = true;
81};
82
91KICOMMON_API int IndexFromAlphabetic( const wxString& aStr, const wxString& aAlphabet );
92
101KICOMMON_API wxString AlphabeticFromIndex( size_t aN, const wxString& aAlphabet,
102 bool aZeroBasedNonUnitCols );
Heuristically increment a string's n'th part from the right.
Definition increment.h:44
void SetAlphabeticMaxIndex(int aMaxIndex)
Set the maximum index for alphabetic parts.
Definition increment.h:62
void SetSkipIOSQXZ(bool aSkip)
If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.
Definition increment.h:50
KICOMMON_API wxString AlphabeticFromIndex(size_t aN, const wxString &aAlphabet, bool aZeroBasedNonUnitCols)
Get an alphabetic string like A, B, ... Z, AA, AB, ... ZZ, AAA, ...
KICOMMON_API int IndexFromAlphabetic(const wxString &aStr, const wxString &aAlphabet)
Attempt to convert a string to an integer, assuming it is an alphabetic string like "A",...
KICOMMON_API bool IncrementString(wxString &aStr, int aDelta)
Generic string incrementer.
Definition increment.cpp:29
#define KICOMMON_API
Definition kicommon.h:27