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 (C) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <optional>
27
28#include <wx/string.h>
29
30#include <kicommon.h>
31
35KICOMMON_API bool IncrementString( wxString& aStr, int aDelta );
36
37
48{
49public:
54 void SetSkipIOSQXZ( bool aSkip ) { m_SkipIOSQXZ = aSkip; }
55
66 void SetAlphabeticMaxIndex( int aMaxIndex ) { m_AlphabeticMaxIndex = aMaxIndex; }
67
71 std::optional<wxString> Increment( const wxString& aStr, int aDelta, size_t aRightIndex ) const;
72
73private:
75 {
76 ALPHABETIC,
77 INTEGER,
78 SKIP,
79 };
80
81 bool incrementPart( wxString& aPart, STRING_PART_TYPE aType, int aDelta ) const;
82
83 bool m_SkipIOSQXZ = true;
84 int m_AlphabeticMaxIndex = 50;
85};
86
95KICOMMON_API int IndexFromAlphabetic( const wxString& aStr, const wxString& aAlphabet );
96
105KICOMMON_API wxString AlphabeticFromIndex( size_t aN, const wxString& aAlphabet,
106 bool aZeroBasedNonUnitCols );
Heuristically increment a string's n'th part from the right.
Definition: increment.h:48
void SetAlphabeticMaxIndex(int aMaxIndex)
Set the maximum index for alphabetic parts.
Definition: increment.h:66
void SetSkipIOSQXZ(bool aSkip)
If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.
Definition: increment.h:54
KICOMMON_API wxString AlphabeticFromIndex(size_t aN, const wxString &aAlphabet, bool aZeroBasedNonUnitCols)
Get an alphabetic string like A, B, ... Z, AA, AB, ... ZZ, AAA, ...
Definition: increment.cpp:258
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",...
Definition: increment.cpp:236
KICOMMON_API bool IncrementString(wxString &aStr, int aDelta)
Generic string incrementer.
Definition: increment.cpp:33
#define KICOMMON_API
Definition: kicommon.h:28