forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsc_option.cpp
956 lines (828 loc) · 24.7 KB
/
sc_option.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#include "sc_option.hpp"
#include <sstream>
#include <iostream>
#include "util/io.hpp"
#include "sc_util.hpp"
namespace { // UNNAMED NAMESPACE ============================================
// is_white_space ===========================================================
bool is_white_space( char c )
{
return ( c == ' ' || c == '\t' || c == '\n' || c == '\r' );
}
char* skip_white_space( char* s )
{
while ( is_white_space( *s ) )
++s;
return s;
}
// option_db_t::open_file ===================================================
io::cfile open_file( const std::vector<std::string>& splits, const std::string& name, std::string& actual_name )
{
for ( size_t i = 0; i < splits.size(); i++ )
{
auto file_path = splits[ i ] + "/" + name;
FILE* f = io::fopen( file_path, "r" );
if ( f )
{
actual_name = file_path;
return io::cfile(f);
}
}
actual_name = name;
return io::cfile( name, "r" );
}
std::string base_name( const std::string& file_path )
{
#if defined( SC_WINDOWS )
auto base_it = file_path.rfind('\\');
#else
auto base_it = file_path.rfind('/');
#endif
std::string file_name;
if ( base_it != std::string::npos )
{
file_name = file_path.substr( base_it + 1 );
}
else
{
file_name = file_path;
}
auto extension_it = file_name.find('.');
std::string base_name;
if ( extension_it != std::string::npos )
{
base_name = file_name.substr( 0, extension_it );
}
else
{
base_name = file_name;
}
return base_name;
}
void do_replace( const option_db_t& opts, std::string& str, std::string::size_type begin, int depth )
{
if ( depth > 10 )
{
std::stringstream s;
s << "Nesting depth exceeded for: '" << str << "'";
throw std::invalid_argument( s.str() );
}
if ( begin == std::string::npos )
{
return;
}
auto next = str.find( "$(", begin + 2 );
if ( next != std::string::npos )
{
do_replace( opts, str, next, ++depth );
}
auto end = str.find( ")", begin + 2 );
if ( end == std::string::npos )
{
std::stringstream s;
s << "Unbalanced parenthesis in template variable for: '" << str << "'";
throw std::invalid_argument( s.str() );
}
auto var = str.substr( begin + 2, ( end - begin ) - 2 );
if ( opts.var_map.find( var ) == opts.var_map.end() )
{
std::stringstream s;
s << "Missing template variable: '" << var << "'";
throw std::invalid_argument( s.str() );
}
str.replace( begin, end - begin + 1, opts.var_map.at( var ) );
}
} // UNNAMED NAMESPACE ======================================================
namespace opts {
/* Option helper class
* Stores a reference of given type T
*/
template<class T>
struct opts_helper_t : public option_t
{
typedef opts_helper_t<T> base_t;
opts_helper_t( const std::string& name, T& ref ) :
option_t( name ),
_ref( ref )
{ }
protected:
T& _ref;
};
struct opt_string_t : public option_t
{
opt_string_t( const std::string& name, std::string& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref = v;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
std::string& _ref;
};
struct opt_append_t : public option_t
{
opt_append_t( const std::string& name, std::string& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref += v;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "+=" << _ref << "\n";
return stream;
}
private:
std::string& _ref;
};
struct opt_uint64_t : public option_t
{
opt_uint64_t( const std::string& name, uint64_t& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
#if defined( SC_WINDOWS ) && defined( SC_VS )
_ref = _strtoui64( v.c_str(), nullptr, 10 );
#else
_ref = strtoull( v.c_str(), nullptr, 10 );
#endif
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
uint64_t& _ref;
};
struct opt_int_t : public option_t
{
opt_int_t( const std::string& name, int& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref = strtol( v.c_str(), nullptr, 10 );
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
int& _ref;
};
struct opt_int_mm_t : public option_t
{
opt_int_mm_t( const std::string& name, int& addr, int min, int max ) :
option_t( name ),
_ref( addr ),
_min( min ),
_max( max )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
int tmp = strtol( v.c_str(), nullptr, 10 );
// Range checking
if ( tmp < _min || tmp > _max ) {
std::stringstream s;
s << "Option '" << n << "' with value '" << v
<< "' not within valid boundaries [" << _min << " - " << _max << "]";
throw std::invalid_argument(s.str());
}
_ref = tmp;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
int& _ref;
int _min, _max;
};
struct opt_uint_t : public option_t
{
opt_uint_t( const std::string& name, unsigned int& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref = strtoul( v.c_str(), nullptr, 10 );
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
unsigned int& _ref;
};
struct opt_uint_mm_t : public option_t
{
opt_uint_mm_t( const std::string& name, unsigned int& addr, unsigned int min, unsigned int max ) :
option_t( name ),
_ref( addr ),
_min( min ),
_max( max )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
unsigned int tmp = strtoul( v.c_str(), nullptr, 10 );
// Range checking
if ( tmp < _min || tmp > _max ) {
std::stringstream s;
s << "Option '" << n << "' with value '" << v
<< "' not within valid boundaries [" << _min << " - " << _max << "]";
throw std::invalid_argument(s.str());
}
_ref = tmp;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
unsigned int& _ref;
unsigned int _min, _max;
};
struct opt_double_t : public option_t
{
opt_double_t( const std::string& name, double& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref = strtod( v.c_str(), nullptr );
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
double& _ref;
};
struct opt_double_mm_t : public option_t
{
opt_double_mm_t( const std::string& name, double& addr, double min, double max ) :
option_t( name ),
_ref( addr ),
_min( min ),
_max( max )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
double tmp = strtod( v.c_str(), nullptr );
// Range checking
if ( tmp < _min || tmp > _max ) {
std::stringstream s;
s << "Option '" << n << "' with value '" << v
<< "' not within valid boundaries [" << _min << " - " << _max << "]";
throw std::invalid_argument(s.str());
}
_ref = tmp;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
double& _ref;
double _min, _max;
};
struct opt_timespan_t : public option_t
{
opt_timespan_t( const std::string& name, timespan_t& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
_ref = timespan_t::from_seconds( strtod( v.c_str(), nullptr ) );
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
timespan_t& _ref;
};
struct opt_timespan_mm_t : public option_t
{
opt_timespan_mm_t( const std::string& name, timespan_t& addr, timespan_t min, timespan_t max ) :
option_t( name ),
_ref( addr ),
_min( min ),
_max( max )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
timespan_t tmp = timespan_t::from_seconds( strtod( v.c_str(), nullptr ) );
// Range checking
if ( tmp < _min || tmp > _max ) {
std::stringstream s;
s << "Option '" << n << "' with value '" << v
<< "' not within valid boundaries [" << _min << " - " << _max << "]";
throw std::invalid_argument(s.str());
}
_ref = tmp;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
timespan_t& _ref;
timespan_t _min, _max;
};
struct opt_bool_t : public option_t
{
opt_bool_t( const std::string& name, bool& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
if ( v != "0" && v != "1" )
{
std::stringstream s;
s << "Acceptable values for '" << n << "' are '1' or '0'";
throw std::invalid_argument( s.str() );
}
_ref = strtol( v.c_str(), nullptr, 10 ) != 0;
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
bool& _ref;
};
struct opt_bool_int_t : public option_t
{
opt_bool_int_t( const std::string& name, int& addr ) :
option_t( name ),
_ref( addr )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( n != name() )
return false;
if ( v != "0" && v != "1" )
{
std::stringstream s;
s << "Acceptable values for '" << n << "' are '1' or '0'";
throw std::invalid_argument( s.str() );
}
_ref = strtol( v.c_str(), nullptr, 10 );
return true;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=" << _ref << "\n";
return stream;
}
private:
int& _ref;
};
struct opts_sim_func_t : public option_t
{
opts_sim_func_t( const std::string& name, const function_t& ref ) :
option_t( name ),
_fun( ref )
{ }
protected:
bool parse( sim_t* sim, const std::string& n, const std::string& value ) const override
{
if ( name() != n )
return false;
return _fun( sim, n, value );
}
std::ostream& print( std::ostream& stream ) const override
{ return stream << "function option: " << name() << "\n"; }
private:
function_t _fun;
};
struct opts_map_t : public option_t
{
opts_map_t( const std::string& name, map_t& ref ) :
option_t( name ),
_ref( ref )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
std::string::size_type last = n.size() - 1;
bool append = false;
if ( n[ last ] == '+' )
{
append = true;
--last;
}
std::string::size_type dot = n.rfind( ".", last );
if ( dot != std::string::npos )
{
if ( name() == n.substr( 0, dot + 1 ) )
{
std::string& value = _ref[ n.substr( dot + 1, last - dot ) ];
value = append ? ( value + v ) : v;
return true;
}
}
return false;
}
std::ostream& print( std::ostream& stream ) const override
{
for ( map_t::const_iterator it = _ref.begin(), end = _ref.end(); it != end; ++it )
stream << name() << it->first << "="<< it->second << "\n";
return stream;
}
map_t& _ref;
};
struct opts_list_t : public option_t
{
opts_list_t( const std::string& name, list_t& ref ) :
option_t( name ),
_ref( ref )
{ }
protected:
bool parse( sim_t*, const std::string& n, const std::string& v ) const override
{
if ( name() != n )
return false;
_ref.push_back( v );
return false;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << name() << "=";
for ( list_t::const_iterator it = _ref.begin(), end = _ref.end(); it != end; ++it )
stream << name() << (*it) << " ";
stream << "\n";
return stream;
}
private:
list_t& _ref;
};
struct opts_deperecated_t : public option_t
{
opts_deperecated_t( const std::string& name, const std::string& new_option ) :
option_t( name ),
_new_option( new_option )
{ }
protected:
bool parse( sim_t*, const std::string& name, const std::string& ) const override
{
if ( name != this -> name() )
return false;
std::stringstream s;
s << "Option '" << name << "' has been deprecated.";
s << " Please use option '" << _new_option << "' instead.";
throw std::invalid_argument( s.str() );
return false;
}
std::ostream& print( std::ostream& stream ) const override
{
stream << "Option '" << name() << "' has been deprecated. Please use '" << _new_option << "'.\n";
return stream;
}
private:
std::string _new_option;
};
} // opts
// option_t::parse ==========================================================
bool opts::parse( sim_t* sim,
const std::vector<std::unique_ptr<option_t>>& options,
const std::string& name,
const std::string& value )
{
for ( auto& option : options )
if ( option -> parse_option( sim, name, value ) )
return true;
return false;
}
// option_t::parse ==========================================================
void opts::parse( sim_t* sim,
const std::string& context,
const std::vector<std::unique_ptr<option_t>>& options,
const std::vector<std::string>& splits )
{
for (auto & s : splits)
{
auto index = s.find_first_of( '=' );
if ( index == std::string::npos )
{
std::stringstream stream;
stream << context << ": Unexpected parameter '" << s << "'. Expected format: name=value";
throw std::invalid_argument( stream.str() );
}
std::string n = s.substr( 0, index );
std::string v = s.substr( index + 1 );
if ( ! opts::parse( sim, options, n, v ) )
{
std::stringstream stream;
stream << context << ": Unexpected parameter '" << n << "'.";
throw std::invalid_argument( stream.str() );
}
}
}
// option_t::parse ==========================================================
void opts::parse( sim_t* sim,
const std::string& context,
const std::vector<std::unique_ptr<option_t>>& options,
const std::string& options_str )
{
opts::parse( sim, context, options, util::string_split( options_str, "," ) );
}
// option_db_t::parse_file ==================================================
bool option_db_t::parse_file( FILE* file )
{
char buffer[ 1024 ];
bool first = true;
while ( fgets( buffer, sizeof( buffer ), file ) )
{
char *b = buffer;
if ( first )
{
first = false;
// Skip the UTF-8 BOM, if any.
size_t len = strlen( b );
if ( len >= 3 && utf8::is_bom( b ) )
b += 3;
}
b = skip_white_space( b );
if ( *b == '#' || *b == '\0' )
continue;
parse_line( io::maybe_latin1_to_utf8( b ) );
}
return true;
}
// option_db_t::parse_text ==================================================
void option_db_t::parse_text( const std::string& text )
{
// Split a chunk of text into lines to parse.
std::string::size_type first = 0;
while ( true )
{
while ( first < text.size() && is_white_space( text[ first ] ) )
++first;
if ( first >= text.size() )
break;
std::string::size_type last = text.find( '\n', first );
if ( false )
{
std::cerr << "first = " << first << ", last = " << last << " ["
<< text.substr( first, last - first ) << ']' << std::endl;
}
if ( text[ first ] != '#' )
{
parse_line( text.substr( first, last - first ) );
}
first = last;
}
}
// option_db_t::parse_line ==================================================
void option_db_t::parse_line( const std::string& line )
{
if ( line[ 0 ] == '#' )
return;
std::vector<std::string> tokens;
size_t num_tokens = util::string_split_allow_quotes( tokens, line, " \t\n\r" );
for ( size_t i = 0; i < num_tokens; ++i )
{
parse_token( tokens[ i ] );
}
}
// option_db_t::parse_token =================================================
void option_db_t::parse_token( const std::string& token )
{
if ( token == "-" )
{
parse_file( stdin );
return;
}
std::string parsed_token = token;
std::string::size_type cut_pt = parsed_token.find( '=' );
// Expand the token with template variables, and try to find '=' again
if ( cut_pt == std::string::npos )
{
do_replace( *this, parsed_token, parsed_token.find( "$(" ), 1 );
cut_pt = parsed_token.find( "=" );
}
if ( cut_pt == token.npos )
{
std::string actual_name;
io::cfile file = open_file( auto_path, parsed_token, actual_name );
if ( ! file )
{
std::stringstream s;
s << "Unexpected parameter '" << parsed_token << "'. Expected format: name=value";
throw std::invalid_argument( s.str() );
}
parse_file( file );
return;
}
std::string name( parsed_token, 0, cut_pt ), value( parsed_token, cut_pt + 1, std::string::npos );
do_replace( *this, value, value.find( "$(" ), 1 );
if ( name.size() >= 1 && name[ 0 ] == '$' )
{
if ( name.size() < 3 || name[ 1 ] != '(' || name[ name.size() - 1 ] != ')' )
{
std::stringstream s;
s << "Variable syntax error: '" << parsed_token << "'";
throw std::invalid_argument( s.str() );
}
auto var_name = name.substr( 2, name.size() - 3 );
do_replace( *this, var_name, var_name.find( "$(" ), 1 );
var_map[ var_name ] = value;
}
else if ( name == "input" )
{
std::string current_base_name;
auto base_name_it = var_map.find( "current_base_name" );
if ( base_name_it != var_map.end() )
{
current_base_name = base_name_it -> second;
}
std::string actual_name;
io::cfile file( open_file( auto_path, value, actual_name ) );
if ( ! file )
{
std::stringstream s;
s << "Unable to open input parameter file '" << value << "'";
throw std::invalid_argument( s.str() );
}
else
{
var_map[ "current_base_name" ] = base_name( actual_name );
}
parse_file( file );
if ( base_name_it != var_map.end() )
{
var_map[ "current_base_name" ] = current_base_name;
}
}
else
{
add( "global", name, value );
}
}
// option_db_t::parse_args ==================================================
void option_db_t::parse_args( const std::vector<std::string>& args )
{
for ( size_t i = 0; i < args.size(); ++i )
parse_token( args[ i ] );
}
// option_db_t::option_db_t =================================================
#ifndef SC_SHARED_DATA
#if defined( SC_LINUX_PACKAGING )
#define SC_SHARED_DATA SC_LINUX_PACKAGING "/profiles"
#else
#define SC_SHARED_DATA ".."
#endif
#endif
option_db_t::option_db_t()
{
const char* paths[] = { "./profiles", "../profiles", SC_SHARED_DATA };
int n_paths = 2;
if ( ! util::str_compare_ci( SC_SHARED_DATA, ".." ) )
n_paths++;
// This makes baby pandas cry a bit less, but still makes them weep.
// Add current directory automagically.
auto_path.push_back( "." );
// Automatically add "./profiles" and "../profiles", because the command line
// client is ran both from the engine/ subdirectory, as well as the source
// root directory, depending on whether the user issues make install or not.
// In addition, if SC_SHARED_DATA is given, search our profile directory
// structure directly from there as well.
for ( int j = 0; j < n_paths; j++ )
{
std::string prefix = paths[ j ];
// Skip empty SHARED_DATA define, as the default ("..") is already
// included.
if ( prefix.empty() )
continue;
auto_path.push_back( prefix );
prefix += "/";
auto_path.push_back( prefix + "Legendaries" ); // Legendaries
auto_path.push_back( prefix + "Tier19H_NH" ); // T19H for Nighthold
auto_path.push_back( prefix + "Tier19M_NH" ); // T19M for Nighthold
// Add profiles for each tier, except pvp
for ( unsigned i = 0; i < N_TIER; ++i )
{
auto_path.push_back( prefix + "Tier" + util::to_string( MIN_TIER + i ) + "B" );
auto_path.push_back( prefix + "Tier" + util::to_string( MIN_TIER + i ) + "M" );
auto_path.push_back( prefix + "Tier" + util::to_string( MIN_TIER + i ) + "H" );
auto_path.push_back( prefix + "Tier" + util::to_string( MIN_TIER + i ) + "N" );
auto_path.push_back( prefix + "Tier" + util::to_string( MIN_TIER + i ) + "P" );
}
}
}
std::unique_ptr<option_t> opt_string( const std::string& n, std::string& v )
{ return std::unique_ptr<option_t>(new opts::opt_string_t( n, v )); }
std::unique_ptr<option_t> opt_append( const std::string& n, std::string& v )
{ return std::unique_ptr<option_t>(new opts::opt_append_t( n, v )); }
std::unique_ptr<option_t> opt_bool( const std::string& n, int& v )
{ return std::unique_ptr<option_t>(new opts::opt_bool_int_t( n, v )); }
std::unique_ptr<option_t> opt_bool( const std::string& n, bool& v )
{ return std::unique_ptr<option_t>(new opts::opt_bool_t( n, v )); }
std::unique_ptr<option_t> opt_uint64( const std::string& n, uint64_t& v )
{ return std::unique_ptr<option_t>(new opts::opt_uint64_t( n, v )); }
std::unique_ptr<option_t> opt_int( const std::string& n, int& v )
{ return std::unique_ptr<option_t>(new opts::opt_int_t( n, v )); }
std::unique_ptr<option_t> opt_int( const std::string& n, int& v, int min, int max )
{ return std::unique_ptr<option_t>(new opts::opt_int_mm_t( n, v, min, max )); }
std::unique_ptr<option_t> opt_uint( const std::string& n, unsigned& v )
{ return std::unique_ptr<option_t>(new opts::opt_uint_t( n, v )); }
std::unique_ptr<option_t> opt_uint( const std::string& n, unsigned& v, unsigned min, unsigned max )
{ return std::unique_ptr<option_t>(new opts::opt_uint_mm_t( n, v, min, max )); }
std::unique_ptr<option_t> opt_float( const std::string& n, double& v )
{ return std::unique_ptr<option_t>(new opts::opt_double_t( n, v )); }
std::unique_ptr<option_t> opt_float( const std::string& n, double& v, double min, double max )
{ return std::unique_ptr<option_t>(new opts::opt_double_mm_t( n, v, min, max )); }
std::unique_ptr<option_t> opt_timespan( const std::string& n, timespan_t& v )
{ return std::unique_ptr<option_t>(new opts::opt_timespan_t( n, v )); }
std::unique_ptr<option_t> opt_timespan( const std::string& n, timespan_t& v, timespan_t min, timespan_t max )
{ return std::unique_ptr<option_t>(new opts::opt_timespan_mm_t( n, v, min, max )); }
std::unique_ptr<option_t> opt_list( const std::string& n, opts::list_t& v )
{ return std::unique_ptr<option_t>(new opts::opts_list_t( n, v )); }
std::unique_ptr<option_t> opt_map( const std::string& n, opts::map_t& v )
{ return std::unique_ptr<option_t>(new opts::opts_map_t( n, v )); }
std::unique_ptr<option_t> opt_func( const std::string& n, const opts::function_t& f )
{ return std::unique_ptr<option_t>(new opts::opts_sim_func_t( n, f )); }
std::unique_ptr<option_t> opt_deprecated( const std::string& n, const std::string& new_option )
{ return std::unique_ptr<option_t>(new opts::opts_deperecated_t( n, new_option )); }
#undef SC_SHARED_DATA