| 482 | |
| 483 | template<typename C, typename F> |
| 484 | void 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 | |
| 512 | std::string map_data_common_t::name() const |
| 513 | { |
no test coverage detected