MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / load_season_array

Function load_season_array

src/mapdata.cpp:484–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482
483template<typename C, typename F>
484void load_season_array( const JsonObject &jo, const std::string &key, const std::string &context,
485 C &container, F load_func )
486{
487 if( jo.has_string( key ) ) {
488 container.fill( load_func( jo.get_string( key ) ) );
489
490 } else if( jo.has_array( key ) ) {
491 JsonArray arr = jo.get_array( key );
492 if( arr.size() == 1 ) {
493 container.fill( load_func( arr.get_string( 0 ) ) );
494
495 } else if( arr.size() == container.size() ) {
496 for( auto &e : container ) {
497 e = load_func( arr.next_string() );
498 }
499
500 } else {
501 jo.throw_error( "Incorrect number of entries", key );
502 }
503
504 } else if( jo.has_member( key ) ) {
505 jo.throw_error( string_format( "Expected '%s' member to be string or array", key ), key );
506 } else {
507 jo.throw_error(
508 string_format( "Expected '%s' member in %s but none was found", key, context ) );
509 }
510}
511
512std::string map_data_common_t::name() const
513{

Callers 1

load_symbolMethod · 0.85

Calls 10

string_formatFunction · 0.85
has_stringMethod · 0.80
has_arrayMethod · 0.80
next_stringMethod · 0.80
has_memberMethod · 0.80
get_stringMethod · 0.60
get_arrayMethod · 0.60
fillMethod · 0.45
sizeMethod · 0.45
throw_errorMethod · 0.45

Tested by

no test coverage detected