KiCad PCB EDA Suite
Loading...
Searching...
No Matches
parameters.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) 2020 Jon Evans <[email protected]>
5 * Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PARAMETERS_H
22#define PARAMETERS_H
23
24#include <set>
25#include <string>
26#include <utility>
27#include <math/util.h>
28
29#include <optional>
30#include <gal/color4d.h>
33#include <kicommon.h>
34
36{
37public:
38 PARAM_BASE( std::string aJsonPath, bool aReadOnly ) :
39 m_path( std::move( aJsonPath ) ),
40 m_readOnly( aReadOnly ),
41 m_clearUnknownKeys( false )
42 {}
43
44 virtual ~PARAM_BASE() = default;
45
51 virtual void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const = 0;
52
57 virtual void Store( JSON_SETTINGS* aSettings ) const = 0;
58
59 virtual void SetDefault() = 0;
60
66 virtual bool MatchesFile( JSON_SETTINGS* aSettings ) const = 0;
67
72 const std::string& GetJsonPath() const { return m_path; }
73
78 bool ClearUnknownKeys() const { return m_clearUnknownKeys; }
79
80protected:
81 std::string m_path;
86};
87
88
89template<typename ValueType>
90class PARAM : public PARAM_BASE
91{
92public:
93 PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
94 bool aReadOnly = false ) :
95 PARAM_BASE( aJsonPath, aReadOnly ),
96 m_min(),
97 m_max(),
98 m_use_minmax( false ),
99 m_ptr( aPtr ),
100 m_default( std::move( aDefault ) )
101 { }
102
103 PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, ValueType aMin,
104 ValueType aMax, bool aReadOnly = false ) :
105 PARAM_BASE( aJsonPath, aReadOnly ),
106 m_min( std::move( aMin ) ),
107 m_max( std::move( aMax ) ),
108 m_use_minmax( true ),
109 m_ptr( aPtr ),
110 m_default( std::move( aDefault ) )
111 { }
112
113 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
114 {
115 if( m_readOnly )
116 return;
117
118 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
119 {
120 ValueType val = *optval;
121
122 if( m_use_minmax )
123 {
124 if( m_max < val || val < m_min )
125 val = m_default;
126 }
127
128 *m_ptr = val;
129 }
130 else if( aResetIfMissing )
131 {
132 *m_ptr = m_default;
133 }
134 }
135
136 void Store( JSON_SETTINGS* aSettings ) const override
137 {
138 aSettings->Set<ValueType>( m_path, *m_ptr );
139 }
140
141 ValueType GetDefault() const
142 {
143 return m_default;
144 }
145
146 void SetDefault() override
147 {
148 *m_ptr = m_default;
149 }
150
151 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
152 {
153 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
154 return *optval == *m_ptr;
155
156 return false;
157 }
158
159private:
160 ValueType m_min;
161 ValueType m_max;
163
164protected:
165 ValueType* m_ptr;
166 ValueType m_default;
167};
168
172class KICOMMON_API PARAM_PATH : public PARAM<wxString>
173{
174public:
175 PARAM_PATH( const std::string& aJsonPath, wxString* aPtr, const wxString& aDefault,
176 bool aReadOnly = false ) :
177 PARAM( aJsonPath, aPtr, aDefault, aReadOnly )
178 { }
179
180 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
181 {
182 if( m_readOnly )
183 return;
184
185 PARAM::Load( aSettings, aResetIfMissing );
186
187 *m_ptr = fromFileFormat( *m_ptr );
188 }
189
190 void Store( JSON_SETTINGS* aSettings ) const override
191 {
192 aSettings->Set<wxString>( m_path, toFileFormat( *m_ptr ) );
193 }
194
195 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
196 {
197 if( std::optional<wxString> optval = aSettings->Get<wxString>( m_path ) )
198 return fromFileFormat( *optval ) == *m_ptr;
199
200 return false;
201 }
202
203private:
204 wxString toFileFormat( const wxString& aString ) const
205 {
206 wxString ret = aString;
207 ret.Replace( wxT( "\\" ), wxT( "/" ) );
208 return ret;
209 }
210
211 wxString fromFileFormat( const wxString& aString ) const
212 {
213 wxString ret = aString;
214#ifdef __WINDOWS__
215 ret.Replace( wxT( "/" ), wxT( "\\" ) );
216#endif
217 return ret;
218 }
219};
220
224template<typename EnumType>
225class PARAM_ENUM : public PARAM_BASE
226{
227public:
228 PARAM_ENUM( const std::string& aJsonPath, EnumType* aPtr, EnumType aDefault,
229 EnumType aMin, EnumType aMax, bool aReadOnly = false ) :
230 PARAM_BASE( aJsonPath, aReadOnly ),
231 m_ptr( aPtr ),
232 m_min( aMin ),
233 m_max( aMax ),
234 m_default( aDefault )
235 {
236 }
237
238 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
239 {
240 if( m_readOnly )
241 return;
242
243 if( std::optional<int> val = aSettings->Get<int>( m_path ) )
244 {
245 if( *val >= static_cast<int>( m_min ) && *val <= static_cast<int>( m_max ) )
246 *m_ptr = static_cast<EnumType>( *val );
247 else if( aResetIfMissing )
248 *m_ptr = m_default;
249
250 }
251 else if( aResetIfMissing )
252 {
253 *m_ptr = m_default;
254 }
255 }
256
257 void Store( JSON_SETTINGS* aSettings ) const override
258 {
259 aSettings->Set<int>( m_path, static_cast<int>( *m_ptr ) );
260 }
261
262 EnumType GetDefault() const
263 {
264 return m_default;
265 }
266
267 void SetDefault() override
268 {
269 *m_ptr = m_default;
270 }
271
272 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
273 {
274 if( std::optional<int> val = aSettings->Get<int>( m_path ) )
275 return *val == static_cast<int>( *m_ptr );
276
277 return false;
278 }
279
280private:
281 EnumType* m_ptr;
282 EnumType m_min;
283 EnumType m_max;
284 EnumType m_default;
285};
286
291template<typename ValueType>
293{
294public:
295 PARAM_LAMBDA( const std::string& aJsonPath, std::function<ValueType()> aGetter,
296 std::function<void( ValueType )> aSetter, ValueType aDefault,
297 bool aReadOnly = false ) :
298 PARAM_BASE( aJsonPath, aReadOnly ),
299 m_default( std::move( aDefault ) ),
300 m_getter( std::move( aGetter ) ),
301 m_setter( std::move( aSetter ) )
302 {
303 }
304
305 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
306 {
307 if( m_readOnly )
308 return;
309
310 if( std::is_same<ValueType, nlohmann::json>::value )
311 {
312 if( std::optional<nlohmann::json> optval = aSettings->GetJson( m_path ) )
313 m_setter( *optval );
314 else
316 }
317 else
318 {
319 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
320 m_setter( *optval );
321 else
323 }
324 }
325
326 void Store( JSON_SETTINGS* aSettings ) const override
327 {
328 try
329 {
330 aSettings->Set<ValueType>( m_path, m_getter() );
331 }
332 catch( ... )
333 {
334 }
335 }
336
337 ValueType GetDefault() const
338 {
339 return m_default;
340 }
341
342 void SetDefault() override
343 {
345 }
346
347 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
348 {
349 if( std::is_same<ValueType, nlohmann::json>::value )
350 {
351 if( std::optional<nlohmann::json> optval = aSettings->GetJson( m_path ) )
352 return *optval == m_getter();
353 }
354 else
355 {
356 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
357 return *optval == m_getter();
358 }
359
360 // Not in file
361 return false;
362 }
363
364private:
365 ValueType m_default;
366 std::function<ValueType()> m_getter;
367 std::function<void( ValueType )> m_setter;
368};
369
370#ifdef __WINDOWS__
371template class KICOMMON_API PARAM_LAMBDA<bool>;
372template class KICOMMON_API PARAM_LAMBDA<int>;
375#else
376extern template class APIVISIBLE PARAM_LAMBDA<bool>;
377extern template class APIVISIBLE PARAM_LAMBDA<int>;
378extern template class APIVISIBLE PARAM_LAMBDA<nlohmann::json>;
379extern template class APIVISIBLE PARAM_LAMBDA<std::string>;
380#endif
381
388template<typename ValueType>
390{
391public:
392 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
393 double aScale = 1.0, bool aReadOnly = false ) :
394 PARAM_BASE( aJsonPath, aReadOnly ),
395 m_ptr( aPtr ),
396 m_default( aDefault ),
397 m_min(),
398 m_max(),
399 m_use_minmax( false ),
400 m_scale( aScale ),
401 m_invScale( 1.0 / aScale )
402 { }
403
404 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
405 ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) :
406 PARAM_BASE( aJsonPath, aReadOnly ),
407 m_ptr( aPtr ),
408 m_default( aDefault ),
409 m_min( aMin ),
410 m_max( aMax ),
411 m_use_minmax( true ),
412 m_scale( aScale ),
413 m_invScale( 1.0 / aScale )
414 { }
415
416 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
417 {
418 if( m_readOnly )
419 return;
420
421 double dval = m_default / m_invScale;
422
423 if( std::optional<double> optval = aSettings->Get<double>( m_path ) )
424 dval = *optval;
425 else if( !aResetIfMissing )
426 return;
427
428 ValueType val = KiROUND<double, ValueType>( dval * m_invScale );
429
430 if( m_use_minmax )
431 {
432 if( val > m_max || val < m_min )
433 val = m_default;
434 }
435
436 *m_ptr = val;
437 }
438
439 void Store( JSON_SETTINGS* aSettings) const override
440 {
441 aSettings->Set<double>( m_path, *m_ptr / m_invScale );
442 }
443
444 ValueType GetDefault() const
445 {
446 return m_default;
447 }
448
449 virtual void SetDefault() override
450 {
451 *m_ptr = m_default;
452 }
453
454 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
455 {
456 if( std::optional<double> optval = aSettings->Get<double>( m_path ) )
457 return *optval == ( *m_ptr / m_invScale );
458
459 return false;
460 }
461
462private:
463 ValueType* m_ptr;
464 ValueType m_default;
465 ValueType m_min;
466 ValueType m_max;
468 double m_scale;
470};
471
472template<typename Type>
473class PARAM_LIST : public PARAM_BASE
474{
475public:
476 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
477 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
478 PARAM_BASE( aJsonPath, aReadOnly ),
479 m_ptr( aPtr ),
480 m_default( aDefault )
481 { }
482
483 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
484 std::vector<Type> aDefault, bool aReadOnly = false ) :
485 PARAM_BASE( aJsonPath, aReadOnly ),
486 m_ptr( aPtr ),
487 m_default( std::move( aDefault ) )
488 { }
489
490 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
491 {
492 if( m_readOnly )
493 return;
494
495 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
496 {
497 std::vector<Type> val;
498
499 if( js->is_array() )
500 {
501 for( const auto& el : js->items() )
502 val.push_back( el.value().get<Type>() );
503 }
504
505 *m_ptr = val;
506 }
507 else if( aResetIfMissing )
508 *m_ptr = m_default;
509 }
510
511 void Store( JSON_SETTINGS* aSettings ) const override
512 {
513 nlohmann::json js = nlohmann::json::array();
514
515 for( const auto& el : *m_ptr )
516 js.push_back( el );
517
518 aSettings->Set<nlohmann::json>( m_path, js );
519 }
520
521 void SetDefault() override
522 {
523 *m_ptr = m_default;
524 }
525
526 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
527 {
528 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
529 {
530 if( js->is_array() )
531 {
532 std::vector<Type> val;
533
534 for( const auto& el : js->items() )
535 {
536 try
537 {
538 val.emplace_back( el.value().get<Type>() );
539 }
540 catch( ... )
541 {
542 // Probably typecast didn't work; skip this element
543 }
544 }
545
546 return val == *m_ptr;
547 }
548 }
549
550 return false;
551 }
552
553protected:
554 std::vector<Type>* m_ptr;
555 std::vector<Type> m_default;
556};
557
558
559#ifdef __WINDOWS__
560template class KICOMMON_API PARAM_LIST<bool>;
561template class KICOMMON_API PARAM_LIST<int>;
562template class KICOMMON_API PARAM_LIST<double>;
564template class KICOMMON_API PARAM_LIST<GRID>;
566#else
567extern template class APIVISIBLE PARAM_LIST<bool>;
568extern template class APIVISIBLE PARAM_LIST<int>;
569extern template class APIVISIBLE PARAM_LIST<double>;
570extern template class APIVISIBLE PARAM_LIST<KIGFX::COLOR4D>;
571extern template class APIVISIBLE PARAM_LIST<GRID>;
572extern template class APIVISIBLE PARAM_LIST<wxString>;
573#endif
574
575
576template<typename Type>
577class PARAM_SET : public PARAM_BASE
578{
579public:
580 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
581 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
582 PARAM_BASE( aJsonPath, aReadOnly ),
583 m_ptr( aPtr ),
584 m_default( aDefault )
585 { }
586
587 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
588 std::set<Type> aDefault, bool aReadOnly = false ) :
589 PARAM_BASE( aJsonPath, aReadOnly ),
590 m_ptr( aPtr ),
591 m_default( aDefault )
592 { }
593
594 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
595 {
596 if( m_readOnly )
597 return;
598
599 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
600 {
601 std::set<Type> val;
602
603 if( js->is_array() )
604 {
605 for( const auto& el : js->items() )
606 val.insert( el.value().get<Type>() );
607 }
608
609 *m_ptr = val;
610 }
611 else if( aResetIfMissing )
612 *m_ptr = m_default;
613 }
614
615 void Store( JSON_SETTINGS* aSettings) const override
616 {
617 nlohmann::json js = nlohmann::json::array();
618
619 for( const auto& el : *m_ptr )
620 js.push_back( el );
621
622 aSettings->Set<nlohmann::json>( m_path, js );
623 }
624
625
626 void SetDefault() override
627 {
628 *m_ptr = m_default;
629 }
630
631 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
632 {
633 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
634 {
635 if( js->is_array() )
636 {
637 std::set<Type> val;
638
639 for( const auto& el : js->items() )
640 val.insert( el.value().get<Type>() );
641
642 return val == *m_ptr;
643 }
644 }
645
646 return false;
647 }
648
649protected:
650 std::set<Type>* m_ptr;
651 std::set<Type> m_default;
652};
653
654#ifdef __WINDOWS__
655template class KICOMMON_API PARAM_SET<wxString>;
656#else
657extern template class APIVISIBLE PARAM_SET<wxString>;
658#endif
659
665{
666public:
667 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
668 std::initializer_list<wxString> aDefault, bool aReadOnly = false ) :
669 PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
670 { }
671
672 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
673 std::vector<wxString> aDefault, bool aReadOnly = false ) :
674 PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
675 { }
676
677 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
678 {
679 if( m_readOnly )
680 return;
681
682 PARAM_LIST::Load( aSettings, aResetIfMissing );
683
684 for( size_t i = 0; i < m_ptr->size(); i++ )
685 ( *m_ptr )[i] = fromFileFormat( ( *m_ptr )[i] );
686 }
687
688 void Store( JSON_SETTINGS* aSettings) const override;
689
690 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
691
692private:
693 wxString toFileFormat( const wxString& aString ) const
694 {
695 wxString ret = aString;
696 ret.Replace( wxT( "\\" ), wxT( "/" ) );
697 return ret;
698 }
699
700 wxString fromFileFormat( const wxString& aString ) const
701 {
702 wxString ret = aString;
703#ifdef __WINDOWS__
704 ret.Replace( wxT( "/" ), wxT( "\\" ) );
705#endif
706 return ret;
707 }
708};
709
722template<typename Value>
723class PARAM_MAP : public PARAM_BASE
724{
725public:
726 PARAM_MAP( const std::string& aJsonPath, std::map<std::string, Value>* aPtr,
727 std::initializer_list<std::pair<const std::string, Value>> aDefault,
728 bool aReadOnly = false ) :
729 PARAM_BASE( aJsonPath, aReadOnly ),
730 m_ptr( aPtr ),
731 m_default( aDefault )
732 { }
733
734 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
735 {
736 if( m_readOnly )
737 return;
738
739 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
740 {
741 if( js->is_object() )
742 {
743 m_ptr->clear();
744
745 for( const auto& el : js->items() )
746 ( *m_ptr )[el.key()] = el.value().get<Value>();
747 }
748 }
749 else if( aResetIfMissing )
750 *m_ptr = m_default;
751 }
752
753 void Store( JSON_SETTINGS* aSettings) const override
754 {
755 nlohmann::json js( {} );
756
757 for( const auto& el : *m_ptr )
758 js[el.first] = el.second;
759
760 aSettings->Set<nlohmann::json>( m_path, js );
761 }
762
763 virtual void SetDefault() override
764 {
765 *m_ptr = m_default;
766 }
767
768 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
769 {
770 if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
771 {
772 if( js->is_object() )
773 {
774 if( m_ptr->size() != js->size() )
775 return false;
776
777 std::map<std::string, Value> val;
778
779 for( const auto& el : js->items() )
780 val[el.key()] = el.value().get<Value>();
781
782 return val == *m_ptr;
783 }
784 }
785
786 return false;
787 }
788
789private:
790 std::map<std::string, Value>* m_ptr;
791 std::map<std::string, Value> m_default;
792};
793
794
795#ifdef __WINDOWS__
796template class KICOMMON_API PARAM_MAP<int>;
797template class KICOMMON_API PARAM_MAP<double>;
798template class KICOMMON_API PARAM_MAP<bool>;
799#else
800extern template class APIVISIBLE PARAM_MAP<int>;
801extern template class APIVISIBLE PARAM_MAP<double>;
802extern template class APIVISIBLE PARAM_MAP<bool>;
803#endif
804
805
810{
811public:
812 PARAM_WXSTRING_MAP( const std::string& aJsonPath, std::map<wxString, wxString>* aPtr,
813 std::initializer_list<std::pair<const wxString, wxString>> aDefault,
814 bool aReadOnly = false, bool aArrayBehavior = false ) :
815 PARAM_BASE( aJsonPath, aReadOnly ),
816 m_ptr( aPtr ),
817 m_default( aDefault )
818 {
819 m_clearUnknownKeys = aArrayBehavior;
820 }
821
822 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
823
824 void Store( JSON_SETTINGS* aSettings) const override;
825
826 virtual void SetDefault() override
827 {
828 *m_ptr = m_default;
829 }
830
831 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
832
833private:
834 std::map<wxString, wxString>* m_ptr;
835 std::map<wxString, wxString> m_default;
836};
837
838#endif
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
reads a model file and creates a generic display structure
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
std::optional< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
PARAM_BASE(std::string aJsonPath, bool aReadOnly)
Definition: parameters.h:38
bool m_readOnly
Indicates param pointer should never be overwritten.
Definition: parameters.h:82
const std::string & GetJsonPath() const
Definition: parameters.h:72
virtual void SetDefault()=0
bool m_clearUnknownKeys
Keys should be cleared from source rather than merged.
Definition: parameters.h:83
virtual void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const =0
Loads the value of this parameter from JSON to the underlying storage.
bool ClearUnknownKeys() const
Definition: parameters.h:78
virtual void Store(JSON_SETTINGS *aSettings) const =0
Stores the value of this parameter to the given JSON_SETTINGS object.
virtual ~PARAM_BASE()=default
std::string m_path
Address of the param in the json files.
Definition: parameters.h:81
virtual bool MatchesFile(JSON_SETTINGS *aSettings) const =0
Checks whether the parameter in memory matches the one in a given JSON file.
Stores an enum as an integer.
Definition: parameters.h:226
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:238
EnumType m_default
Definition: parameters.h:284
void SetDefault() override
Definition: parameters.h:267
EnumType GetDefault() const
Definition: parameters.h:262
EnumType * m_ptr
Definition: parameters.h:281
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition: parameters.h:228
EnumType m_min
Definition: parameters.h:282
EnumType m_max
Definition: parameters.h:283
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:272
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:257
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:293
std::function< void(ValueType)> m_setter
Definition: parameters.h:367
std::function< ValueType()> m_getter
Definition: parameters.h:366
ValueType m_default
Definition: parameters.h:365
void SetDefault() override
Definition: parameters.h:342
ValueType GetDefault() const
Definition: parameters.h:337
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:295
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:305
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:326
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:347
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:490
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:511
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:476
std::vector< Type > * m_ptr
Definition: parameters.h:554
std::vector< Type > m_default
Definition: parameters.h:555
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:483
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:526
void SetDefault() override
Definition: parameters.h:521
Represents a map of <std::string, Value>.
Definition: parameters.h:724
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:768
virtual void SetDefault() override
Definition: parameters.h:763
PARAM_MAP(const std::string &aJsonPath, std::map< std::string, Value > *aPtr, std::initializer_list< std::pair< const std::string, Value > > aDefault, bool aReadOnly=false)
Definition: parameters.h:726
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:753
std::map< std::string, Value > m_default
Definition: parameters.h:791
std::map< std::string, Value > * m_ptr
Definition: parameters.h:790
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:734
Represents a list of strings holding directory paths.
Definition: parameters.h:665
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:693
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:677
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:700
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:667
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:672
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:173
PARAM_PATH(const std::string &aJsonPath, wxString *aPtr, const wxString &aDefault, bool aReadOnly=false)
Definition: parameters.h:175
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:211
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:190
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:204
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:195
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:180
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:390
ValueType GetDefault() const
Definition: parameters.h:444
bool m_use_minmax
Definition: parameters.h:467
ValueType m_default
Definition: parameters.h:464
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:439
ValueType m_max
Definition: parameters.h:466
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:454
double m_scale
Definition: parameters.h:468
ValueType * m_ptr
Definition: parameters.h:463
double m_invScale
Definition: parameters.h:469
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:416
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:392
virtual void SetDefault() override
Definition: parameters.h:449
ValueType m_min
Definition: parameters.h:465
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:404
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:594
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:580
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:631
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::set< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:587
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:615
std::set< Type > * m_ptr
Definition: parameters.h:650
void SetDefault() override
Definition: parameters.h:626
std::set< Type > m_default
Definition: parameters.h:651
A helper for <wxString, wxString> maps.
Definition: parameters.h:810
virtual void SetDefault() override
Definition: parameters.h:826
std::map< wxString, wxString > * m_ptr
Definition: parameters.h:834
PARAM_WXSTRING_MAP(const std::string &aJsonPath, std::map< wxString, wxString > *aPtr, std::initializer_list< std::pair< const wxString, wxString > > aDefault, bool aReadOnly=false, bool aArrayBehavior=false)
Definition: parameters.h:812
std::map< wxString, wxString > m_default
Definition: parameters.h:835
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:113
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:151
void SetDefault() override
Definition: parameters.h:146
ValueType * m_ptr
Definition: parameters.h:165
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, bool aReadOnly=false)
Definition: parameters.h:103
ValueType m_default
Definition: parameters.h:166
bool m_use_minmax
Definition: parameters.h:162
ValueType GetDefault() const
Definition: parameters.h:141
ValueType m_min
Definition: parameters.h:160
ValueType m_max
Definition: parameters.h:161
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:93
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:136
#define APIVISIBLE
Definition: import_export.h:55
#define KICOMMON_API
Definition: kicommon.h:28
STL namespace.