diff --git a/.gitignore b/.gitignore index 905c4f4..dc9509d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .libs .deps +.vscode *.la *.lo *.o @@ -9,6 +10,7 @@ Makefile Makefile.in aclocal.m4 autom4te.cache +build config.* config configure @@ -19,7 +21,8 @@ librcscenv libtool m4/lt* m4/libtool.m4 -thermo_color_test +object_table_printer +rcg2csv rcg2txt rcgrenameteam rcgresultprinter @@ -30,3 +33,5 @@ rclmscheduler rclmtableprinter stamp-h1 tmp +thermo_color_test + diff --git a/CMakeLists.txt b/CMakeLists.txt index 641b77e..fa48ac5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.5) -project(librcsc VERSION 2023) +project(librcsc VERSION 2024) -set(LIBRCSC_SOVERSION 18) # protocol version +set(LIBRCSC_SOVERSION 19) # protocol version set(LIBRCSC_BUILDVERSION ${LIBRCSC_SOVERSION}.0.0) if(CMAKE_VERSION VERSION_LESS "3.7.0") @@ -32,7 +32,6 @@ if(WIN32) endif() check_include_file_cxx("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file_cxx("fcntl.h" HAVE_FCNTL_H) -check_include_file_cxx("netinet/in.h" HAVE_NETINET_IN_H) check_include_file_cxx("netdb.h" HAVE_NETDB_H) check_include_file_cxx("sys/socket.h" HAVE_SYS_SOCKET_H) check_include_file_cxx("sys/time.h" HAVE_SYS_TIME_H) diff --git a/configure.ac b/configure.ac index 58368a1..84a6668 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.65) LT_PREREQ(2.2) -AC_INIT([librcsc],[2023],[akky@users.sourceforge.jp]) +AC_INIT([librcsc],[2024],[akky@users.sourceforge.jp]) #LT_PREREQ(2.2.4) @@ -60,7 +60,9 @@ AC_CHECK_LIB([z], [deflate], # Checks for header files. ################################################## -AC_CHECK_HEADERS([arpa/inet.h]) +AC_CHECK_HEADERS([arpa/inet.h], + break, + [AC_MSG_ERROR([*** arpa/inet.h not found ***])]) AC_CHECK_HEADERS([fcntl.h], break, [AC_MSG_ERROR([*** fcntl.h not found ***])]) @@ -103,12 +105,12 @@ AC_C_INLINE #AC_TYPE_INT64_T #AC_TYPE_UINT32_T AC_TYPE_SIZE_T -AC_HEADER_TIME +#AC_HEADER_TIME ################################################## # Checks for library functions. ################################################## -AC_HEADER_STDC +#AC_HEADER_STDC AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES diff --git a/rcsc/Makefile.am b/rcsc/Makefile.am index c15db81..4203711 100644 --- a/rcsc/Makefile.am +++ b/rcsc/Makefile.am @@ -57,7 +57,7 @@ librcsc_la_LIBADD = \ ## action/librcsc_action_obsolete.la -librcsc_la_LDFLAGS = -version-info 18:0:0 +librcsc_la_LDFLAGS = -version-info 19:0:0 #libXXXX_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) # 1. Start with version information of `0:0:0' for each libtool library. # diff --git a/rcsc/coach/coach_agent.cpp b/rcsc/coach/coach_agent.cpp index 0b31217..27bf4c7 100644 --- a/rcsc/coach/coach_agent.cpp +++ b/rcsc/coach/coach_agent.cpp @@ -2130,7 +2130,7 @@ CoachAgent::doTeamGraphic( const int x, std::ostringstream ostr; ostr << "(team_graphic (" << x << ' ' << y << ' '; - tile->second->print( ostr ); + tile->second->print( ostr, ' ' ); ostr << "))"; return ( M_client->sendMessage( ostr.str().c_str() ) > 0 ); diff --git a/rcsc/coach/player_type_analyzer.cpp b/rcsc/coach/player_type_analyzer.cpp index ec8100a..4373732 100644 --- a/rcsc/coach/player_type_analyzer.cpp +++ b/rcsc/coach/player_type_analyzer.cpp @@ -44,7 +44,13 @@ #include #include -//#define DEBUG_PRINT +#include +#include + +// #define DEBUG_PRINT +// #define DEBUG_PRINT_RESULT +// #define DEBUG_PRINT_DETECT_INVALID +// #define DEBUG_PRINT_MATRIX namespace rcsc { @@ -54,6 +60,7 @@ namespace rcsc { */ PlayerTypeAnalyzer::Data::Data() : turned_( false ), + rotation_( 0.0 ), kicked_( false ), tackling_( false ), maybe_referee_( false ), @@ -277,6 +284,10 @@ PlayerTypeAnalyzer::analyze() checkPlayerSpeedMax(); checkTurnMoment(); +#ifdef DEBUG_PRINT_MATRIX + debugPrintIllegalMatrix(); +#endif + const int max_types = PlayerParam::i().playerTypes(); for ( const CoachPlayerObject * p : M_world.opponents() ) @@ -317,7 +328,7 @@ PlayerTypeAnalyzer::analyze() } } -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_RESULT dlog.addText( Logger::ANALYZER, __FILE__" (analyze) opponent %d. invalid count=%d", p->unum(), invalid_count ); @@ -330,7 +341,7 @@ PlayerTypeAnalyzer::analyze() << " no player type for opponent " << p->unum() << ". restart analysis." << std::endl; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_RESULT dlog.addText( Logger::ANALYZER, __FILE__" (analyze) opponent %d. no player type candidate. restart analysis.", p->unum() ); @@ -347,7 +358,7 @@ PlayerTypeAnalyzer::analyze() std::cout << M_world.ourTeamName() << " coach: " << M_world.time() << " determined opponent " << p->unum() << " type = " << t << std::endl; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_RESULT dlog.addText( Logger::ANALYZER, __FILE__" (analyze) determined opponent %d. type=%d", p->unum(), t ); @@ -372,7 +383,7 @@ PlayerTypeAnalyzer::analyze() else { // several candidates -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_RESULT dlog.addText( Logger::ANALYZER, __FILE__" (analyze) opponent %d. several player type candidates = %d.", p->unum(), @@ -392,7 +403,9 @@ PlayerTypeAnalyzer::checkTurn() for ( int i = 0; i < 11 ; ++i ) { M_teammate_data[i].turned_ = false; + M_teammate_data[i].rotation_ = 0.0; M_opponent_data[i].turned_ = false; + M_opponent_data[i].rotation_ = 0.0; } for ( const CoachPlayerObject * t : M_world.teammates() ) @@ -403,13 +416,14 @@ PlayerTypeAnalyzer::checkTurn() if ( data.body_ != -360.0 ) { - if ( std::fabs( data.body_ - t->body().degree() ) > 0.5 ) + data.rotation_ = AngleDeg::normalize_angle( data.body_ - t->body().degree() ); + if ( std::fabs( data.rotation_ ) > 0.5 ) { data.turned_ = true; #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, __FILE__" (checkTurn) teammate %d turned 1", - (*p)->unum() ); + t->unum() ); #endif } #ifdef DEBUG_PRINT @@ -417,7 +431,7 @@ PlayerTypeAnalyzer::checkTurn() { dlog.addText( Logger::ANALYZER, __FILE__" (checkTurn) teammate %d turned 0", - (*p)->unum() ); + t->unum() ); } #endif } @@ -431,13 +445,14 @@ PlayerTypeAnalyzer::checkTurn() if ( data.body_ != -360.0 ) { - if ( std::fabs( data.body_ - o->body().degree() ) > 0.5 ) + data.rotation_ = AngleDeg::normalize_angle( data.body_ - o->body().degree() ); + if ( std::fabs( data.rotation_ ) > 0.5 ) { data.turned_ = true; #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, __FILE__" (checkTurn) opponent %d turned 1", - (*p)->unum() ); + o->unum() ); #endif } #ifdef DEBUG_PRINT @@ -445,7 +460,7 @@ PlayerTypeAnalyzer::checkTurn() { dlog.addText( Logger::ANALYZER, __FILE__" (checkTurn) opponent %d turned 0", - (*p)->unum() ); + o->unum() ); } #endif } @@ -473,8 +488,8 @@ PlayerTypeAnalyzer::checkTackle() M_teammate_data[p->unum() - 1].tackling_ = p->isTackling(); #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, - __FILE__" (checkTackle) teammate %d tackling %d", - (*p)->unum(), (int)(*p)->isTackling() ); + __FILE__" (checkTackle) teammate %d tackling [%s]", + p->unum(), ( p->isTackling() ? "true" : "false" ) ); #endif } @@ -485,8 +500,8 @@ PlayerTypeAnalyzer::checkTackle() M_opponent_data[p->unum() - 1].tackling_ = p->isTackling(); #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, - __FILE__" (checkTackle) opponent %d tackling %d", - p->unum(), (int)(*p->isTackling()) ); + __FILE__" (checkTackle) opponent %d tackling [%s]", + p->unum(), ( p->isTackling() ? "true" : "false" ) ); #endif } @@ -567,10 +582,10 @@ PlayerTypeAnalyzer::checkCollisions() const double ball_collide_dist2 = std::pow( ServerParam::i().defaultPlayerSize() + ServerParam::i().ballSize() - + 0.02, + + 0.001, 2 ); const double player_collide_dist2 - = std::pow( ServerParam::i().defaultPlayerSize() * 2.0 + 0.02, 2 ); + = std::pow( ServerParam::i().defaultPlayerSize() * 2.0 + 0.001, 2 ); const Vector2D pole_pos( ServerParam::i().pitchHalfLength() - ServerParam::i().goalPostRadius(), ServerParam::i().goalHalfWidth() @@ -597,7 +612,7 @@ PlayerTypeAnalyzer::checkCollisions() #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, __FILE__" (checkCollisions) opponent %d. may be collided with ball", - (*p)->unum() ); + p->unum() ); #endif } } @@ -653,7 +668,7 @@ PlayerTypeAnalyzer::checkCollisions() #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, __FILE__" (checkCollisions) opponent %d. may be collided with teammate %d", - (*o)->unum(), (*t)->unum() ); + o->unum(), t->unum() ); #endif break; } @@ -764,8 +779,8 @@ PlayerTypeAnalyzer::checkKick() } #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, - __FILE__" (checkKick) teammate %d. kicking %d", - p->unum(), (int)p->kicked() ); + __FILE__" (checkKick) teammate %d. kicking [%s]", + p->unum(), ( p->isKicking() ? "true" : "false" ) ); #endif } @@ -783,8 +798,8 @@ PlayerTypeAnalyzer::checkKick() } #ifdef DEBUG_PRINT dlog.addText( Logger::ANALYZER, - __FILE__" (checkKick) opponent %d. kicking %d", - p->unum(), (int)p->kicked() ); + __FILE__" (checkKick) opponent %d. kicking [%s]", + p->unum(), ( p->isKicking() ? "true" : "false" ) ); #endif } } @@ -867,12 +882,12 @@ PlayerTypeAnalyzer::checkKick() if ( ball_dist > player_type->kickableArea() + 0.001 ) { data.invalid_flags_[t] = 1; -#ifdef DEBUG_PRINT - std::cout << M_world.ourTeamName() << " coach: " << M_world.time() - << " opponent " << kicker_idx + 1 - << " detect invalid kickable area. type = " - << t - << std::endl; +#ifdef DEBUG_PRINT_DETECT_INVALID + // std::cout << M_world.ourTeamName() << " coach: " << M_world.time() + // << " opponent " << kicker_idx + 1 + // << " detect invalid kickable area. type = " + // << t + // << std::endl; dlog.addText( Logger::ANALYZER, __FILE__" (checkKick) opponent=%d type=%d," " out of range kickable area." @@ -909,6 +924,17 @@ PlayerTypeAnalyzer::checkPlayerDecay() Data & data = M_opponent_data[p->unum() - 1]; + // If the player rotates by the two legs dash model, + // turn and acceleration occur simultaneously. + // In that case, it is impossible to determine the player type based on the player decay noise + // if ( data.turned_ ) continue; + if ( 0.5 < std::fabs( data.rotation_ ) + //&& std::fabs( data.rotation_ ) < 50.0 ) // magic number + && std::fabs( data.rotation_ ) < 100.0 ) // magic number + { + continue; + } + if ( data.maybe_collide_ ) continue; if ( data.maybe_referee_ ) continue; if ( ! data.turned_ @@ -955,19 +981,19 @@ PlayerTypeAnalyzer::checkPlayerDecay() } #else // rcssserver-13 or lator - Vector2D rand_vec + const Vector2D noise_vec = ( p->vel() - data.vel_ * player_type->playerDecay() ) / player_type->playerDecay(); - double rand_r = rand_vec.r(); - if ( rand_r > rand_max + 0.0000001 ) + const double noise_magnitude = noise_vec.r(); + if ( noise_magnitude > rand_max + 1.0e-10 ) { data.invalid_flags_[t] = 1; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_DETECT_INVALID dlog.addText( Logger::ANALYZER, __FILE__" (checkPlayerDecay) opponent=%d type=%d" - " out of range player decay. rand_r=%f rand_max=%f", + " out of range player decay. noise=%f rand_max=%f", p->unum(), t, - rand_r, rand_max ); + noise_magnitude, rand_max ); #endif } #endif @@ -1019,10 +1045,10 @@ PlayerTypeAnalyzer::checkPlayerSpeedMax() * ServerParam::i().playerRand() / ( 1.0 + ServerParam::i().playerRand() ) ); - if ( last_accel_r > max_accel + last_max_noise + 0.0001 ) + if ( last_accel_r > max_accel + last_max_noise + 1.0e-10 ) { data.invalid_flags_[t] = 1; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_DETECT_INVALID std::cout << M_world.ourTeamName() << " coach: " << M_world.time() << " opponent " << p->unum() << " type = " << t @@ -1061,7 +1087,7 @@ PlayerTypeAnalyzer::checkPlayerSpeedMax() if ( last_move_dist > max_move ) { data.invalid_flags_[t] = 1; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_DETECT_INVALID std::cout << M_world.ourTeamName() << " coach: " << M_world.time() << " opponent " << p->unum() << " type = " << t @@ -1113,7 +1139,7 @@ PlayerTypeAnalyzer::checkTurnMoment() if ( turn_angle > max_turn * ( 1.0 + ServerParam::i().playerRand() ) + 1.0001 ) { data.invalid_flags_[t] = 1; -#ifdef DEBUG_PRINT +#ifdef DEBUG_PRINT_DETECT_INVALID std::cout << M_world.ourTeamName() << " coach: " << M_world.time() << " opponent " << p->unum() << " type = " << t @@ -1133,4 +1159,29 @@ PlayerTypeAnalyzer::checkTurnMoment() } } +/*-------------------------------------------------------------------*/ +void +PlayerTypeAnalyzer::debugPrintIllegalMatrix() +{ + dlog.addText( Logger::ANALYZER, + "(PlayerTypeAnalyzer) === print matrix ===" ); + for ( int i = 0; i < 11; ++i ) + { + std::ostringstream ostr; + int invalid_count = 0; + for ( const int flag : M_opponent_data[i].invalid_flags_ ) + { + ostr << " " << std::setw( 2 ) << flag; + invalid_count += flag; + } + + if ( M_opponent_data[i].type_ == Hetero_Unknown ) + { + dlog.addText( Logger::ANALYZER, + "%02d: %s -> invalid=%d", + i + 1, ostr.str().c_str(), invalid_count ); + } + } +} + } diff --git a/rcsc/coach/player_type_analyzer.h b/rcsc/coach/player_type_analyzer.h index 05961a6..e2f8bfa 100644 --- a/rcsc/coach/player_type_analyzer.h +++ b/rcsc/coach/player_type_analyzer.h @@ -53,6 +53,7 @@ class PlayerTypeAnalyzer { struct Data { bool turned_; //!< player performed turn + double rotation_; //!< rotated degree bool kicked_; //!< player perfomed kick bool tackling_; //!< player perfoming tackle bool maybe_referee_; //!< player may be moved by referee @@ -187,6 +188,9 @@ class PlayerTypeAnalyzer { \brief check turn moment range */ void checkTurnMoment(); + + // + void debugPrintIllegalMatrix(); }; } diff --git a/rcsc/common/player_param.cpp b/rcsc/common/player_param.cpp index 0a19542..7a444a9 100644 --- a/rcsc/common/player_param.cpp +++ b/rcsc/common/player_param.cpp @@ -368,9 +368,52 @@ PlayerParam::convertFrom( const rcg::player_params_t & from ) } /*-------------------------------------------------------------------*/ -/*! +void +PlayerParam::convertFrom( const rcg::PlayerParamT & from ) +{ + M_player_types = from.player_types_; //!< the number of player types + M_subs_max = from.substitute_max_; //!< max number of player substitution oppotunity + M_pt_max = from.pt_max_; //!< max number of same player type at the same time -*/ + M_allow_mult_default_type = from.allow_mult_default_type_; //!< if true, the number of default type player is not restricted. + + M_player_speed_max_delta_min = from.player_speed_max_delta_min_; //!< (obsolete) tradeoff parameter for player speed max + M_player_speed_max_delta_max = from.player_speed_max_delta_max_; //!< (obsolete) tradeoff parameter for player speed max + M_stamina_inc_max_delta_factor = from.stamina_inc_max_delta_factor_; //!< (obsolete) tradeoff parameter for + + M_player_decay_delta_min = from.player_decay_delta_min_; //!< tradeoff parameter for player decay + M_player_decay_delta_max = from.player_decay_delta_max_; //!< tradeoff parameter for player decay + M_inertia_moment_delta_factor = from.inertia_moment_delta_factor_; //!< tradeoff parameter for inertia moment + + M_dash_power_rate_delta_min = from.dash_power_rate_delta_min_; //!< (obsolete) tradeoff parameter for dash power rate + M_dash_power_rate_delta_min = from.dash_power_rate_delta_max_; //!< (obsolete) tradeoff parameter for dash power rate + M_player_size_delta_factor = from.player_size_delta_factor_; //!< (obsolete) tradeoff parameter for player size + + M_kickable_margin_delta_min = from.kickable_margin_delta_min_; //!< tradeoff parameter for kickable margin + M_kickable_margin_delta_max = from.kickable_margin_delta_max_; //!< tradeoff parameter for kickable margin + M_kick_rand_delta_factor = from.kick_rand_delta_factor_; //!< tradeoff parameter for kick rand + + M_extra_stamina_delta_min = from.extra_stamina_delta_min_; //!< tradeoff parameter for extra stamina + M_extra_stamina_delta_max = from.extra_stamina_delta_max_; //!< tradeoff parameter for extra stamina + M_effort_max_delta_factor = from.effort_max_delta_factor_; //!< tradeoff parameter for effort max + M_effort_min_delta_factor = from.effort_min_delta_factor_; //!< tradeoff parameter for effort min + + M_random_seed = from.random_seed_; //!< seed value to generate hetero parameters + + M_new_dash_power_rate_delta_min = from.new_dash_power_rate_delta_min_; //!< tradeoff parameter for dash power rate + M_new_dash_power_rate_delta_max = from.new_dash_power_rate_delta_max_; //!< tradeoff parameter for dash power rate + M_new_stamina_inc_max_delta_factor = from.new_stamina_inc_max_delta_factor_; //!< tradeoff parameter for stamina inc max + + // v14 + M_kick_power_rate_delta_min = from.kick_power_rate_delta_min_; //!< tradeoff parameter for kick power rate + M_kick_power_rate_delta_max = from.kick_power_rate_delta_max_; //!< tradeoff parameter for kick power rate + M_foul_detect_probability_delta_factor = from.foul_detect_probability_delta_factor_; //!< tradeoff parameter for foul detect probability + + M_catchable_area_l_stretch_min = from.catchable_area_l_stretch_min_; //!< tradeoff parameter for catch area length & catch probability + M_catchable_area_l_stretch_max = from.catchable_area_l_stretch_max_; //!< tradeoff parameter for catch area length & catch probability +} + +/*-------------------------------------------------------------------*/ void PlayerParam::convertTo( rcg::player_params_t & to ) const { @@ -415,6 +458,51 @@ PlayerParam::convertTo( rcg::player_params_t & to ) const to.catchable_area_l_stretch_max = rcg::hdtonl( M_catchable_area_l_stretch_max ); } +/*-------------------------------------------------------------------*/ +void +PlayerParam::convertTo( rcg::PlayerParamT & to ) const +{ + to.player_types_ = M_player_types; + to.substitute_max_ = M_subs_max; + to.pt_max_ = M_pt_max; + + to.allow_mult_default_type_ = M_allow_mult_default_type; + + to.player_speed_max_delta_min_ = M_player_speed_max_delta_min; + to.player_speed_max_delta_max_ = M_player_speed_max_delta_max; + to.stamina_inc_max_delta_factor_ = M_stamina_inc_max_delta_factor; + + to.player_decay_delta_min_ = M_player_decay_delta_min; + to.player_decay_delta_max_ = M_player_decay_delta_max; + to.inertia_moment_delta_factor_ = M_inertia_moment_delta_factor; + + to.dash_power_rate_delta_min_ = M_dash_power_rate_delta_min; + to.dash_power_rate_delta_max_ = M_dash_power_rate_delta_max; + to.player_size_delta_factor_ = M_player_size_delta_factor; + + to.kickable_margin_delta_min_ = M_kickable_margin_delta_min; + to.kickable_margin_delta_max_ = M_kickable_margin_delta_max; + to.kick_rand_delta_factor_ = M_kick_rand_delta_factor; + + to.extra_stamina_delta_min_ = M_extra_stamina_delta_min; + to.extra_stamina_delta_max_ = M_extra_stamina_delta_max; + to.effort_max_delta_factor_ = M_effort_max_delta_factor; + to.effort_min_delta_factor_ = M_effort_min_delta_factor; + + to.new_dash_power_rate_delta_min_ = M_new_dash_power_rate_delta_min; + to.new_dash_power_rate_delta_max_ = M_new_dash_power_rate_delta_max; + to.new_stamina_inc_max_delta_factor_ = M_new_stamina_inc_max_delta_factor; + + to.random_seed_ = M_random_seed; + + to.kick_power_rate_delta_min_ = M_kick_power_rate_delta_min; + to.kick_power_rate_delta_max_ = M_kick_power_rate_delta_max; + to.foul_detect_probability_delta_factor_ = M_foul_detect_probability_delta_factor; + + to.catchable_area_l_stretch_min_ = M_catchable_area_l_stretch_min; + to.catchable_area_l_stretch_max_ = M_catchable_area_l_stretch_max; +} + /*-------------------------------------------------------------------*/ /*! diff --git a/rcsc/common/player_param.h b/rcsc/common/player_param.h index d46bc96..7bd2aa2 100644 --- a/rcsc/common/player_param.h +++ b/rcsc/common/player_param.h @@ -40,6 +40,7 @@ namespace rcsc { namespace rcg { struct player_params_t; +struct PlayerParamT; } class ParamMap; @@ -197,12 +198,24 @@ class PlayerParam { */ void convertFrom( const rcg::player_params_t & from ); + /*! + \brief convert parameters from the type in the rcg parser library. + \param from data structure for the rcg parser + */ + void convertFrom( const rcg::PlayerParamT & from ); + /*! \brief convert parameters to monitor protcol data \param to reference to the data structure variable */ void convertTo( rcg::player_params_t & to ) const; + /*! + \brief convert parameters to rcg data + \param to reference to the data structure variable + */ + void convertTo( rcg::PlayerParamT & to ) const; + /*! \brief convert to the rcss parameter message \return parameter message string diff --git a/rcsc/common/player_type.cpp b/rcsc/common/player_type.cpp index 6f94dba..7fc303e 100644 --- a/rcsc/common/player_type.cpp +++ b/rcsc/common/player_type.cpp @@ -39,6 +39,7 @@ #include "server_param.h" #include "stamina_model.h" +#include #include #include @@ -176,6 +177,52 @@ PlayerType::PlayerType( const rcg::player_type_t & from ) /*-------------------------------------------------------------------*/ /*! +*/ +PlayerType::PlayerType( const rcg::PlayerTypeT & from ) + : M_id( Hetero_Unknown ) +{ + setDefault(); + + M_id = from.id_; + M_player_speed_max = from.player_speed_max_; + M_stamina_inc_max = from.stamina_inc_max_; + M_player_decay = from.player_decay_; + M_inertia_moment = from.inertia_moment_; + M_dash_power_rate = from.dash_power_rate_; + M_player_size = from.player_size_; + M_kickable_margin = from.kickable_margin_; + M_kick_rand = from.kick_rand_; + M_extra_stamina = from.extra_stamina_; + M_effort_max = from.effort_max_; + M_effort_min = from.effort_min_; + + M_kick_power_rate = from.kick_power_rate_; + M_foul_detect_probability = from.foul_detect_probability_; + M_catchable_area_l_stretch = from.catchable_area_l_stretch_; + + M_unum_far_length = from.unum_far_length_; + M_unum_too_far_length = from.unum_too_far_length_; + M_team_far_length = from.team_far_length_; + M_team_too_far_length = from.team_too_far_length_; + M_player_max_observation_length = from.player_max_observation_length_; + M_ball_vel_far_length = from.ball_vel_far_length_; + M_ball_vel_too_far_length = from.ball_vel_too_far_length_; + M_ball_max_observation_length = from.ball_max_observation_length_; + M_flag_chg_far_length = from.flag_chg_far_length_; + M_flag_chg_too_far_length = from.flag_chg_too_far_length_; + M_flag_max_observation_length = from.flag_max_observation_length_; + + M_dist_noise_rate = from.dist_noise_rate_; + M_focus_dist_noise_rate = from.focus_dist_noise_rate_; + M_land_dist_noise_rate = from.land_dist_noise_rate_; + M_land_focus_dist_noise_rate = from.land_focus_dist_noise_rate_; + + initAdditionalParams(); +} + +/*-------------------------------------------------------------------*/ +/*! + */ template< typename DeltaFunc > PlayerType::PlayerType( const int id, @@ -276,9 +323,6 @@ PlayerType::PlayerType( const int id, } /*-------------------------------------------------------------------*/ -/*! - -*/ void PlayerType::convertTo( rcg::player_type_t & to ) const { @@ -301,9 +345,45 @@ PlayerType::convertTo( rcg::player_type_t & to ) const } /*-------------------------------------------------------------------*/ -/*! +void +PlayerType::convertTo( rcg::PlayerTypeT & to ) const +{ + to.id_ = M_id; + to.player_speed_max_ = M_player_speed_max; + to.stamina_inc_max_ = M_stamina_inc_max; + to.player_decay_ = M_player_decay; + to.inertia_moment_ = M_inertia_moment; + to.dash_power_rate_ = M_dash_power_rate; + to.player_size_ = M_player_size; + to.kickable_margin_ = M_kickable_margin; + to.kick_rand_ = M_kick_rand; + to.extra_stamina_ = M_extra_stamina; + to.effort_max_ = M_effort_max; + to.effort_min_ = M_effort_min; + // v14 + to.kick_power_rate_ = M_kick_power_rate; + to.foul_detect_probability_ = M_foul_detect_probability; + to.catchable_area_l_stretch_ = M_catchable_area_l_stretch; + // v18 + to.unum_far_length_ = M_unum_far_length; + to.unum_too_far_length_ = M_unum_too_far_length; + to.team_far_length_ = M_team_far_length; + to.team_too_far_length_ = M_team_too_far_length; + to.player_max_observation_length_ = M_player_max_observation_length; + to.ball_vel_far_length_ = M_ball_vel_far_length; + to.ball_vel_too_far_length_ = M_ball_vel_too_far_length; + to.ball_max_observation_length_ = M_ball_max_observation_length; + to.flag_chg_far_length_ = M_flag_chg_far_length; + to.flag_chg_too_far_length_ = M_flag_chg_too_far_length; + to.flag_max_observation_length_ = M_flag_max_observation_length; + // v19 + to.dist_noise_rate_ = M_dist_noise_rate; + to.focus_dist_noise_rate_ = M_focus_dist_noise_rate; + to.land_dist_noise_rate_ = M_land_dist_noise_rate; + to.land_focus_dist_noise_rate_= M_land_focus_dist_noise_rate; +} -*/ +/*-------------------------------------------------------------------*/ std::string PlayerType::toServerString() const { @@ -325,6 +405,21 @@ PlayerType::toServerString() const << "(kick_power_rate " << M_kick_power_rate << ')' << "(foul_detect_probability " << M_foul_detect_probability << ')' << "(catchable_area_l_stretch " << M_catchable_area_l_stretch << ')' + << "(unum_far_length " << M_unum_far_length << ')' + << "(unum_too_far_length " << M_unum_too_far_length << ')' + << "(team_far_length " << M_team_far_length << ')' + << "(team_too_far_length " << M_team_too_far_length << ')' + << "(player_max_observation_length " << M_player_max_observation_length << ')' + << "(ball_vel_far_length " << M_ball_vel_far_length << ')' + << "(ball_vel_too_far_length " << M_ball_vel_too_far_length << ')' + << "(ball_max_observation_length " << M_ball_max_observation_length << ')' + << "(flag_chg_far_length " << M_flag_chg_far_length << ')' + << "(flag_chg_too_far_length " << M_flag_chg_too_far_length << ')' + << "(flag_max_observation_length " << M_flag_max_observation_length << ')' + << "(dist_noise_rate " << distNoiseRate() << ')' + << "(focus_dist_noise_rate " << focusDistNoiseRate() << ')' + << "(land_dist_noise_rate " << landDistNoiseRate() << ')' + << "(land_focus_dist_noise_rate " << landFocusDistNoiseRate() << ')' << ')'; return os.str(); @@ -368,6 +463,12 @@ PlayerType::setDefault() M_flag_chg_far_length = 20.0; M_flag_chg_too_far_length = 40.0; M_flag_max_observation_length = maximum_dist_in_pitch; + + // v19 + M_dist_noise_rate = SP.distNoiseRate(); + M_focus_dist_noise_rate = SP.focusDistNoiseRate(); + M_land_dist_noise_rate = SP.landDistNoiseRate(); + M_land_focus_dist_noise_rate = SP.landFocusDistNoiseRate(); } /*-------------------------------------------------------------------*/ @@ -398,10 +499,11 @@ PlayerType::parseV8( const char * msg ) if ( std::sscanf( msg, " ( player_type ( %s %d ) %n ", name, &id, &n_read ) != 2 || n_read == 0 + || std::strcmp( name, "id" ) != 0 || id < 0 ) { - std::cerr << __FILE__ << ":(PlayerType::parseV8) " - << "ERROR: could not read id value " << msg << std::endl; + std::cerr << "(PlayerType::parseV8) " + << "ERROR: could not read the id value " << msg << std::endl; return; } msg += n_read; @@ -416,7 +518,7 @@ PlayerType::parseV8( const char * msg ) name, &val, &n_read ) != 2 || n_read == 0 ) { - std::cerr << __FILE__ << ":(PlayerType::parseV8) " + std::cerr << "(PlayerType::parseV8) " << " ERROR: illegal parameter format " << msg << std::endl; break; } @@ -522,9 +624,25 @@ PlayerType::parseV8( const char * msg ) { M_flag_max_observation_length = val; } + else if ( ! std::strcmp( name, "dist_noise_rate" ) ) + { + M_dist_noise_rate = val; + } + else if ( ! std::strcmp( name, "focus_dist_noise_rate" ) ) + { + M_focus_dist_noise_rate = val; + } + else if ( ! std::strcmp( name, "land_dist_noise_rate" ) ) + { + M_land_dist_noise_rate = val; + } + else if ( ! std::strcmp( name, "land_focus_dist_noise_rate" ) ) + { + M_land_focus_dist_noise_rate = val; + } else { - std::cerr << __FILE__ << ":(PlayerType::parseV8) " + std::cerr << "(PlayerType::parseV8) " << " ERROR: unsupported parameter name " << name << std::endl; break; } @@ -683,18 +801,18 @@ PlayerType::reliableCatchLength() const /*! */ -double -PlayerType::reliableCatchableDist() const -{ - if ( ServerParam::i().catchProbability() < 1.0 ) - { - return 0.0; - } - else - { - return M_reliable_catchable_dist; - } -} +// double +// PlayerType::reliableCatchableDist() const +// { +// if ( ServerParam::i().catchProbability() < 1.0 ) +// { +// return 0.0; +// } +// else +// { +// return M_reliable_catchable_dist; +// } +// } /*-------------------------------------------------------------------*/ /*! @@ -1078,6 +1196,67 @@ PlayerType::dashRate( const double & effort, return dashRate( effort ) * ServerParam::i().dashDirRate( rel_dir ); } +/*-------------------------------------------------------------------*/ +double +PlayerType::getBipedalRotation( const double dash_power_left, + const double dash_dir_left, + const double dash_power_right, + const double dash_dir_right, + const double effort ) const +{ + const ServerParam & SP = ServerParam::i(); + + const Vector2D accel_left + = Vector2D::from_polar( SP.normalizeDashPower( dash_power_left ) * dashRate( effort, dash_dir_left ), + SP.discretizeDashAngle( dash_dir_left ) ); + const Vector2D accel_right + = Vector2D::from_polar( SP.normalizeDashPower( dash_power_right ) * dashRate( effort, dash_dir_right ), + SP.discretizeDashAngle( dash_dir_right ) ); + + return AngleDeg::normalize_angle( AngleDeg::RAD2DEG * ( accel_left.x - accel_right.x ) / ( playerSize() * 2.0 ) ); +} + +/*-------------------------------------------------------------------*/ +double +PlayerType::getBipedalRotation( const double dash_power_backward, + const double effort ) const +{ + // the magnitude of the forward accel must be same as the backward one. + const double accel = ServerParam::i().normalizeDashPower( dash_power_backward ) + * dashRate( effort ) + * ServerParam::i().backDashRate(); + // the difference between the forward accel and the backward one is the twile of the backword accel + return AngleDeg::normalize_angle( AngleDeg::RAD2DEG * ( accel * 2.0 ) / ( playerSize() * 2.0 ) ); +} + +/*-------------------------------------------------------------------*/ +std::pair< double, double > +PlayerType::getBipedalPowers( const AngleDeg & rotation, + const double effort ) const +{ + /* + (accel_outer + accel_inner) / (player_size * 2) = rotation_radian + accel_outer + accel_inner = rotation_radian * player_size * 2 + + accel_outer = outer_power * dprate * effort + accel_inner = inner_power * back_dash_rate * dprate * effort + + outer_power = inner_power * back_dash_rate + accel_outer = inner_power * back_dash_rate * dprate * effort + accel_inner = inner_power * back_dash_rate * dprate * effort + + 2 * accel_inner = rotation_radian * player_size * 2 + accel_inner = rotation_radian * player_size + inner_power * back_dash_rate * dprate * effort = rotation_radian * player_size + inner_power = ( rotation_radian * player_size ) / (back_dash_rate * dprate * effort) + */ + const double inner_power + = ( std::fabs( rotation.radian() ) * playerSize() ) + / ( dashRate( effort ) * ServerParam::i().backDashRate() ); + return std::make_pair( inner_power * ServerParam::i().backDashRate(), + inner_power ); +} + /*-------------------------------------------------------------------*/ /*! diff --git a/rcsc/common/player_type.h b/rcsc/common/player_type.h index a30ac0c..845fe82 100644 --- a/rcsc/common/player_type.h +++ b/rcsc/common/player_type.h @@ -33,7 +33,6 @@ #define RCSC_PARAM_PLAYER_TYPE_H #include -#include #include #include @@ -43,6 +42,11 @@ namespace rcsc { +namespace rcg { +struct player_type_t; +struct PlayerTypeT; +} + /*! \class PlayerType \brief heterogeneous player parametor class @@ -78,6 +82,12 @@ class PlayerType { double M_flag_chg_too_far_length;//!< Distance where the flag relative velocityr becomes completely unobservable double M_flag_max_observation_length; //!< Maximum distance where the flag can be observed + // v19 + double M_dist_noise_rate; //!< noise rate for movable objects in Gaussian see mode + double M_focus_dist_noise_rate; //!< focus noise rate for movable objects in Gaussian see mode + double M_land_dist_noise_rate; //!< noise rate for landmark objects in Gaussian see mode + double M_land_focus_dist_noise_rate; //!< focus noise rate for landmark objects in Gaussian see mode + // // additional parameters // @@ -125,12 +135,20 @@ class PlayerType { const double & version ); /*! - \brief construct with monitor protocol + \brief construct by monitor data \param from monitor protocol data */ explicit PlayerType( const rcg::player_type_t & from ); + /*! + \brief construct by monitor data + \param from monitor protocol data + */ + explicit + PlayerType( const rcg::PlayerTypeT & from ); + + /*! \brief create new player type with randomly generated parameters, same as server's algorithm \param seed random seed @@ -145,6 +163,12 @@ class PlayerType { */ void convertTo( rcg::player_type_t & to ) const; + /*! + \brief conver to the data format in the rcg library + \param to reference to the data variable. + */ + void convertTo( rcg::PlayerTypeT & to ) const; + /*! \brief convert to the rcss parameter message \return parameter message string @@ -411,6 +435,32 @@ class PlayerType { return M_flag_max_observation_length; } + // v19 + + /*! + \brief get the distance noise rate value for movable objects in Gaussian see mode. + \return distance noise rate value + */ + double distNoiseRate() const { return M_dist_noise_rate; } + + /*! + \brief get the focus distance noise rate value for movable objects in Gaussian see mode. + \return distance noise rate value + */ + double focusDistNoiseRate() const { return M_focus_dist_noise_rate; } + + /*! + \brief get the distance noise rate value for landmark objects in Gaussian see mode. + \return distance noise rate value + */ + double landDistNoiseRate() const { return M_land_dist_noise_rate; } + + /*! + \brief get the focus distance noise rate value for landmark objects in Gaussian see mode. + \return distance noise rate value + */ + double landFocusDistNoiseRate() const { return M_land_focus_dist_noise_rate; } + //////////////////////////////////////////////// // additional parameters @@ -440,7 +490,10 @@ class PlayerType { \brief get the reliable distance for the catch command. This value is the length of the diagonal line of the reliable catchable area rectangle. \return the diagonal line length of the reliable catch area rectangle. if server::catch_probability < 1.0, 0.0 is always returned. */ - double reliableCatchableDist() const; + double reliableCatchableDist() const + { + return M_reliable_catchable_dist; + } /*! \brief get reliable catchable distance. This value is the length of the diagonal line of the reliable catchable area rectangle. @@ -667,6 +720,40 @@ class PlayerType { return command_moment / ( 1.0 + inertiaMoment() * speed ); } + /*! + \brief calculate the rotation with the given bipedal dash powers and direction + \param dash_power_left the dash power for the left leg + \param dash_dir_left the dash direction for both legs + \param dash_power_right the dash power for the right leg + \param dash_dir_right the dash direction for both legs + \param effort the effort value + \return estimated result rotation + */ + double getBipedalRotation( const double dash_power_left, + const double dash_dir_left, + const double dash_power_right, + const double dash_dir_right, + const double effort ) const; + /*! + \brief calculate the rotation with the given bipedal dash powers + \param dash_power_backward the dash power for backword + \param effort the effort value + \return estimated result rotation + */ + double getBipedalRotation( const double dash_power_backward, + const double effort ) const; + + /*! + \brief calculate the dash powers(outer and inner) to achieve the target rotation. + The outer power is assumed to be used as the acceleration in the direction of the body(dash_dir=0). + The inner power is assumed to be used as the acceleration in the opposite direction of the body(dash_dir=180). + Which leg is on the outside is determined by the positive or negative rotation angle, which must be determined outside of this function call. + \param effort the effort value + \return the dash powers [outer(dash_dir=0), inner(dash_dir=180)] + */ + std::pair< double, double > getBipedalPowers( const AngleDeg & rotation, + const double effort ) const; + /*! \brief calculate final reachable speed \param dash_power used dash power diff --git a/rcsc/common/server_param.cpp b/rcsc/common/server_param.cpp index d7d57b3..01a39a6 100644 --- a/rcsc/common/server_param.cpp +++ b/rcsc/common/server_param.cpp @@ -221,7 +221,7 @@ const int ServerParam::DEFAULT_ONLINE_COACH_PORT = 6002; const bool ServerParam::DEFAULT_VERBOSE_MODE = false; -const int ServerParam::DEFAULT_COACH_SEND_VI_STEP = 100; +const int ServerParam::DEFAULT_ONLINE_COACH_LOOK_STEP = 100; const std::string ServerParam::DEFAULT_REPLAY_FILE = ""; // unused after rcsserver-9+ const std::string ServerParam::DEFAULT_LANDMARK_FILE = "~/.rcssserver-landmark.xml"; @@ -344,9 +344,19 @@ const int ServerParam::ILLEGAL_DEFENSE_NUMBER = 0; const double ServerParam::ILLEGAL_DEFENSE_DIST_X = 16.5; const double ServerParam::ILLEGAL_DEFENSE_WIDTH = 40.32; +namespace { + // 17.0 -const double ServerParam::MAX_CATCH_ANGLE = +90.0; -const double ServerParam::MIN_CATCH_ANGLE = -90.0; +constexpr double MAX_CATCH_ANGLE = +90.0; +constexpr double MIN_CATCH_ANGLE = -90.0; + +// 19.0 +constexpr double DIST_NOISE_RATE = 0.0125; +constexpr double FOCUS_DIST_NOISE_RATE = 0.0125; +constexpr double LAND_DIST_NOISE_RATE = 0.00125; +constexpr double LAND_FOCUS_DIST_NOISE_RATE = 0.00125; + +} /* It is necessary to check out whether server is NEW_QSTEP mode @@ -536,7 +546,7 @@ ServerParam::setDefaultParam() M_verbose_mode = DEFAULT_VERBOSE_MODE; - M_coach_send_vi_step = DEFAULT_COACH_SEND_VI_STEP; + M_online_coach_look_step = DEFAULT_ONLINE_COACH_LOOK_STEP; M_replay_file = DEFAULT_REPLAY_FILE; M_landmark_file = DEFAULT_LANDMARK_FILE; @@ -667,6 +677,12 @@ ServerParam::setDefaultParam() M_max_catch_angle = MAX_CATCH_ANGLE; M_min_catch_angle = MIN_CATCH_ANGLE; + // 19.0 + M_dist_noise_rate = DIST_NOISE_RATE; + M_focus_dist_noise_rate = FOCUS_DIST_NOISE_RATE; + M_land_dist_noise_rate = LAND_DIST_NOISE_RATE; + M_land_focus_dist_noise_rate = LAND_FOCUS_DIST_NOISE_RATE; + // XXX M_random_seed = -1; M_long_kick_power_factor = 2.0; @@ -851,7 +867,7 @@ ServerParam::createMap() ( "verbose", "", &M_verbose_mode ) - ( "send_vi_step", "", &M_coach_send_vi_step ) + ( "send_vi_step", "", &M_online_coach_look_step ) ( "replay", "", &M_replay_file ) // unused after rcsserver-9+ ( "landmark_file", "", &M_landmark_file ) @@ -977,6 +993,12 @@ ServerParam::createMap() // 17.0 ( "max_catch_angle", "", &M_max_catch_angle ) ( "min_catch_angle", "", &M_min_catch_angle ) + // 19.0 + ( "dist_noise_rate", "", &M_dist_noise_rate ) + ( "focus_dist_noise_rate", "", &M_focus_dist_noise_rate ) + ( "land_dist_noise_rate", "", &M_land_dist_noise_rate ) + ( "land_focus_dist_noise_rate", "", &M_land_focus_dist_noise_rate ) + // XXX //( "random_seed", "", &M_random_seed ) ; } @@ -1140,7 +1162,7 @@ ServerParam::parseV7( const char * msg ) >> M_coach_mode >> M_coach_with_referee_mode >> M_use_old_coach_hear - >> M_coach_send_vi_step + >> M_online_coach_look_step >> M_start_goal_l >> M_start_goal_r >> M_fullstate_l @@ -1335,7 +1357,7 @@ ServerParam::convertFrom( const rcg::server_params_t & from ) M_coach_with_referee_mode = rcg::nstohb( from.coach_with_referee_mode ); M_use_old_coach_hear = rcg::nstohb( from.use_old_coach_hear ); - M_coach_send_vi_step = rcg::nstohi( from.online_coach_look_step ); + M_online_coach_look_step = rcg::nstohi( from.online_coach_look_step ); M_slowness_on_top_for_left_team = rcg::nltohd( from.slowness_on_top_for_left_team ); M_slowness_on_top_for_right_team = rcg::nltohd( from.slowness_on_top_for_right_team ); @@ -1380,9 +1402,226 @@ ServerParam::convertFrom( const rcg::server_params_t & from ) } /*-------------------------------------------------------------------*/ -/*! +void +ServerParam::convertFrom( const rcg::ServerParamT & from ) +{ + M_goal_width = from.goal_width_; + M_inertia_moment = from.inertia_moment_; + M_player_size = from.player_size_; + M_player_decay = from.player_decay_; + M_player_rand = from.player_rand_; + M_player_weight = from.player_weight_; + M_player_speed_max = from.player_speed_max_; + M_player_accel_max = from.player_accel_max_; + M_stamina_max = from.stamina_max_; + M_stamina_inc_max = from.stamina_inc_max_; + M_recover_init = from.recover_init_; + M_recover_dec_thr = from.recover_dec_thr_; + M_recover_min = from.recover_min_; + M_recover_dec = from.recover_dec_; + M_effort_init = from.effort_init_; + M_effort_dec_thr = from.effort_dec_thr_; + M_effort_min = from.effort_min_; + M_effort_dec =from.effort_dec_; + M_effort_inc_thr = from.effort_inc_thr_; + M_effort_inc = from.effort_inc_; + M_kick_rand = from.kick_rand_; + M_team_actuator_noise = from.team_actuator_noise_; + M_player_rand_factor_l = from.player_rand_factor_l_; + M_player_rand_factor_r = from.player_rand_factor_r_; + M_kick_rand_factor_l = from.kick_rand_factor_l_; + M_kick_rand_factor_r = from.kick_rand_factor_r_; + M_ball_size = from.ball_size_; + M_ball_decay = from.ball_decay_; + M_ball_rand = from.ball_rand_; + M_ball_weight = from.ball_weight_; + M_ball_speed_max =from.ball_speed_max_; + M_ball_accel_max = from.ball_accel_max_; + M_dash_power_rate = from.dash_power_rate_; + M_kick_power_rate = from.kick_power_rate_; + M_kickable_margin = from.kickable_margin_; + M_control_radius = from.control_radius_; + M_catch_probability = from.catch_probability_; + M_catch_area_l = from.catchable_area_l_; + M_catch_area_w = from.catchable_area_w_; + M_goalie_max_moves = from.goalie_max_moves_; + M_max_power = from.max_power_; + M_min_power = from.min_power_; + M_max_moment = from.max_moment_; + M_min_moment = from.min_moment_; + M_max_neck_moment = from.max_neck_moment_; + M_min_neck_moment = from.min_neck_moment_; + M_max_neck_angle = from.max_neck_angle_; + M_min_neck_angle = from.min_neck_angle_; + M_visible_angle = from.visible_angle_; + M_visible_distance = from.visible_distance_; + M_audio_cut_dist = from.audio_cut_dist_; + M_dist_quantize_step = from.dist_quantize_step_; + M_landmark_dist_quantize_step = from.landmark_dist_quantize_step_; + M_corner_kick_margin = from.corner_kick_margin_; + M_wind_dir = from.wind_dir_; + M_wind_force = from.wind_force_; + M_wind_angle = from.wind_angle_; + M_wind_rand = from.wind_rand_; + M_wind_none = from.wind_none_; + M_use_wind_random = from.use_wind_random_; + M_half_time = from.half_time_; + M_drop_ball_time = from.drop_ball_time_; + M_player_port = from.port_; + M_trainer_port = from.coach_port_; + M_online_coach_port = from.online_coach_port_; + M_coach_say_count_max = from.coach_say_count_max_; + M_coach_say_msg_size = from.coach_say_msg_size_; + M_simulator_step = from.simulator_step_; + M_send_step = from.send_step_; // player's see message interval for (normal,high) mode + M_recv_step = from.recv_step_; + M_sense_body_step = from.sense_body_step_; + M_player_say_msg_size = from.player_say_msg_size_; + M_clang_win_size = from.clang_win_size_; + M_clang_define_win = from.clang_define_win_; + M_clang_meta_win = from.clang_meta_win_; + M_clang_advice_win = from.clang_advice_win_; + M_clang_info_win = from.clang_info_win_; + M_clang_del_win = from.clang_del_win_; + M_clang_rule_win = from.clang_rule_win_; + M_clang_mess_delay = from.clang_mess_delay_; + M_clang_mess_per_cycle = from.clang_mess_per_cycle_; + M_player_hear_max = from.player_hear_max_; + M_player_hear_inc = from.player_hear_inc_; + M_player_hear_decay = from.player_hear_decay_; + M_catch_ban_cycle = from.catch_ban_cycle_; + M_coach_mode = from.coach_mode_; + M_coach_with_referee_mode = from.coach_with_referee_mode_; + M_use_old_coach_hear = from.use_old_coach_hear_; // old_coach_hear + M_online_coach_look_step = from.online_coach_look_step_; // send_vi_step: online coach's see_global interval + M_use_offside = from.use_offside_; + M_offside_active_area_size = from.offside_active_area_size_; + M_kickoff_offside = from.kickoff_offside_; // forbid_kick_off_offside + M_verbose_mode = from.verbose_; + M_offside_kick_margin = from.offside_kick_margin_; + M_slow_down_factor = from.slow_down_factor_; + M_synch_mode = from.synch_mode_; + M_synch_offset =from.synch_offset_; + M_synch_micro_sleep = from.synch_micro_sleep_; + M_start_goal_l = from.start_goal_l_; + M_start_goal_r = from.start_goal_r_; + M_fullstate_l = from.fullstate_l_; + M_fullstate_r = from.fullstate_r_; + M_slowness_on_top_for_left_team = from.slowness_on_top_for_left_team_; + M_slowness_on_top_for_right_team = from.slowness_on_top_for_right_team_; + M_landmark_file = from.landmark_file_; + M_send_comms = from.send_comms_; + M_text_logging = from.text_logging_; + M_game_logging = from.game_logging_; + M_game_log_version = from.game_log_version_; + M_text_log_dir = from.text_log_dir_; + M_game_log_dir = from.game_log_dir_; + M_text_log_fixed_name = from.text_log_fixed_name_; + M_game_log_fixed_name = from.game_log_fixed_name_; + M_use_text_log_fixed = from.text_log_fixed_; + M_use_game_log_fixed = from.game_log_fixed_; + M_use_text_log_dated = from.text_log_dated_; + M_use_game_log_dated = from.game_log_dated_; + M_log_date_format = from.log_date_format_; + M_log_times = from.log_times_; + M_record_message = from.record_messages_; + M_text_log_compression = from.text_log_compression_; + M_game_log_compression = from.game_log_compression_; + M_use_profile = from.profile_; + M_point_to_ban = from.point_to_ban_; + M_point_to_duration = from.point_to_duration_; + M_tackle_dist = from.tackle_dist_; + M_tackle_back_dist = from.tackle_back_dist_; + M_tackle_width = from.tackle_width_; + M_tackle_exponent = from.tackle_exponent_; + M_tackle_cycles = from.tackle_cycles_; + M_tackle_power_rate = from.tackle_power_rate_; + M_freeform_wait_period = from.freeform_wait_period_; + M_freeform_send_period = from.freeform_send_period_; + M_free_kick_faults = from.free_kick_faults_; + M_back_passes = from.back_passes_; + M_proper_goal_kicks = from.proper_goal_kicks_; + M_stopped_ball_vel = from.stopped_ball_vel_; + M_max_goal_kicks = from.max_goal_kicks_; + M_auto_mode = from.auto_mode_; + M_kick_off_wait = from.kick_off_wait_; + M_connect_wait = from.connect_wait_; + M_game_over_wait = from.game_over_wait_; + M_team_l_start = from.team_l_start_; + M_team_r_start = from.team_r_start_; + M_keepaway_mode = from.keepaway_mode_; + M_keepaway_length = from.keepaway_length_; + M_keepaway_width = from.keepaway_width_; + M_keepaway_logging = from.keepaway_logging_; + M_keepaway_log_dir = from.keepaway_log_dir_; + M_keepaway_log_fixed_name = from.keepaway_log_fixed_name_; + M_keepaway_log_fixed = from.keepaway_log_fixed_; + M_keepaway_log_dated = from.keepaway_log_dated_; + M_keepaway_start = from.keepaway_start_; + M_nr_normal_halfs = from.nr_normal_halfs_; + M_nr_extra_halfs = from.nr_extra_halfs_; + M_penalty_shoot_outs = from.penalty_shoot_outs_; + M_pen_before_setup_wait = from.pen_before_setup_wait_; + M_pen_setup_wait = from.pen_setup_wait_; + M_pen_ready_wait = from.pen_ready_wait_; + M_pen_taken_wait = from.pen_taken_wait_; + M_pen_nr_kicks = from.pen_nr_kicks_; + M_pen_max_extra_kicks = from.pen_max_extra_kicks_; + M_pen_dist_x = from.pen_dist_x_; + M_pen_random_winner = from.pen_random_winner_; + M_pen_max_goalie_dist_x = from.pen_max_goalie_dist_x_; + M_pen_allow_mult_kicks = from.pen_allow_mult_kicks_; + M_pen_coach_moves_players = from.pen_coach_moves_players_; + // v11 + M_ball_stuck_area = from.ball_stuck_area_; + M_coach_msg_file = from.coach_msg_file_; + // v12 + M_max_tackle_power = from.max_tackle_power_; + M_max_back_tackle_power = from.max_back_tackle_power_; + M_player_speed_max_min = from.player_speed_max_min_; + M_extra_stamina = from.extra_stamina_; + M_synch_see_offset = from.synch_see_offset_; + M_max_monitors = from.max_monitors_; + // v12.1.3 + M_extra_half_time = from.extra_half_time_; + // v13 + M_stamina_capacity = from.stamina_capacity_; + M_max_dash_angle = from.max_dash_angle_; + M_min_dash_angle = from.min_dash_angle_; + M_dash_angle_step = from.dash_angle_step_; + M_side_dash_rate = from.side_dash_rate_; + M_back_dash_rate = from.back_dash_rate_; + M_max_dash_power = from.max_dash_power_; + M_min_dash_power = from.min_dash_power_; + // 14.0 + M_tackle_rand_factor = from.tackle_rand_factor_; + M_foul_detect_probability = from.foul_detect_probability_; + M_foul_exponent = from.foul_exponent_; + M_foul_cycles = from.foul_cycles_; + M_golden_goal = from.golden_goal_; + // v15 + M_red_card_probability = from.red_card_probability_; + // v16.0 + M_illegal_defense_duration = from.illegal_defense_duration_; + M_illegal_defense_number = from.illegal_defense_number_; + M_illegal_defense_dist_x = from.illegal_defense_dist_x_; + M_illegal_defense_width = from.illegal_defense_width_; + M_fixed_teamname_l = from.fixed_teamname_l_; + M_fixed_teamname_r = from.fixed_teamname_r_; + // v17 + M_max_catch_angle = from.max_catch_angle_; + M_min_catch_angle = from.min_catch_angle_; + // v19 + M_dist_noise_rate = from.dist_noise_rate_; + M_focus_dist_noise_rate = from.focus_dist_noise_rate_; + M_land_dist_noise_rate = from.land_dist_noise_rate_; + M_land_focus_dist_noise_rate = from.land_focus_dist_noise_rate_; -*/ + // + setAdditionalParam(); +} + +/*-------------------------------------------------------------------*/ void ServerParam::convertTo( rcg::server_params_t & to ) const { @@ -1509,7 +1748,7 @@ ServerParam::convertTo( rcg::server_params_t & to ) const to.coach_with_referee_mode = rcg::hbtons( M_coach_with_referee_mode ); to.use_old_coach_hear = rcg::hbtons( M_use_old_coach_hear ); - to.online_coach_look_step = rcg::hitons( M_coach_send_vi_step ); + to.online_coach_look_step = rcg::hitons( M_online_coach_look_step ); to.slowness_on_top_for_left_team = rcg::hdtonl( M_slowness_on_top_for_left_team ); to.slowness_on_top_for_right_team = rcg::hdtonl( M_slowness_on_top_for_right_team ); @@ -1544,9 +1783,223 @@ ServerParam::convertTo( rcg::server_params_t & to ) const } /*-------------------------------------------------------------------*/ -/*! +void +ServerParam::convertTo( rcg::ServerParamT & to ) const +{ + to.goal_width_ = M_goal_width; + to.inertia_moment_ = M_inertia_moment; + to.player_size_ = M_player_size;; + to.player_decay_ = M_player_decay; + to.player_rand_ = M_player_rand; + to.player_weight_ = M_player_weight; + to.player_speed_max_ = M_player_speed_max; + to.player_accel_max_ = M_player_accel_max; + to.stamina_max_ = M_stamina_max; + to.stamina_inc_max_ = M_stamina_inc_max; + to.recover_init_ = M_recover_init; + to.recover_dec_thr_ = M_recover_dec_thr; + to.recover_min_ = M_recover_min; + to.recover_dec_ = M_recover_dec; + to.effort_init_ = M_effort_init; + to.effort_dec_thr_ = M_effort_dec_thr; + to.effort_min_ = M_effort_min; + to.effort_dec_ = M_effort_dec; + to.effort_inc_thr_ = M_effort_inc_thr; + to.effort_inc_ = M_effort_inc; + to.kick_rand_ = M_kick_rand; + to.team_actuator_noise_ = M_team_actuator_noise; + to.player_rand_factor_l_ = M_player_rand_factor_l; + to.player_rand_factor_r_ = M_player_rand_factor_r; + to.kick_rand_factor_l_ = M_kick_rand_factor_l; + to.kick_rand_factor_r_ = M_kick_rand_factor_r; + to.ball_size_ = M_ball_size; + to.ball_decay_ = M_ball_decay; + to.ball_rand_ = M_ball_rand; + to.ball_weight_ = M_ball_weight; + to.ball_speed_max_ = M_ball_speed_max; + to.ball_accel_max_ = M_ball_accel_max; + to.dash_power_rate_ = M_dash_power_rate; + to.kick_power_rate_ = M_kick_power_rate; + to.kickable_margin_ = M_kickable_margin; + to.control_radius_ = M_control_radius; + to.catch_probability_ = M_catch_probability; + to.catchable_area_l_ = M_catch_area_l; + to.catchable_area_w_ = M_catch_area_w; + to.goalie_max_moves_ = M_goalie_max_moves; + to.max_power_ = M_max_power; + to.min_power_ = M_min_power; + to.max_moment_ = M_max_moment; + to.min_moment_ = M_min_moment; + to.max_neck_moment_ = M_max_neck_moment; + to.min_neck_moment_ = M_min_neck_moment; + to.max_neck_angle_ = M_max_neck_angle; + to.min_neck_angle_ = M_min_neck_angle; + to.visible_angle_ = M_visible_angle; + to.visible_distance_ = M_visible_distance; + to.audio_cut_dist_ = M_audio_cut_dist; + to.dist_quantize_step_ = M_dist_quantize_step; + to.landmark_dist_quantize_step_ = M_landmark_dist_quantize_step; + to.corner_kick_margin_ = M_corner_kick_margin; + to.wind_dir_ = M_wind_dir; + to.wind_force_ = M_wind_force; + to.wind_angle_ = M_wind_angle; + to.wind_rand_ = M_wind_rand; + to.wind_none_ = M_wind_none; + to.use_wind_random_ = M_use_wind_random; + to.half_time_ = M_half_time; + to.drop_ball_time_ = M_drop_ball_time; + to.port_ = M_player_port; + to.coach_port_ = M_trainer_port; + to.online_coach_port_ = M_online_coach_port; + to.coach_say_count_max_ = M_coach_say_count_max; + to.coach_say_msg_size_ = M_coach_say_msg_size; + to.simulator_step_ = M_simulator_step; + to.send_step_ = M_send_step; + to.recv_step_ = M_recv_step; + to.sense_body_step_ = M_sense_body_step; + to.player_say_msg_size_ = M_player_say_msg_size; + to.clang_win_size_ = M_clang_win_size; + to.clang_define_win_ = M_clang_define_win; + to.clang_meta_win_ = M_clang_meta_win; + to.clang_advice_win_ = M_clang_advice_win; + to.clang_info_win_ = M_clang_info_win; + to.clang_del_win_ = M_clang_del_win; + to.clang_rule_win_ = M_clang_rule_win; + to.clang_mess_delay_ = M_clang_mess_delay; + to.clang_mess_per_cycle_ = M_clang_mess_per_cycle; + to.player_hear_max_ = M_player_hear_max; + to.player_hear_inc_ = M_player_hear_inc; + to.player_hear_decay_ = M_player_hear_decay; + to.catch_ban_cycle_ = M_catch_ban_cycle; + to.coach_mode_ = M_coach_mode; + to.coach_with_referee_mode_ = M_coach_with_referee_mode; + to.use_old_coach_hear_ = M_use_old_coach_hear; + to.online_coach_look_step_ = M_online_coach_look_step; + to.use_offside_ = M_use_offside; + to.offside_active_area_size_ = M_offside_active_area_size; + to.kickoff_offside_ = M_kickoff_offside; + to.verbose_ = M_verbose_mode; + to.offside_kick_margin_ = M_offside_kick_margin; + to.slow_down_factor_ = M_slow_down_factor; + to.synch_mode_ = M_synch_mode; + to.synch_offset_ = M_synch_offset; + to.synch_micro_sleep_ = M_synch_micro_sleep; + to.start_goal_l_ = M_start_goal_l; + to.start_goal_r_ = M_start_goal_r; + to.fullstate_l_ = M_fullstate_l; + to.fullstate_r_ = M_fullstate_r; + to.slowness_on_top_for_left_team_ = M_slowness_on_top_for_left_team; + to.slowness_on_top_for_right_team_ = M_slowness_on_top_for_right_team; + to.landmark_file_ = M_landmark_file; + to.send_comms_ = M_send_comms; + to.text_logging_ = M_text_logging; + to.game_logging_ = M_game_logging; + to.game_log_version_ = M_game_log_version; + to.text_log_dir_ = M_text_log_dir; + to.game_log_dir_ = M_game_log_dir; + to.text_log_fixed_name_ = M_text_log_fixed_name; + to.game_log_fixed_name_ = M_game_log_fixed_name; + to.text_log_fixed_ = M_use_text_log_fixed; + to.game_log_fixed_ = M_use_game_log_fixed; + to.text_log_dated_ = M_use_text_log_dated; + to.game_log_dated_ = M_use_game_log_dated; + to.log_date_format_ = M_log_date_format; + to.log_times_ = M_log_times; + to.record_messages_ = M_record_message; + to.text_log_compression_ = M_text_log_compression; + to.game_log_compression_ = M_game_log_compression; + to.profile_ = M_use_profile; + to.point_to_ban_ = M_point_to_ban; + to.point_to_duration_ = M_point_to_duration; + to.tackle_dist_ = M_tackle_dist; + to.tackle_back_dist_ = M_tackle_back_dist; + to.tackle_width_ = M_tackle_width; + to.tackle_exponent_ = M_tackle_exponent; + to.tackle_cycles_ = M_tackle_cycles;; + to.tackle_power_rate_ = M_tackle_power_rate; + to.freeform_wait_period_ = M_freeform_wait_period; + to.freeform_send_period_ = M_freeform_send_period; + to.free_kick_faults_ = M_free_kick_faults; + to.back_passes_ = M_back_passes; + to.proper_goal_kicks_ = M_proper_goal_kicks; + to.stopped_ball_vel_ = M_stopped_ball_vel; + to.max_goal_kicks_ = M_max_goal_kicks; + to.auto_mode_ = M_auto_mode; + to.kick_off_wait_ = M_kick_off_wait; + to.connect_wait_ = M_connect_wait; + to.game_over_wait_ = M_game_over_wait; + to.team_l_start_ = M_team_l_start; + to.team_r_start_ = M_team_r_start; + to.keepaway_mode_ = M_keepaway_mode; + to.keepaway_length_ = M_keepaway_length; + to.keepaway_width_ = M_keepaway_width; + to.keepaway_logging_ = M_keepaway_logging; + to.keepaway_log_dir_ = M_keepaway_log_dir; + to.keepaway_log_fixed_name_ = M_keepaway_log_fixed_name; + to.keepaway_log_fixed_ = M_keepaway_log_fixed; + to.keepaway_log_dated_ = M_keepaway_log_dated; + to.keepaway_start_ = M_keepaway_start; + to.nr_normal_halfs_ = M_nr_normal_halfs; + to.nr_extra_halfs_ = M_nr_extra_halfs; + to.penalty_shoot_outs_ = M_penalty_shoot_outs; + to.pen_before_setup_wait_ = M_pen_before_setup_wait; + to.pen_setup_wait_ = M_pen_setup_wait; + to.pen_ready_wait_ = M_pen_ready_wait; + to.pen_taken_wait_ = M_pen_taken_wait; + to.pen_nr_kicks_ = M_pen_nr_kicks; + to.pen_max_extra_kicks_ = M_pen_max_extra_kicks; + to.pen_dist_x_ = M_pen_dist_x; + to.pen_random_winner_ = M_pen_random_winner; + to.pen_max_goalie_dist_x_ = M_pen_max_goalie_dist_x; + to.pen_allow_mult_kicks_ = M_pen_allow_mult_kicks; + to.pen_coach_moves_players_ = M_pen_coach_moves_players; + // v11 + to.ball_stuck_area_ = M_ball_stuck_area; + to.coach_msg_file_ = M_coach_msg_file; + // v12 + to.max_tackle_power_ = M_max_tackle_power; + to.max_back_tackle_power_ = M_max_back_tackle_power; + to.player_speed_max_min_ = M_player_speed_max_min; + to.extra_stamina_ = M_extra_stamina; + to.synch_see_offset_ = M_synch_see_offset; + to.max_monitors_ = M_max_monitors; + // v12.1.3 + to.extra_half_time_ = M_extra_half_time; + // v13 + to.stamina_capacity_ = M_stamina_capacity; + to.max_dash_angle_ = M_max_dash_angle; + to.min_dash_angle_ = M_min_dash_angle; + to.dash_angle_step_ = M_dash_angle_step; + to.side_dash_rate_ = M_side_dash_rate; + to.back_dash_rate_ = M_back_dash_rate; + to.max_dash_power_ = M_max_dash_power; + to.min_dash_power_ = M_min_dash_power; + // 14.0 + to.tackle_rand_factor_ = M_tackle_rand_factor; + to.foul_detect_probability_ = M_foul_detect_probability; + to.foul_exponent_ = M_foul_exponent; + to.foul_cycles_ = M_foul_cycles; + to.golden_goal_ = M_golden_goal; + // v15 + to.red_card_probability_ = M_red_card_probability; + // v16.0 + to.illegal_defense_duration_ = M_illegal_defense_duration; + to.illegal_defense_number_ = M_illegal_defense_number; + to.illegal_defense_dist_x_ = M_illegal_defense_dist_x; + to.illegal_defense_width_ = M_illegal_defense_width; + to.fixed_teamname_l_ = M_fixed_teamname_l; + to.fixed_teamname_r_ = M_fixed_teamname_r; + // v17 + to.max_catch_angle_ = M_max_catch_angle; + to.min_catch_angle_ = M_min_catch_angle; + // v19 + to.dist_noise_rate_ = M_dist_noise_rate; + to.focus_dist_noise_rate_ = M_focus_dist_noise_rate; + to.land_dist_noise_rate_ = M_land_dist_noise_rate; + to.land_focus_dist_noise_rate_ = M_land_focus_dist_noise_rate; +} -*/ +/*-------------------------------------------------------------------*/ std::string ServerParam::toServerString() const { @@ -1554,12 +2007,10 @@ ServerParam::toServerString() const os << "(server_param "; - for ( std::map< std::string, ParamEntity::Ptr >::const_iterator it = M_param_map->longNameMap().begin(), end = M_param_map->longNameMap().end(); - it != end; - ++it ) + for ( const ParamMap::Map::value_type & v : M_param_map->longNameMap() ) { - os << '(' << it->second->longName() << ' '; - it->second->printValue( os ); + os << '(' << v.second->longName() << ' '; + v.second->printValue( os ); os << ')'; } diff --git a/rcsc/common/server_param.h b/rcsc/common/server_param.h index 7863778..5186968 100644 --- a/rcsc/common/server_param.h +++ b/rcsc/common/server_param.h @@ -44,6 +44,7 @@ namespace rcsc { namespace rcg { struct server_params_t; +struct ServerParamT; } class ParamMap; @@ -231,7 +232,7 @@ class ServerParam { static const bool DEFAULT_VERBOSE_MODE; - static const int DEFAULT_COACH_SEND_VI_STEP; // defined as SEND_VISUALINFO_INTERVAL_MSEC in rcssserver/param.h + static const int DEFAULT_ONLINE_COACH_LOOK_STEP; // defined as SEND_VISUALINFO_INTERVAL_MSEC in rcssserver/param.h static const std::string DEFAULT_REPLAY_FILE; // unused after rcsserver-9+ static const std::string DEFAULT_LANDMARK_FILE; @@ -344,9 +345,7 @@ class ServerParam { static const int ILLEGAL_DEFENSE_NUMBER; static const double ILLEGAL_DEFENSE_DIST_X; static const double ILLEGAL_DEFENSE_WIDTH; - // 17.0 - static const double MAX_CATCH_ANGLE; - static const double MIN_CATCH_ANGLE; + private: ////////////////////////////////////////////////////// @@ -505,7 +504,7 @@ class ServerParam { bool M_verbose_mode; - int M_coach_send_vi_step; // coach's visual info step + int M_online_coach_look_step; // coach's visual info step std::string M_replay_file; // unused after rcsserver-9+ std::string M_landmark_file; @@ -643,6 +642,12 @@ class ServerParam { double M_max_catch_angle; double M_min_catch_angle; + // 19.0 + double M_dist_noise_rate; + double M_focus_dist_noise_rate; + double M_land_dist_noise_rate; + double M_land_focus_dist_noise_rate; + // xxx int M_random_seed; double M_long_kick_power_factor; @@ -733,12 +738,24 @@ class ServerParam { */ void convertFrom( const rcg::server_params_t & from ); + /*! + \brief convert from the data type in the rcg parser library. + \param from monitor protocol data structure + */ + void convertFrom( const rcg::ServerParamT & from ); + /*! \brief convert to the monitor protocol format \param to monitor protocol data structure */ void convertTo( rcg::server_params_t & to ) const; + /*! + \brief convert from the data type in the rcg parser library. + \param from monitor protocol data structure + */ + void convertTo( rcg::ServerParamT & to ) const; + /*! \brief convert to the rcss parameter message \return parameter message string @@ -983,7 +1000,7 @@ class ServerParam { bool verboseMode() const { return M_verbose_mode; } - int coachSendVIStep() const { return M_coach_send_vi_step; } + int onlineCoachLookStep() const { return M_online_coach_look_step; } const std::string & replayFile() const { return M_replay_file; } const std::string & landmarkFile() const { return M_landmark_file; } @@ -1115,6 +1132,12 @@ class ServerParam { double maxCatchAngle() const { return M_max_catch_angle; } double minCatchAngle() const { return M_min_catch_angle; } + // v19 + double distNoiseRate() const { return M_dist_noise_rate; } + double focusDistNoiseRate() const { return M_focus_dist_noise_rate; } + double landDistNoiseRate() const { return M_land_dist_noise_rate; } + double landFocusDistNoiseRate() const { return M_land_focus_dist_noise_rate; } + // XXX int randomSeed() const { return M_random_seed; } double longKickPowerFactor() const { return M_long_kick_power_factor; } diff --git a/rcsc/common/stamina_model.cpp b/rcsc/common/stamina_model.cpp index 07863d9..c3f1e93 100644 --- a/rcsc/common/stamina_model.cpp +++ b/rcsc/common/stamina_model.cpp @@ -268,6 +268,20 @@ StaminaModel::simulateDash( const PlayerType & player_type, simulateWait( player_type ); } +/*-------------------------------------------------------------------*/ +void +StaminaModel::simulateDash( const PlayerType & player_type, + const double left_dash_power, + const double right_dash_power ) +{ + double left_stamina = ( left_dash_power < 0.0 ? -left_dash_power : left_dash_power * 0.5 ); + double right_stamina = ( right_dash_power < 0.0 ? -right_dash_power : right_dash_power * 0.5 ); + M_stamina -= ( left_stamina + right_stamina ); + M_stamina = std::max( 0.0, M_stamina ); + + simulateWait( player_type ); +} + /*-------------------------------------------------------------------*/ /*! diff --git a/rcsc/common/stamina_model.h b/rcsc/common/stamina_model.h index 3432b68..7d9c349 100644 --- a/rcsc/common/stamina_model.h +++ b/rcsc/common/stamina_model.h @@ -213,6 +213,16 @@ class StaminaModel { void simulateDash( const PlayerType & player_type, const double & dash_power ); + /*! + \brief simulate stamina variables after one dash. + \param player_type heterogeneous player type + \param left_dash_power dash power for simulation + \param right_dash_power dash power for simulation + */ + void simulateDash( const PlayerType & player_type, + const double left_dash_power, + const double right_dash_power ); + /*! \brief simulate stamina variables after nr dashes. \param player_type heterogeneous player type diff --git a/rcsc/common/team_graphic.cpp b/rcsc/common/team_graphic.cpp index e379344..7371792 100644 --- a/rcsc/common/team_graphic.cpp +++ b/rcsc/common/team_graphic.cpp @@ -100,7 +100,7 @@ read_xpm_header( std::istream & is, if ( ! read_xpm_string( is, buf ) ) { - std::cerr << __FILE__ << ' ' << __LINE__ + std::cerr << __FILE__ << ": (read_xpm_header) could not read xpm line. [" << buf << ']' << std::endl; @@ -110,7 +110,7 @@ read_xpm_header( std::istream & is, if ( std::sscanf( buf.c_str(), " %d %d %d %d ", width, height, n_color, cpp ) != 4 ) { - std::cerr << __FILE__ << ' ' << __LINE__ + std::cerr << __FILE__ << ": (read_xpm_header) Illegal xpm header [" << buf << "]" << std::endl; return false; @@ -121,9 +121,9 @@ read_xpm_header( std::istream & is, || *height % rcsc::TeamGraphic::TILE_SIZE != 0 || *height > rcsc::TeamGraphic::MAX_HEIGHT || *n_color < 1 - || *cpp != 1 ) + || *cpp != rcsc::TeamGraphic::CPP ) { - std::cerr << __FILE__ << ' ' << __LINE__ + std::cerr << __FILE__ << ": (read_xpm_header) Unsupported xpm data. [" << buf << "]\n" << " width=" << *width << " height=" << *height @@ -160,7 +160,7 @@ read_xpm_colors( std::istream & is, if ( ! read_xpm_string( is, buf ) || buf.empty() ) { - std::cerr << __FILE__ << ' ' << __LINE__ + std::cerr << __FILE__ << ": (read_xpm_colors) Illegal xpm color [" << buf << "]" << std::endl; return false; @@ -190,7 +190,7 @@ read_xpm_body( std::istream & is, if ( ! read_xpm_string( is, buf ) || buf.length() != width ) { - std::cerr << __FILE__ << ' ' << __LINE__ + std::cerr << __FILE__ << ": (read_xpm_body) Illegal xpm line [" << buf << "]" << std::endl; return false; @@ -208,23 +208,30 @@ read_xpm_body( std::istream & is, */ static bool -read_xpm( std::istream & is, - std::vector< std::string > & xpm_strings ) +xpm_file_to_strings( const std::string & filepath, + std::vector< std::string > & xpm_strings ) { + std::ifstream fin( filepath ); + if ( ! fin ) + { + std::cerr << __FILE__": (xpm_file_to_strings) Could not open the xpm file [" << filepath << "]" << std::endl; + return false; + } + int width, height, n_color, cpp; - if ( ! read_xpm_header( is, + if ( ! read_xpm_header( fin, xpm_strings, &width, &height, &n_color, &cpp ) ) { return false; } - if ( ! read_xpm_colors( is, n_color, xpm_strings ) ) + if ( ! read_xpm_colors( fin, n_color, xpm_strings ) ) { return false; } - if ( ! read_xpm_body( is, width, height, xpm_strings ) ) + if ( ! read_xpm_body( fin, width, height, xpm_strings ) ) { return false; } @@ -238,15 +245,7 @@ read_xpm( std::istream & is, namespace rcsc { -const int TeamGraphic::MAX_WIDTH = 256; -const int TeamGraphic::MAX_HEIGHT = 64; -const int TeamGraphic::TILE_SIZE = 8; -const int TeamGraphic::MAX_COLOR = 256; - /*-------------------------------------------------------------------*/ -/*! - - */ TeamGraphic::XpmTile::XpmTile( const int width, const int height, const int cpp ) @@ -258,67 +257,132 @@ TeamGraphic::XpmTile::XpmTile( const int width, } /*-------------------------------------------------------------------*/ -/*! - - */ std::ostream & -TeamGraphic::XpmTile::print( std::ostream & os ) const +TeamGraphic::XpmTile::print( std::ostream & os, + const char separator ) const { os << '"' << width() << ' ' << height() << ' ' << colors().size() << ' ' << cpp() << '"'; - //os << "\n"; for ( const std::shared_ptr< std::string > & c : colors() ) { - os << " \"" << *c << '"'; - //os << "\n"; + os << separator << '"' << *c << '"'; } for ( const std::string & line : pixelLines() ) { - os << " \"" << line << '"'; - //os << "\n"; + os << separator << '"' << line << '"'; } return os; } /*-------------------------------------------------------------------*/ -/*! - - */ TeamGraphic::TeamGraphic() : M_width( 0 ), M_height( 0 ), - M_cpp( 1 ) + M_cpp( CPP ) { } /*-------------------------------------------------------------------*/ -/*! - - */ void TeamGraphic::clear() { M_width = 0; M_height = 0; - M_cpp = 1; + M_cpp = CPP; M_colors.clear(); M_tiles.clear(); } /*-------------------------------------------------------------------*/ -/*! +bool +TeamGraphic::isValid() const +{ + if ( colors().empty() + || tiles().empty() + || width() <= 0 + || height() <= 0 + || M_cpp != 1 ) + { + return false; + } - */ + int max_x = 0; + int max_y = 0; + + for ( const Map::value_type & tile : tiles() ) + { + if ( tile.first.first > max_x ) max_x = tile.first.first; + if ( tile.first.second > max_y ) max_y = tile.first.second; + } + + if ( static_cast< int >( tiles().size() ) != ( max_x + 1 ) * ( max_y + 1 ) ) + { + return false; + } + + return true; +} + + +/*-------------------------------------------------------------------*/ bool -TeamGraphic::createXpmTiles( const char * const * xpm_data ) +TeamGraphic::readXpmFile( const std::string & filepath ) +{ + // + // read file stream and store to string vector + // + std::vector< std::string > xpm_strings; + if ( ! xpm_file_to_strings( filepath, xpm_strings ) ) + { + std::cerr << "Illegal xpm file [" << filepath << "]" + << std::endl; + return false; + } + + // + // create the char array + // + const size_t array_size = xpm_strings.size(); + char ** xpm; + xpm = new char*[ array_size ]; + for ( size_t i = 0; i < array_size; ++i ) + { + xpm[i] = new char[ xpm_strings[i].length() + 1 ]; + std::strcpy( xpm[i], xpm_strings[i].c_str() ); + } + + // + // create xpm tiles + // + bool result = true; + if ( ! fromRawXpm( xpm ) ) + { + result = false; + } + + // + // release the char array + // + for ( size_t i = 0; i < array_size; ++i ) + { + delete [] xpm[i]; + } + delete [] xpm; + + return result; +} + +/*-------------------------------------------------------------------*/ +bool +TeamGraphic::fromRawXpm( const char * const * xpm_data ) { if ( ! xpm_data ) return false; @@ -341,7 +405,7 @@ TeamGraphic::createXpmTiles( const char * const * xpm_data ) || xpm_height % TILE_SIZE != 0 || xpm_height > MAX_HEIGHT || xpm_n_color > MAX_COLOR - || xpm_cpp != 1 ) + || xpm_cpp != CPP ) { std::cerr << "Unsupported xpm data. \n" << " width=" << xpm_width @@ -420,9 +484,9 @@ TeamGraphic::createXpmTiles( const char * const * xpm_data ) Index index( index_x, index_y ); - Ptr tile( new XpmTile( ( max_x - start_x ) / xpm_cpp, // width - max_y - start_y, // height - xpm_cpp ) ); + XpmTile::Ptr tile( new XpmTile( ( max_x - start_x ) / xpm_cpp, // width + max_y - start_y, // height + xpm_cpp ) ); for ( int y = start_y; y < max_y; ++y ) { @@ -459,69 +523,37 @@ TeamGraphic::createXpmTiles( const char * const * xpm_data ) } } -#if 0 - // - // set shared color data strings - // - for ( const std::shared_ptr< std::string > & color : M_colors ) - { - for ( Map::iterator tile = M_tiles.begin(), tile_end = M_tiles.end(); - tile != tile_end; - ++tile ) - { - for ( const std::string & line = tile->second->pixelLines() ) - { - if ( line.find( (**color)[0] ) != std::string::npos ) - { - tile->second->addColor( color ); - break; - } - } - } - } -#endif return true; } /*-------------------------------------------------------------------*/ -/*! - - */ bool -TeamGraphic::parse( const char * server_msg ) +TeamGraphic::addXpmTile( const int x, + const int y, + const std::vector< std::string > & xpm_tile ) { - int n_read = 0; - char side = '?'; - int x = -1, y = -1; - - if ( std::sscanf( server_msg, "(team_graphic_%c ( %d %d %n ", - &side, &x, &y, - &n_read ) != 3 - || ( side != 'l' && side != 'r' ) - || x < 0 - || y < 0 - || n_read == 0 ) + if ( x < 0 + || y < 0 + || ( x + 1 ) * TILE_SIZE > MAX_WIDTH + || ( y + 1 ) * TILE_SIZE > MAX_HEIGHT ) { + std::cerr << "(TeamGraphic::addXpmTile) Unsupported xpm tile index [" << x << ',' << y << "]" << std::endl; return false; } - server_msg += n_read; - if ( ( x + 1 ) * TILE_SIZE > MAX_WIDTH - || ( y + 1 ) * TILE_SIZE > MAX_HEIGHT ) + if ( xpm_tile.empty() ) { - std::cerr << "Unsupported xpm tile index [" - << x << ',' << y << "]" - << std::endl; + std::cerr << "(TeamGraphic::addXpmTile) Empty data." << std::endl; return false; } // // header // - n_read = 0; + int n_read = 0; int xpm_width = 0, xpm_height = 0, xpm_n_color = 0, xpm_cpp = 0; - if ( std::sscanf( server_msg, - " \" %d %d %d %d \" %n ", + if ( std::sscanf( xpm_tile[0].c_str(), + " %d %d %d %d %n ", &xpm_width, &xpm_height, &xpm_n_color, &xpm_cpp, &n_read ) != 4 || xpm_width != TILE_SIZE @@ -530,32 +562,26 @@ TeamGraphic::parse( const char * server_msg ) || xpm_cpp != 1 || n_read == 0 ) { - std::cerr << "Illegal xpm header [" << server_msg << "]" - << std::endl; + std::cerr << "(TeamGraphic::addXpmTile) Illegal xpm header [" << xpm_tile[0] << "]" << std::endl; return false; } - server_msg += n_read; - - Index index( x, y ); - - Ptr tile( new XpmTile( xpm_width, xpm_height, xpm_cpp ) ); + if ( xpm_tile.size() != size_t( 1 + xpm_n_color + xpm_height ) ) + { + std::cerr << "(TeamGraphic::addXpmTile) Illegal xpm size. defined=" << xpm_tile[0] << " size=" << xpm_tile.size() << std::endl; + return false; + } - char line_buf[8192]; + const Index index( x, y ); + XpmTile::Ptr tile( new XpmTile( xpm_width, xpm_height, xpm_cpp ) ); // // colors // - for ( int i = 0; i < xpm_n_color; ++i ) + const size_t color_max( 1 + xpm_n_color ); + for ( size_t i = 1; i < color_max; ++i ) { - if ( std::sscanf( server_msg, " \"%8191[^\"]\" %n ", - line_buf, &n_read ) != 1 ) - { - return false; - } - server_msg += n_read; - - std::shared_ptr< std::string > new_col( new std::string( line_buf ) ); + std::shared_ptr< std::string > new_col( new std::string( xpm_tile[i] ) ); std::shared_ptr< std::string > col = findColor( *new_col ); if ( col ) { @@ -571,25 +597,21 @@ TeamGraphic::parse( const char * server_msg ) // // pixels // - for ( int i = 0; i < xpm_height; ++i ) - { - if ( std::sscanf( server_msg, " \"%8191[^\"]\" %n ", - line_buf, &n_read ) != 1 ) - { - return false; - } - server_msg += n_read; + const size_t pixel_max( 1 + xpm_n_color + xpm_height ); + const size_t line_width( xpm_width * xpm_cpp ); - if ( static_cast< int >( std::strlen( line_buf ) ) != xpm_width * xpm_cpp ) + for ( size_t i = color_max; i < pixel_max; ++i ) + { + if ( xpm_tile[i].length() != line_width ) { return false; } - tile->addPixelLine( line_buf ); + tile->addPixelLine( xpm_tile[i] ); } // insert new tile - M_tiles.insert( std::pair< Index, Ptr >( index, tile ) ); + M_tiles.insert( std::pair< Index, XpmTile::Ptr >( index, tile ) ); if ( M_width < ( x + 1 ) * TILE_SIZE ) { @@ -605,101 +627,6 @@ TeamGraphic::parse( const char * server_msg ) } /*-------------------------------------------------------------------*/ -/*! - - */ -bool -TeamGraphic::readXpmFile( const char * file_path ) -{ - std::ifstream fin( file_path ); - if ( ! fin ) - { - std::cerr << "Could not open the xpm file [" << file_path << "]" - << std::endl; - return false; - } - - // - // read file stream and store to string vector - // - std::vector< std::string > xpm_strings; - if ( ! read_xpm( fin, xpm_strings ) ) - { - std::cerr << "Illegal xpm file [" << file_path << "]" - << std::endl; - return false; - } - - // - // create the char array - // - const size_t array_size = xpm_strings.size(); - char ** xpm; - xpm = new char*[ array_size ]; - for ( size_t i = 0; i < array_size; ++i ) - { - xpm[i] = new char[ xpm_strings[i].length() + 1 ]; - std::strcpy( xpm[i], xpm_strings[i].c_str() ); - } - - // - // create xpm tiles - // - bool result = true; - if ( ! createXpmTiles( xpm ) ) - { - result = false; - } - - // - // release the char array - // - for ( size_t i = 0; i < array_size; ++i ) - { - delete [] xpm[i]; - } - delete [] xpm; - - return result; -} - -/*-------------------------------------------------------------------*/ -/*! - - */ -bool -TeamGraphic::isValid() const -{ - if ( colors().empty() - || tiles().empty() - || width() <= 0 - || height() <= 0 - || M_cpp != 1 ) - { - return false; - } - - int max_x = 0; - int max_y = 0; - - for ( const Map::value_type & tile : tiles() ) - { - if ( tile.first.first > max_x ) max_x = tile.first.first; - if ( tile.first.second > max_y ) max_y = tile.first.second; - } - - if ( static_cast< int >( tiles().size() ) != ( max_x + 1 ) * ( max_y + 1 ) ) - { - return false; - } - - return true; -} - -/*-------------------------------------------------------------------*/ -/*! - - */ std::shared_ptr< std::string > TeamGraphic::findColor( const std::string & str ) { @@ -714,23 +641,4 @@ TeamGraphic::findColor( const std::string & str ) return std::shared_ptr< std::string >(); } -/*-------------------------------------------------------------------*/ -/*! - - */ -std::ostream & -TeamGraphic::print( std::ostream & os ) const -{ - for ( const Map::value_type & tile : tiles() ) - { - //os << "colors = " << tile->second->colors().size() << "\n"; - os << '(' << tile.first.first - << ' ' << tile.first.second << ' '; - tile.second->print( os ); - os << ")\n"; - } - - return os; -} - } diff --git a/rcsc/common/team_graphic.h b/rcsc/common/team_graphic.h index 234f79e..f0c267e 100644 --- a/rcsc/common/team_graphic.h +++ b/rcsc/common/team_graphic.h @@ -47,13 +47,15 @@ class TeamGraphic { public: //! max pixel width of the team graphic - static const int MAX_WIDTH; + static constexpr int MAX_WIDTH = 256; //! max pixel height of the team graphic - static const int MAX_HEIGHT; + static constexpr int MAX_HEIGHT = 64; //! tile size unit - static const int TILE_SIZE; + static constexpr int TILE_SIZE = 8; //! max colors - static const int MAX_COLOR; + static constexpr int MAX_COLOR = 256; + //! characters per pixel + static constexpr int CPP = 1; /*! @@ -61,6 +63,9 @@ class TeamGraphic { \brief 8x8 pixels xpm data contained by the TeamGraphic */ class XpmTile { + public: + using Ptr = std::shared_ptr< XpmTile >; //!< XpmTile pointer + private: const int M_width; //!< width of this tile const int M_height; //!< height of this tile @@ -151,16 +156,15 @@ class TeamGraphic { /*! \brief output xpm lines \param os refrence to the output stream + \param separator separator character \return refrence to the output stream */ - std::ostream & print( std::ostream & os ) const; + std::ostream & print( std::ostream & os, + const char separator ) const; }; - - typedef std::shared_ptr< XpmTile > Ptr; //!< XpmTile pointer - typedef std::shared_ptr< const XpmTile > ConstPtr; //!< XpmTile pointer - typedef std::pair< int, int > Index; //!< xpm tile index - typedef std::map< Index, const Ptr > Map; //!< xpm tile map + using Index = std::pair< int, int >; //!< xpm tile index + using Map = std::map< Index, const XpmTile::Ptr >; //!< xpm tile map private: int M_width; //!< total pixmap width @@ -170,7 +174,7 @@ class TeamGraphic { //! color data strings std::vector< std::shared_ptr< std::string > > M_colors; - //! 8x8 xpm tiles + //! xpm tiles with index Map M_tiles; public: @@ -185,6 +189,12 @@ class TeamGraphic { */ void clear(); + /*! + \brief check if all xpm tiles have been completed or not + \return checked result + */ + bool isValid() const; + /*! \brief geth the total width of this team graphic \return pixel width value @@ -221,32 +231,30 @@ class TeamGraphic { return M_tiles; } - /*! - \brief create tiled xpm from the raw xpm data - \param xpm_data raw xpm string array - \return true if successfully parsed - */ - bool createXpmTiles( const char * const * xpm_data ); - - /*! - \brief analyze team_graphic_? message from rcssserver & add new xpm tile - \param server_msg raw server message - \return true if successfully analyzed - */ - bool parse( const char * server_msg ); - /*! \brief read xpm data from the input file \param file_path input file path \return parsing result */ - bool readXpmFile( const char * file_path ); + bool readXpmFile( const std::string & file_path ); /*! - \brief check if all xpm tiles have been completed or not - \return checked result + \brief create tiled xpm from the raw xpm data + \param xpm_data raw xpm string array + \return true if successfully parsed */ - bool isValid() const; + bool fromRawXpm( const char * const * xpm_data ); + + /*! + \brief create tiled xpm from the raw xpm data + \param x xpm tile index + \param y xpm tile index + \param xpm_tile raw xpm string array + \return true if successfully parsed + */ + bool addXpmTile( const int x, + const int y, + const std::vector< std::string > & xpm_tile ); private: @@ -257,14 +265,6 @@ class TeamGraphic { */ std::shared_ptr< std::string > findColor( const std::string & str ); -public: - - /*! - \brief output all tiled xpm data - \param os reference to the output stream - \return reference to the output stream - */ - std::ostream & print( std::ostream & os ) const; }; } diff --git a/rcsc/param/param_map.cpp b/rcsc/param/param_map.cpp index 777493e..24fecfd 100644 --- a/rcsc/param/param_map.cpp +++ b/rcsc/param/param_map.cpp @@ -35,16 +35,14 @@ #include "param_map.h" -#include +#include +#include namespace rcsc { namespace { /*-------------------------------------------------------------------*/ -/*! - - */ inline bool is_true( const std::string & value_str ) @@ -56,9 +54,6 @@ is_true( const std::string & value_str ) } /*-------------------------------------------------------------------*/ -/*! - - */ inline bool is_false( const std::string & value_str ) @@ -69,119 +64,253 @@ is_false( const std::string & value_str ) || value_str == "no" ); } -} - /*-------------------------------------------------------------------*/ -/*! - - */ -std::ostream & -ParamEntity::printFormat( std::ostream & os ) const -{ - os << "--" << longName(); - if ( ! shortName().empty() ) - { - os << " [ -" << shortName() << " ]"; - } - - os << " "; - return os; -} +struct IsSwitch { + + bool operator()( int * ) + { + return false; + } + + bool operator()( size_t * ) + { + return false; + } + + bool operator()( double * ) + { + return false; + } + + bool operator()( bool * ) + { + return false; + } + + bool operator()( NegateBool ) + { + return false; + } + + bool operator()( BoolSwitch ) + { + return true; + } + + bool operator()( NegateSwitch ) + { + return true; + } + + bool operator()( std::string * ) + { + return false; + } + +}; /*-------------------------------------------------------------------*/ -/*! +struct ValueParser { + const std::string & value_str; + + ValueParser( const std::string & str ) + : value_str( str ) + { } + + void operator()( int * ptr ) + { + *ptr = std::stoi( value_str ); + } + + void operator()( size_t * ptr ) + { + *ptr = std::stoul( value_str ); + } + + void operator()( double * ptr ) + { + *ptr = std::stod( value_str ); + } + + void operator()( bool * ptr ) + { + if ( is_true( value_str ) ) + { + *ptr = true; + } + else if ( is_false( value_str ) ) + { + *ptr = false; + } + else + { + throw( std::invalid_argument( "Unknown bool string." ) ); + } + } + + void operator()( NegateBool ptr ) + { + if ( is_true( value_str ) ) + { + *(ptr.ptr_) = false; + } + else if ( is_false( value_str ) ) + { + *(ptr.ptr_) = true; + } + else + { + throw( std::invalid_argument( "Unknown bool string." ) ); + } + } + + void operator()( BoolSwitch ptr ) + { + *(ptr.ptr_) = true; + } + + void operator()( NegateSwitch ptr ) + { + *(ptr.ptr_) = false; + } + + void operator()( std::string * ptr ) + { + *ptr = value_str; + } + +}; - */ -bool -ParamGeneric< bool >::analyze( const std::string & value_str ) -{ - if ( value_str.empty() ) - { - return false; - } - - if ( is_true( value_str ) ) - { - *M_value_ptr = true; - } - else if ( is_false( value_str ) ) - { - *M_value_ptr = false; - } - else - { - std::cerr << __FILE__ << ':' << __LINE__ - << " ***ERROR*** Unexpected value string: type bool. [" - << value_str << "]" - << std::endl; - return false; - } +/*-------------------------------------------------------------------*/ +struct PointerCheck { + + bool operator()( int * ptr ) + { + return ptr; + } + + bool operator()( size_t * ptr ) + { + return ptr; + } + + bool operator()( double * ptr ) + { + return ptr; + } + + bool operator()( bool * ptr ) + { + return ptr; + } + + bool operator()( NegateBool ptr ) + { + return ptr.ptr_; + } + + bool operator()( BoolSwitch ptr ) + { + return ptr.ptr_; + } + + bool operator()( NegateSwitch ptr ) + { + return ptr.ptr_; + } + + bool operator()( std::string * ptr ) + { + return ptr; + } + +}; - if ( M_negate ) - { - *M_value_ptr = ! *M_value_ptr; - } +/*-------------------------------------------------------------------*/ +struct ValuePrinter { + std::ostream & os_; + + ValuePrinter( std::ostream & os ) + : os_( os ) + { } + + void operator()( int * ptr ) + { + os_ << *ptr; + } + + void operator()( size_t * ptr ) + { + os_ << *ptr; + } + + void operator()( double * ptr ) + { + os_ << *ptr; + } + + void operator()( bool * ptr ) + { + os_ << std::boolalpha << *ptr; + } + + void operator()( NegateBool ptr ) + { + os_ << std::boolalpha << !*(ptr.ptr_); + } + + void operator()( BoolSwitch ptr ) + { + os_ << std::boolalpha << *(ptr.ptr_); + } + + void operator()( NegateSwitch ptr ) + { + os_ << std::boolalpha << !*(ptr.ptr_); + } + + void operator()( std::string * ptr ) + { + os_ << *ptr; + } +}; - return true; } /*-------------------------------------------------------------------*/ -/*! - - */ -std::ostream & -ParamGeneric< bool >::printValue( std::ostream & os ) const +bool +ParamEntity::isSwitch() const { - if ( M_negate ) + try { - os << std::boolalpha << ! *M_value_ptr; + return std::visit( IsSwitch(), M_value_ptr ); } - else + catch ( std::exception & e ) { - os << std::boolalpha << *M_value_ptr; + std::cerr << "(ParamEntity::isSwitch) " << e.what() << std::endl; } - return os; + return false; } /*-------------------------------------------------------------------*/ -/*! - - */ bool -ParamSwitch::analyze( const std::string & value_str ) +ParamEntity::analyze( const std::string & value_str ) { - if ( value_str.empty() - || is_true( value_str ) ) - { - *M_value_ptr = true; - } - else if ( is_false( value_str ) ) + try { - *M_value_ptr = false; + std::visit( ValueParser( value_str ), M_value_ptr ); } - else + catch ( std::exception & e ) { - std::cerr << __FILE__ << ':' << __LINE__ - << " ***ERROR*** Unexpected value string: type switch. [" - << value_str << "]" - << std::endl; + std::cerr << "(ParamEntity::analyze) parse error. " << e.what() << std::endl; return false; } - - if ( M_negate ) - { - *M_value_ptr = ! *M_value_ptr; - } - return true; } /*-------------------------------------------------------------------*/ -/*! - - */ std::ostream & -ParamSwitch::printFormat( std::ostream & os ) const +ParamEntity::printFormat( std::ostream & os ) const { os << "--" << longName(); if ( ! shortName().empty() ) @@ -189,35 +318,30 @@ ParamSwitch::printFormat( std::ostream & os ) const os << " [ -" << shortName() << " ]"; } + os << " "; return os; } /*-------------------------------------------------------------------*/ -/*! - - */ std::ostream & -ParamSwitch::printValue( std::ostream & os ) const +ParamEntity::printValue( std::ostream & os ) const { - if ( M_negate ) + try { - os << ( *M_value_ptr ? "off" : "on" ); + std::visit( ValuePrinter( os ), M_value_ptr ); } - else + catch ( std::exception & e ) { - os << ( *M_value_ptr ? "on" : "off" ); + std::cerr << "(ParamEntity::printValue) " << e.what() << std::endl; } return os; } /*-------------------------------------------------------------------*/ -/*! - - */ ParamMap::Registrar & ParamMap::Registrar::operator()( const std::string & long_name, const std::string & short_name, - const NegateBool & value, + ParamEntity::ValuePtr value_ptr, const char * description ) { if ( ! checkName( long_name, short_name ) ) @@ -226,95 +350,30 @@ ParamMap::Registrar::operator()( const std::string & long_name, return *this; } - if ( ! value.ptr_ ) + try { - std::cerr << "***ERROR*** detected null pointer for the option " - << long_name << std::endl; - M_param_map.M_valid = false; - return *this; - } - - ParamEntity::Ptr ptr( new ParamGeneric< bool >( long_name, - short_name, - value, - description ) ); - - M_param_map.add( ptr ); - - return *this; -} - - -/*-------------------------------------------------------------------*/ -/*! - - */ -ParamMap::Registrar & -ParamMap::Registrar::operator()( const std::string & long_name, - const std::string & short_name, - const BoolSwitch & value, - const char * description ) -{ - if ( ! checkName( long_name, short_name ) ) - { - M_param_map.M_valid = false; - return *this; - } - - if ( ! value.ptr_ ) - { - std::cerr << "***ERROR*** detected null pointer for the option " - << long_name << std::endl; - M_param_map.M_valid = false; - return *this; - } - - ParamEntity::Ptr ptr( new ParamSwitch( long_name, - short_name, - value.ptr_, - description ) ); - M_param_map.add( ptr ); - - return *this; -} - -/*-------------------------------------------------------------------*/ -/*! - - */ -ParamMap::Registrar & -ParamMap::Registrar::operator()( const std::string & long_name, - const std::string & short_name, - const NegateSwitch & value, - const char * description ) -{ - if ( ! checkName( long_name, short_name ) ) - { - M_param_map.M_valid = false; - return *this; + if ( ! std::visit( PointerCheck(), value_ptr ) ) + { + std::cerr << "***ERROR*** detected null pointer for the option " + << long_name << std::endl; + M_param_map.M_valid = false; + return *this; + } } - - if ( ! value.ptr_ ) + catch ( std::exception & e ) { - std::cerr << "***ERROR*** detected null pointer for the option " - << long_name << std::endl; + std::cerr << "(ParamMap::Regstrar) ERROR " << long_name << "\n" + << e.what() << std::endl; M_param_map.M_valid = false; return *this; } - ParamEntity::Ptr ptr( new ParamSwitch( long_name, - short_name, - value, - description ) ); + ParamEntity::Ptr ptr( new ParamEntity( long_name, short_name, value_ptr, description ) ); M_param_map.add( ptr ); - return *this; } /*-------------------------------------------------------------------*/ -/*! - - */ bool ParamMap::Registrar::checkName( const std::string & long_name, const std::string & short_name ) const @@ -344,31 +403,6 @@ ParamMap::Registrar::checkName( const std::string & long_name, } /*-------------------------------------------------------------------*/ -/*! - - */ -// ParamMap & -// ParamMap::add( ParamMap & param_map ) -// { -// if ( this == ¶m_map ) -// { -// return *this; -// } -// -// for ( std::vector< ParamEntity::Ptr >::iterator it = param_map.M_parameters.begin(); -// it != param_map.M_parameters.end(); -// ++it ) -// { -// add( *it ); -// } -// -// return *this; -// } - -/*-------------------------------------------------------------------*/ -/*! - - */ ParamMap::Registrar & ParamMap::add( ParamEntity::Ptr param ) { @@ -434,9 +468,6 @@ ParamMap::add( ParamEntity::Ptr param ) } /*-------------------------------------------------------------------*/ -/*! - - */ void ParamMap::remove( const std::string & long_name ) { @@ -448,12 +479,12 @@ ParamMap::remove( const std::string & long_name ) } ), M_parameters.end() ); - std::map< std::string, ParamEntity::Ptr >::iterator it_long = M_long_name_map.find( long_name ); + Map::iterator it_long = M_long_name_map.find( long_name ); if ( it_long != M_long_name_map.end() ) { if ( ! it_long->second->shortName().empty() ) { - std::map< std::string, ParamEntity::Ptr >::iterator it_short = M_short_name_map.find( it_long->second->shortName() ); + std::unordered_map< std::string, ParamEntity::Ptr >::iterator it_short = M_short_name_map.find( it_long->second->shortName() ); M_short_name_map.erase( it_short ); } @@ -462,13 +493,10 @@ ParamMap::remove( const std::string & long_name ) } /*-------------------------------------------------------------------*/ -/*! - - */ ParamEntity::Ptr ParamMap::findLongName( const std::string & long_name ) { - std::map< std::string, ParamEntity::Ptr >::iterator it = M_long_name_map.find( long_name ); + Map::iterator it = M_long_name_map.find( long_name ); if ( it != M_long_name_map.end() ) { @@ -479,13 +507,10 @@ ParamMap::findLongName( const std::string & long_name ) } /*-------------------------------------------------------------------*/ -/*! - - */ ParamEntity::Ptr ParamMap::findShortName( const std::string & short_name ) { - std::map< std::string, ParamEntity::Ptr >::iterator it = M_short_name_map.find( short_name ); + Map::iterator it = M_short_name_map.find( short_name ); if ( it != M_short_name_map.end() ) { @@ -496,9 +521,6 @@ ParamMap::findShortName( const std::string & short_name ) } /*-------------------------------------------------------------------*/ -/*! - - */ std::ostream & ParamMap::printHelp( std::ostream & os, const bool with_default ) const diff --git a/rcsc/param/param_map.h b/rcsc/param/param_map.h index 2141af8..8a8013e 100644 --- a/rcsc/param/param_map.h +++ b/rcsc/param/param_map.h @@ -32,12 +32,11 @@ #ifndef RCSC_PARAM_PARAM_MAP_H #define RCSC_PARAM_PARAM_MAP_H -#include - #include #include -#include +#include #include +#include #include #include @@ -132,37 +131,44 @@ struct NegateSwitch { class ParamEntity { public: + //! value pointer type + using ValuePtr = std::variant< int*, size_t*, double*, bool*, NegateBool, BoolSwitch, NegateSwitch, std::string* >; + //! ParamEntity smart pointer type - typedef std::shared_ptr< ParamEntity > Ptr; + using Ptr = std::shared_ptr< ParamEntity >; private: //! long parameter name std::string M_long_name; //! short parameter name std::string M_short_name; + // parameter value pointer holder as variant + ValuePtr M_value_ptr; //! parameter description std::string M_description; //! not used ParamEntity() = delete; -protected: +public: /*! \brief construct with all arguments \param long_name long parameter name \param short_name short parameter name + \param value_ptr pointer type to the paramter variable \param description description message about this parameter */ ParamEntity( const std::string & long_name, - const std::string & short_name, - const char * description = "" ) + const std::string & short_name, + ValuePtr value_ptr, + const char * description = "" ) : M_long_name( long_name ), M_short_name( short_name ), + M_value_ptr( value_ptr ), M_description( description ) { } -public: /*! \brief destructor as virtual method @@ -198,34 +204,22 @@ class ParamEntity { } /*! - \brief get the formatted name string for help messages - \return formatted name string - */ - std::string helpName() const; - - /*! - \brief (virtual) check if this parameter is switch type or not. + \brief check if this parameter is switch type or not. \return true if this parameter is switch type.. */ - virtual - bool isSwitch() const - { - return false; - } + bool isSwitch() const; /*! \brief pure virtual method. analyze value string. \return boolean status of analysis result */ - virtual - bool analyze( const std::string & value_str ) = 0; + bool analyze( const std::string & value_str ); /*! \brief print help name strings \param os reference to the stream \return reference to the stream */ - virtual std::ostream & printFormat( std::ostream & os ) const; /*! @@ -233,255 +227,19 @@ class ParamEntity { \param os reference to the stream \return reference to the stream */ - virtual - std::ostream & printValue( std::ostream & os ) const = 0; - -}; - -/*-------------------------------------------------------------------*/ -/*! - \class ParamGeneric - \brief generic parameter -*/ -template < typename ValueType > -class ParamGeneric - : public ParamEntity { -public: - typedef ValueType Type; //!< value type alias - -private: - //! pointer to parameter variable instance - Type * M_value_ptr; - -public: - - /*! - \brief constructor - \param long_name parameter's long name string - \param short_name parameter's short name string(ommitable) - \param value_ptr pointer to variable instance - \param description description message(ommitable) - */ - ParamGeneric( const std::string & long_name, - const std::string & short_name, - Type * value_ptr, - const char * description = "" ) - : ParamEntity( long_name, short_name, description ), - M_value_ptr( value_ptr ) - { - assert( value_ptr ); - } - - /*! - \brief analyze value string and substitute it to variable. - \param value_str string that contains value - \return boolean status of analysis result - */ - bool analyze( const std::string & value_str ) - { - try - { - *M_value_ptr = boost::lexical_cast< Type >( value_str ); - return true; - } - catch ( boost::bad_lexical_cast & e ) - { - std::cerr << e.what() << " [" << value_str << "]" - << std::endl; - return false; - } - } - -private: - - template < typename T > - std::ostream & printValueImpl( std::ostream & os, - const T & value ) const - { - os << value; - return os; - } - - std::ostream & printValueImpl( std::ostream & os, - const std::string & value ) const - { - os << '"' << value << '"'; - return os; - } - -public: - /*! - \brief print value to stream - \param os reference to the stream - \return reference to the stream - */ - std::ostream & printValue( std::ostream & os ) const - { - return printValueImpl( os, *M_value_ptr ); - } - -}; - -/*-------------------------------------------------------------------*/ -/*! - \class ParamGeneric< bool > - \brief specialized template class -*/ -template <> -class ParamGeneric< bool > - : public ParamEntity { -private: - const bool M_negate; - - //! pointer to parameter variable instance - bool * M_value_ptr; - -public: - - /*! - \brief constructor - \param long_name parameter's long name string - \param short_name parameter's short name string(ommitable) - \param value_ptr pointer to variable instance - \param description description message(ommitable) - */ - ParamGeneric( const std::string & long_name, - const std::string & short_name, - bool * value_ptr, - const char * description = "" ) - : ParamEntity( long_name, short_name, description ), - M_negate( false ), - M_value_ptr( value_ptr ) - { - assert( value_ptr ); - } - - /*! - \brief constructor - \param long_name parameter's long name string - \param short_name parameter's short name string(ommitable) - \param value negate bool object - \param description description message(ommitable) - */ - ParamGeneric( const std::string & long_name, - const std::string & short_name, - const NegateBool & value, - const char * description = "" ) - : ParamEntity( long_name, short_name, description ), - M_negate( true ), - M_value_ptr( value.ptr_ ) - { - assert( M_value_ptr ); - } - - /*! - \brief analyze value string and substitute it to variable. - \param value_str string that contains value - \return boolean status of analysis result - */ - bool analyze( const std::string & value_str ); - - /*! - \brief print value to stream - \param os reference to the stream - \return reference to the stream - */ std::ostream & printValue( std::ostream & os ) const; }; -/*-------------------------------------------------------------------*/ -/*! - \class ParamSwitch - \brief switch type parameter -*/ -class ParamSwitch - : public ParamEntity { -private: - const bool M_negate; - - //! pointer to parameter variable instance - bool * M_value_ptr; - -public: - - /*! - \brief constructor - \param long_name parameter's long name string - \param short_name parameter's short name string(ommitable) - \param value_ptr pointer to variable instance - \param description description message(ommitable) - */ - ParamSwitch( const std::string & long_name, - const std::string & short_name, - bool * value_ptr, - const char * description = "" ) - : ParamEntity( long_name, short_name, description ), - M_negate( false ), - M_value_ptr( value_ptr ) - { - assert( value_ptr ); - } - - - /*! - \brief constructor - \param long_name parameter's long name string - \param short_name parameter's short name string(ommitable) - \param value negate bool object - \param description description message(ommitable) - */ - ParamSwitch( const std::string & long_name, - const std::string & short_name, - const NegateSwitch & value, - const char * description = "" ) - : ParamEntity( long_name, short_name, description ), - M_negate( true ), - M_value_ptr( value.ptr_ ) - { - assert( M_value_ptr ); - } - - /*! - \brief (virtual) check if this parameter is switch type or not. - \return always true. - */ - virtual - bool isSwitch() const - { - return true; - } - - /*! - \brief analyze value string and substitute it to variable. - \param value_str string that contains value - \return boolean status of analysis result - */ - bool analyze( const std::string & value_str ); - - /*! - \brief print usage format. - \param os reference to the stream - \return reference to the stream - */ - std::ostream & printFormat( std::ostream & os ) const; - - /*! - \brief print value to stream - \param os reference to the stream - \return reference to the stream - */ - std::ostream & printValue( std::ostream & os ) const; - -}; - - /*-------------------------------------------------------------------*/ /*! \class ParamMap \brief parameter container */ class ParamMap { +public: + //! map type + using Map = std::unordered_map< std::string, ParamEntity::Ptr >; private: /*! @@ -512,71 +270,9 @@ class ParamMap { \param description parameter's description message(ommitable) \return reference to itself */ - template < typename ValueType > - Registrar & operator()( const std::string & long_name, - const std::string & short_name, - ValueType * value_ptr, - const char * description = "" ) - { - if ( ! checkName( long_name, short_name ) ) - { - M_param_map.M_valid = false; - return *this; - } - - if ( ! value_ptr ) - { - std::cerr << "***ERROR*** detected null pointer for the option " - << long_name << std::endl; - M_param_map.M_valid = false; - return *this; - } - - ParamEntity::Ptr ptr( new ParamGeneric< ValueType >( long_name, - short_name, - value_ptr, - description ) ); - M_param_map.add( ptr ); - return *this; - } - - /*! - \brief parameter registration operator for negate bool - \param long_name parameter's long name - \param short_name parameter's short name(ommitable) - \param value wrapper object - \param description parameter's description message(ommitable) - \return reference to itself - */ - Registrar & operator()( const std::string & long_name, - const std::string & short_name, - const NegateBool & value, - const char * description = "" ); - - /*! - \brief parameter registration operator for bool switch - \param long_name parameter's long name - \param short_name parameter's short name(ommitable) - \param value wrapper object - \param description parameter's description message(ommitable) - \return reference to itself - */ - Registrar & operator()( const std::string & long_name, - const std::string & short_name, - const BoolSwitch & value, - const char * description = "" ); - - /*! - \brief parameter registration operator for negate bool switch - \param long_name parameter's long name - \param short_name parameter's short name(ommitable) - \param value wrapper object - \param description parameter's description message(ommitable) - \return reference to itself - */ Registrar & operator()( const std::string & long_name, const std::string & short_name, - const NegateSwitch & value, + ParamEntity::ValuePtr value_ptr, const char * description = "" ); private: @@ -602,10 +298,10 @@ class ParamMap { std::vector< ParamEntity::Ptr > M_parameters; //! long name option map - std::map< std::string, ParamEntity::Ptr > M_long_name_map; + Map M_long_name_map; //! short name option map - std::map< std::string, ParamEntity::Ptr > M_short_name_map; + Map M_short_name_map; // no copyable @@ -670,7 +366,7 @@ class ParamMap { \brief get the long name parameter map \return const reference to the container instance */ - const std::map< std::string, ParamEntity::Ptr > & longNameMap() const + const Map & longNameMap() const { return M_long_name_map; } @@ -679,7 +375,7 @@ class ParamMap { \brief get the short name parameter map \return const reference to the container instance */ - const std::map< std::string, ParamEntity::Ptr > & shortNameMap() const + const Map & shortNameMap() const { return M_short_name_map; } diff --git a/rcsc/param/rcss_param_parser.cpp b/rcsc/param/rcss_param_parser.cpp index 3518586..7396eb4 100644 --- a/rcsc/param/rcss_param_parser.cpp +++ b/rcsc/param/rcss_param_parser.cpp @@ -45,7 +45,7 @@ namespace rcsc { /*-------------------------------------------------------------------*/ /*! -*/ + */ RCSSParamParser::RCSSParamParser( const char * msg ) { if ( ! init( msg ) ) @@ -57,7 +57,7 @@ RCSSParamParser::RCSSParamParser( const char * msg ) /*-------------------------------------------------------------------*/ /*! -*/ + */ bool RCSSParamParser::parse( ParamMap & param_map ) { @@ -106,22 +106,22 @@ RCSSParamParser::parse( ParamMap & param_map ) /*-------------------------------------------------------------------*/ /*! -*/ + */ std::string RCSSParamParser::cleanString( std::string str ) { if( str.empty() ) { - return str; + return str; } if ( *str.begin() == '\'' ) { - if( *str.rbegin() == '\'' ) + if( *str.rbegin() == '\'' ) { str = str.substr( 1, str.length() - 2 ); } - else + else { return str; } @@ -130,18 +130,18 @@ RCSSParamParser::cleanString( std::string str ) for ( std::string::size_type escape_pos = str.find( "\\'" ); escape_pos != std::string::npos; escape_pos = str.find( "\\'" ) ) - { + { // replace "\'" with "'" str.replace( escape_pos, 2, "'" ); - } + } } else if ( *str.begin() == '"' ) { - if ( *str.rbegin() == '"' ) + if ( *str.rbegin() == '"' ) { str = str.substr( 1, str.length() - 2 ); } - else + else { return str; } @@ -150,10 +150,10 @@ RCSSParamParser::cleanString( std::string str ) for ( std::string::size_type escape_pos = str.find( "\\\"" ); escape_pos != std::string::npos; escape_pos = str.find( "\\\"" ) ) - { + { // replace "\"" with """ str.replace( escape_pos, 2, "\"" ); - } + } } return str; @@ -163,7 +163,7 @@ RCSSParamParser::cleanString( std::string str ) /*-------------------------------------------------------------------*/ /*! -*/ + */ bool RCSSParamParser::init( const char * msg ) { diff --git a/rcsc/player/action_effector.cpp b/rcsc/player/action_effector.cpp index b38fc51..e6ee6cd 100644 --- a/rcsc/player/action_effector.cpp +++ b/rcsc/player/action_effector.cpp @@ -55,6 +55,8 @@ namespace rcsc { ActionEffector::ActionEffector( const PlayerAgent & agent ) : M_agent( agent ), M_command_body( nullptr ), + // M_command_left_leg( nullptr ), + // M_command_right_leg( nullptr ), M_command_turn_neck( nullptr ), M_command_change_view( nullptr ), M_command_change_focus( nullptr ), @@ -67,9 +69,11 @@ ActionEffector::ActionEffector( const PlayerAgent & agent ) M_kick_accel_error( 0.0, 0.0 ), M_turn_actual( 0.0 ), M_turn_error( 0.0 ), - M_dash_accel( 0.0, 0.0 ), - // M_dash_accel_error(0.0, 0.0), M_dash_power( 0.0 ), + M_left_dash_power( 0.0 ), + M_right_dash_power( 0.0 ), + M_dash_accel( 0.0, 0.0 ), + M_dash_rotation( 0.0 ), M_move_pos( 0.0, 0.0 ), M_catch_time( 0, 0 ), M_tackle_power( 0.0 ), @@ -161,21 +165,22 @@ ActionEffector::reset() M_done_turn_neck = false; M_say_message.erase(); - // it is not necesarry to reset these value, - // because value is selected by last command type specifier in updator function. - - //M_kick_accel.assign(0.0, 0.0); - //M_kick_accel_error.assign(0.0, 0.0); - //M_turn_actual = M_turn_error = 0.0; - //M_dash_accel.assign(0.0, 0.0); - //M_dash_accel_error.assign(0.0, 0.0); - //M_dash_power = 0.0; - //M_move_pos.assign(0.0, 0.0); - //M_catch_time - //M_tackle_power = 0.0; - //M_tackle_dir = 0.0; - //M_turnneck_moment = 0.0; - //M_pointto_pos.assign(0.0, 0.0); + M_kick_accel.assign( 0.0, 0.0 ); + M_kick_accel_error.assign( 0.0, 0.0 ); + M_turn_actual = M_turn_error = 0.0; + M_dash_accel.assign( 0.0, 0.0 ); + M_dash_rotation = 0.0; + M_dash_power = 0.0; + M_left_dash_power = 0.0; + M_right_dash_power = 0.0; + M_left_dash_power = 0.0; + M_right_dash_power = 0.0; + M_move_pos.assign( 0.0, 0.0 ); + M_catch_time.assign( 0, 0 ); + M_tackle_power = 0.0; + M_tackle_dir = 0.0; + M_turn_neck_moment = 0.0; + M_pointto_pos.assign( 0.0, 0.0 ); } /*-------------------------------------------------------------------*/ @@ -287,8 +292,10 @@ ActionEffector::checkCommandCount( const BodySensor & sense ) } M_last_body_command_type[0] = PlayerCommand::ILLEGAL; M_dash_accel.assign( 0.0, 0.0 ); - //M_dash_accel_error.assign( 0.0, 0.0 ); + M_dash_rotation = 0.0; M_dash_power = 0.0; + M_left_dash_power = 0.0; + M_right_dash_power = 0.0; M_command_counter[PlayerCommand::DASH] = sense.dashCount(); } @@ -689,7 +696,6 @@ ActionEffector::setKick( const double & power, M_kick_accel_error.x, M_kick_accel_error.y ); } - namespace { /*-------------------------------------------------------------------*/ /*! @@ -876,7 +882,10 @@ ActionEffector::setDash( const double & power, */ M_dash_power = command_power; - M_dash_dir = command_dir; + M_left_dash_power = command_power; + M_right_dash_power = command_power; + + M_dash_rotation = 0.0; M_dash_accel.setPolar( accel_mag, accel_angle ); #if 0 @@ -911,6 +920,158 @@ ActionEffector::setDash( const double & power, accel_mag, accel_angle.degree() ); } +/*-------------------------------------------------------------------*/ +namespace { + +/*-------------------------------------------------------------------*/ +double +check_and_normalize_dash_power( const WorldModel & wm, + double power ) + +{ + const ServerParam & param = ServerParam::i(); + + if ( power < param.minDashPower() - 0.001 + || param.maxDashPower() + 0.001 < power ) + { + dlog.addText( Logger::ACTION, + __FILE__" (setDash) exceeding the dash power range %.1f", power ); + std::cerr << wm.teamName() << ' ' << wm.self().unum() << ": " << wm.time() + << " exceeding the dash power range [left]: " << power + << std::endl; + power = param.normalizeDashPower( power ); + } + + return power; +} + +/*-------------------------------------------------------------------*/ +double +check_and_normalize_dash_dir( const WorldModel & wm, + double dir ) + +{ + const ServerParam & param = ServerParam::i(); + + if ( dir < param.minDashAngle() - 0.001 + || param.maxDashAngle() + 0.001 < dir ) + { + dlog.addText( Logger::ACTION, + __FILE__" (setDash) exceeding the dash angle range %.1f", dir ); + std::cerr << wm.teamName() << ' ' << wm.self().unum() << ": " << wm.time() + << " exceeding the dash angle range: " << dir + << std::endl; + dir = param.normalizeDashAngle( dir ); + } + + return param.discretizeDashAngle( dir ); +} + +/*-------------------------------------------------------------------*/ +void +check_stamina_for_two_legs_dash( const WorldModel & wm, + double * left_power, + double * right_power ) +{ + // required stamina + double left_stamina = ( *left_power < 0.0 ? *left_power * -1.0 : *left_power * 0.5 ); + double right_stamina = ( *right_power < 0.0 ? *right_power * -1.0 : *right_power * 0.5 ); + + double consumed_stamina = std::min( left_stamina + right_stamina, + wm.self().stamina() + wm.self().playerType().extraStamina() ); + + if ( consumed_stamina < 1.0e-5 ) + { + *left_power = 0.0; + *right_power = 0.0; + return; + } + + left_stamina = consumed_stamina * left_stamina / ( left_stamina + right_stamina ); + right_stamina = consumed_stamina * right_stamina / ( left_stamina + right_stamina ); + + *left_power = ( *left_power < 0.0 ? left_stamina * -1.0 : left_stamina * 2.0 ); + *right_power = ( *right_power < 0.0 ? right_stamina * -1.0 : right_stamina * 2.0 ); +} + +} + +/*-------------------------------------------------------------------*/ +void +ActionEffector::setDash( const double left_power, + const AngleDeg left_dir, + const double right_power, + const AngleDeg right_dir ) +{ + const WorldModel & wm = M_agent.world(); + + dlog.addText( Logger::ACTION, + __FILE__" (setDash) register dash for 2 legs. left=(%.1f %.1f) right=(%.1f %.1f)", + left_power, left_dir.degree(), right_power, right_dir.degree() ); + + // normalize command argument : power + double left_command_power = check_and_normalize_dash_power( wm, left_power ); + double right_command_power = check_and_normalize_dash_power( wm, right_power ); + + check_stamina_for_two_legs_dash( wm, &left_command_power, &right_command_power ); + + left_command_power = std::round( left_command_power * 1000.0 ) * 0.001; + right_command_power = std::round( right_command_power * 1000.0 ) * 0.001; + + // normalize command argument: direction + double left_command_dir = check_and_normalize_dash_dir( wm, left_dir.degree() ); + double right_command_dir = check_and_normalize_dash_dir( wm, right_dir.degree() ); + + // create command object + if ( M_command_body ) + { + delete M_command_body; + M_command_body = nullptr; + } + M_command_body = new PlayerDashCommand( left_command_power, left_command_dir, + right_command_power, right_command_dir ); + + // estimate command effect + double left_dir_rate = ServerParam::i().dashDirRate( left_command_dir ); + double right_dir_rate = ServerParam::i().dashDirRate( left_command_dir ); + + double left_accel_mag = std::fabs( left_command_power * left_dir_rate * wm.self().dashRate() ); + double right_accel_mag = std::fabs( right_command_power * right_dir_rate * wm.self().dashRate() ); + + AngleDeg left_accel_angle = wm.self().body() + left_command_dir; + AngleDeg right_accel_angle = wm.self().body() + right_command_dir; + + if ( left_power < 0.0 ) left_accel_angle += 180.0; + if ( right_power < 0.0 ) right_accel_angle += 180.0; + + const Vector2D left_accel = Vector2D::from_polar( left_accel_mag, left_accel_angle ); + const Vector2D right_accel = Vector2D::from_polar( right_accel_mag, right_accel_angle ); + + const Vector2D body_unit = Vector2D::from_polar( 1.0, wm.self().body() ); + const Vector2D vel_l = wm.self().vel() + left_accel; + const Vector2D vel_r = wm.self().vel() + right_accel; + + const double vel_l_body = body_unit.x * vel_l.x + body_unit.y * vel_l.y; + const double vel_r_body = body_unit.x * vel_r.x + body_unit.y * vel_r.y; + + const double omega = ( vel_l_body - vel_r_body ) / ( wm.self().playerType().playerSize() * 2.0 ); + const Vector2D new_vel = ( vel_r + vel_l ) * 0.5; + + M_dash_power = ( left_command_power < 0.0 ? -left_command_power : left_command_power*0.5 + + right_command_power < 0.0 ? -right_command_power : left_command_power*0.5 ); + M_left_dash_power = left_command_power; + M_right_dash_power = right_command_power; + + M_dash_rotation = AngleDeg::rad2deg( omega ); + M_dash_accel = new_vel - wm.self().vel(); + + const double actual_accel_mag = M_dash_accel.r(); + if ( actual_accel_mag > ServerParam::i().playerAccelMax() ) + { + M_dash_accel *= ServerParam::i().playerAccelMax() / actual_accel_mag; + } +} + /*-------------------------------------------------------------------*/ /*! @@ -1609,6 +1770,7 @@ AngleDeg ActionEffector::queuedNextSelfBody() const { AngleDeg next_angle = M_agent.world().self().body(); + if ( M_command_body && M_command_body->type() == PlayerCommand::TURN ) { @@ -1617,6 +1779,14 @@ ActionEffector::queuedNextSelfBody() const next_angle += moment; } + if ( M_command_body + && M_command_body->type() == PlayerCommand::TURN ) + { + double dash_rotation = 0.0; + getDashInfo( nullptr, &dash_rotation, nullptr, nullptr ); + next_angle += dash_rotation; + } + return next_angle; } @@ -1632,7 +1802,7 @@ ActionEffector::queuedNextSelfPos() const && M_command_body->type() == PlayerCommand::DASH ) { Vector2D accel( 0.0, 0.0 ); - getDashInfo( &accel, NULL ); + getDashInfo( &accel, nullptr, nullptr, nullptr ); vel += accel; double tmp = vel.r(); diff --git a/rcsc/player/action_effector.h b/rcsc/player/action_effector.h index c050670..75458ae 100644 --- a/rcsc/player/action_effector.h +++ b/rcsc/player/action_effector.h @@ -61,6 +61,11 @@ class ActionEffector { //! pointer of body action for dynamic allocation PlayerBodyCommand * M_command_body; + //! left leg command + // PlayerLegCommand * M_command_left_leg; + //! right leg command + // PlayerLegCommand * M_command_right_leg; + //! pointer of turn_neck for dynamic allocation PlayerTurnNeckCommand * M_command_turn_neck; //! pointer of change_view for dynamic allocation @@ -83,6 +88,8 @@ class ActionEffector { //! last body command type PlayerCommand::Type M_last_body_command_type[2]; + // PlayerCommand::Type M_last_left_leg_command_type[2]; + // PlayerCommand::Type M_last_right_leg_command_type[2]; //! checker of turn_neck. true if turn_neck was done at last bool M_done_turn_neck; @@ -98,10 +105,11 @@ class ActionEffector { double M_turn_error; //!< estimated turn moment error // dash effect + double M_dash_power; //!< command power: need to estimate the consumed stamina + double M_left_dash_power; //!< command power: need to estimate the consumed stamina + double M_right_dash_power; //!< command power: need to estimate the consumed stamina Vector2D M_dash_accel; //!< estimated last dash accel - //Vector2D M_dash_accel_error; - double M_dash_power; //!< last dash power to update stamina - double M_dash_dir; //!< last dash direction relative to body (or reverse body) + double M_dash_rotation; //!< rotation degree by differntial drive // move effect Vector2D M_move_pos; //!< last move coordinates @@ -265,6 +273,21 @@ class ActionEffector { void setDash( const double & power, const AngleDeg & rel_dir ); + /*! + \brief register dash command for each leg. + \param left_power dash power for left leg + \param left_dir dash direction for left leg + \param right_power dash power for right leg + \param right_dir dash direction for right leg + + power is normalized by server parameter + useless dash power is reduceed automatically. + */ + void setDash( const double left_power, + const AngleDeg left_dir, + const double right_power, + const AngleDeg right_dir ); + /*! \brief create turn command and its effect with turn parameter \param moment turn moment that player wants to perform @@ -448,18 +471,25 @@ class ActionEffector { ////////////////////////////////////////// /*! \brief get estimated dash action effect - \param accel variable pointer to store the estimated dash accel - \param power variable pointer to store the used dash power */ void getDashInfo( Vector2D * accel, - /*Vector2D * acc_err,*/ double * power ) const { if ( accel ) *accel = M_dash_accel; - //if ( acc_err ) *acc_err = M_dash_accel_error; if ( power ) *power = M_dash_power; } + void getDashInfo( Vector2D * accel, + double * rotation, + double * left_power, + double * right_power ) const + { + if ( accel ) *accel = M_dash_accel; + if ( rotation ) *rotation = M_dash_rotation; + if ( left_power ) *left_power = M_left_dash_power; + if ( right_power ) *right_power = M_right_dash_power; + } + ////////////////////////////////////////// /*! diff --git a/rcsc/player/intercept.h b/rcsc/player/intercept.h index 212d639..aba3f9f 100644 --- a/rcsc/player/intercept.h +++ b/rcsc/player/intercept.h @@ -60,8 +60,9 @@ class Intercept { */ enum ActionType { OMNI_DASH = 0, - TURN_FORWARD_DASH = 1, - TURN_BACK_DASH = 2, + BIPEDAL_DASH, + TURN_FORWARD_DASH, + TURN_BACK_DASH, UNKNOWN_TYPE = 100, }; @@ -78,8 +79,12 @@ class Intercept { double M_turn_angle; //!< angle difference between current body angle and dash angle int M_dash_step; //!< estimated dash step - double M_dash_power; //!< first dash power - double M_dash_dir; //!< first dash direction (relative to body) + double M_dash_power; //!< first dash power (for v18 or older) + double M_dash_dir; //!< first dash dir (for v18 or older) + double M_dash_power_left; //!< first dash power for left leg + double M_dash_dir_left; //!< first dash direction for left leg (relative to body) + double M_dash_power_right; //!< first dash power for right leg + double M_dash_dir_right; //!< first dash directionfor right leg (relative to body) Vector2D M_self_pos; //!< estimated final self position double M_ball_dist; //!< estimated final ball distance @@ -88,7 +93,7 @@ class Intercept { public: /*! - \brief create invalid info + \brief create invalid data */ Intercept() : M_index( -1 ), @@ -98,8 +103,12 @@ class Intercept { M_turn_step( 10000 ), M_turn_angle( 0.0 ), M_dash_step( 10000 ), - M_dash_power( 100000.0 ), + M_dash_power( 0.0 ), M_dash_dir( 0.0 ), + M_dash_power_left( 0.0 ), + M_dash_dir_left( 0.0 ), + M_dash_power_right( 0.0 ), + M_dash_dir_right( 0.0 ), M_self_pos( -10000.0, 0.0 ), M_ball_dist( 10000000.0 ), M_stamina( 0.0 ) @@ -127,6 +136,44 @@ class Intercept { M_dash_step( dash_step ), M_dash_power( dash_power ), M_dash_dir( dash_dir ), + M_dash_power_left( dash_power ), + M_dash_dir_left( dash_dir ), + M_dash_power_right( dash_power ), + M_dash_dir_right( dash_dir ), + M_self_pos( self_pos ), + M_ball_dist( ball_dist ), + M_stamina( stamina ) + { } + + + /*! + \brief construct with all variables + */ + Intercept( const StaminaType stamina_type, + const ActionType action_type, + const int turn_step, + const double turn_angle, + const int dash_step, + const double dash_power_left, + const double dash_dir_left, + const double dash_power_right, + const double dash_dir_right, + const Vector2D & self_pos, + const double ball_dist, + const double stamina ) + : M_index( -1 ), + M_value( MIN_VALUE ), + M_stamina_type( stamina_type ), + M_action_type( action_type ), + M_turn_step( turn_step ), + M_turn_angle( turn_angle ), + M_dash_step( dash_step ), + M_dash_power( 0.0 ), + M_dash_dir( 0.0 ), + M_dash_power_left( dash_power_left ), + M_dash_dir_left( dash_dir_left ), + M_dash_power_right( dash_power_right ), + M_dash_dir_right( dash_dir_right ), M_self_pos( self_pos ), M_ball_dist( ball_dist ), M_stamina( stamina ) @@ -144,6 +191,18 @@ class Intercept { M_value = value; } + void setBipedalDash( const double power_left, + const double dir_left, + const double power_right, + const double dir_right ) + { + M_action_type = BIPEDAL_DASH; + M_dash_power_left = power_left; + M_dash_dir_left = dir_left; + M_dash_power_right = power_right; + M_dash_dir_right = dir_right; + } + /*! \brief check if this object is legal one or not. \return checked result. @@ -244,6 +303,42 @@ class Intercept { return M_dash_dir; } + /*! + \brief get dash power for the first dash + \return dash power value + */ + double dashPowerLeft() const + { + return M_dash_power_left; + } + + /*! + \brief ger the dash direction for the first dash + \return dash direction value (relative to body) + */ + double dashDirLeft() const + { + return M_dash_dir_left; + } + + /*! + \brief get dash power for the first dash + \return dash power value + */ + double dashPowerRight() const + { + return M_dash_power_right; + } + + /*! + \brief ger the dash direction for the first dash + \return dash direction value (relative to body) + */ + double dashDirRight() const + { + return M_dash_dir_right; + } + /*! \brief get the estimated final self position \return final self position diff --git a/rcsc/player/intercept_simulator_self_v17.cpp b/rcsc/player/intercept_simulator_self_v17.cpp index 752597e..8f4d969 100644 --- a/rcsc/player/intercept_simulator_self_v17.cpp +++ b/rcsc/player/intercept_simulator_self_v17.cpp @@ -181,7 +181,8 @@ struct InterceptEqual { && lhs.actionType() == rhs.actionType() && lhs.turnStep() == rhs.turnStep() && lhs.dashStep() == rhs.dashStep() - && lhs.dashDir() == rhs.dashDir(); + && lhs.dashDirLeft() == rhs.dashDirLeft() + && lhs.dashDirRight() == rhs.dashDirRight(); } }; @@ -230,7 +231,7 @@ InterceptSimulatorSelfV17::simulate( const WorldModel & wm, { simulateTurnDash( wm, max_step, true, self_cache ); // back dash } - simulateOmniDash( wm, max_step, self_cache ); // omni dash + simulateOmniDash( wm, std::min( 5, max_step ), self_cache ); // omni dash if ( self_cache.empty() ) { @@ -324,7 +325,7 @@ InterceptSimulatorSelfV17::simulateNoDash( const WorldModel & wm, const double ball_noise = ballVel().r() * ServerParam::i().ballRand() * BALL_NOISE_RATE; const double ball_next_dist = self_next.dist( ball_next ); - if ( ball_next_dist > control_area - CONTROL_BUF - ball_noise ) + if ( ball_next_dist > std::max( 0.3, control_area - CONTROL_BUF - ball_noise ) ) { #ifdef DEBUG_PRINT_ONE_STEP dlog.addText( Logger::INTERCEPT, @@ -1002,7 +1003,7 @@ simulate_turn_step( const WorldModel & wm, int n_turn = 0; - if ( control_area - CONTROL_BUF - ball_noise < inertia_dist ) + if ( std::max( control_area * 0.7, control_area - CONTROL_BUF - ball_noise ) < inertia_dist ) { const ServerParam & SP = ServerParam::i(); const PlayerType & ptype = wm.self().playerType(); @@ -1155,6 +1156,7 @@ InterceptSimulatorSelfV17::getTurnDash( const WorldModel & wm, const double control_buf = ( goalie_mode ? 0.0 : CONTROL_BUF + ball_noise ); + const double kickable_thr2 = std::pow( std::max( ptype.kickableArea() * 0.7, ptype.kickableArea() - control_buf ), 2 ); AngleDeg dash_angle = ( back_dash ? wm.self().body() + 180.0 @@ -1214,13 +1216,16 @@ InterceptSimulatorSelfV17::getTurnDash( const WorldModel & wm, const Vector2D ball_rel = rotate_matrix.transform( ball_pos - wm.self().pos() ); const int max_dash_step = step - n_turn; + double first_dash_power = 0.0; for ( int i = 0; i < max_dash_step; ++i ) { - double required_vel_x = ( ball_rel.x - self_pos.x ) + const Vector2D self_final_pos = inertia_n_step_point( self_pos, self_vel, max_dash_step - i, ptype.playerDecay() ); + double required_vel_x = ( ball_rel.x - self_final_pos.x ) * ( 1.0 - ptype.playerDecay() ) / ( 1.0 - std::pow( ptype.playerDecay(), max_dash_step - i ) ); - double required_accel_x = required_vel_x - self_vel.x; + //double required_accel_x = required_vel_x - self_vel.x; + double required_accel_x = required_vel_x; double dash_power = required_accel_x / ( ptype.dashPowerRate() * stamina_model.effort() ); dash_power = bound( SP.minDashPower(), dash_power, SP.maxDashPower() ); dash_power = stamina_model.getSafetyDashPower( ptype, dash_power, 1.0 ); @@ -1247,7 +1252,7 @@ InterceptSimulatorSelfV17::getTurnDash( const WorldModel & wm, if ( self_pos.absX() > ball_rel.absX() - 1.0e-5 || self_pos.r2() > ball_rel.r2() - || self_pos.dist2( ball_rel ) < std::pow( ptype.kickableArea() - control_buf, 2 ) ) + || self_pos.dist2( ball_rel ) < kickable_thr2 ) { ok = true; } @@ -1338,15 +1343,14 @@ InterceptSimulatorSelfV17::simulateOmniDashAny( const WorldModel & wm, ? 0.0 : CONTROL_BUF + ball_noise ); - const Vector2D self_inertia = wm.self().inertiaPoint( ball_step ); - - const Vector2D ball_rel = rotate_matrix.transform( ball_pos - self_inertia ); + //const Vector2D ball_rel = rotate_matrix.transform( ball_pos - self_final_pos ); + const Vector2D ball_rel = rotate_matrix.transform( ball_pos - wm.self().inertiaPoint( ball_step ) ); if ( ball_rel.absY() - control_area > max_side_speed * ball_step ) { continue; } - //const AngleDeg accel_angle = ( ball_pos - self_inertia ).th(); + //const AngleDeg accel_angle = ( ball_pos - self_final_pos ).th(); double first_dash_power = 0.0; double first_dash_dir = 0.0; @@ -1357,10 +1361,12 @@ InterceptSimulatorSelfV17::simulateOmniDashAny( const WorldModel & wm, for ( int step = 1; step <= ball_step; ++step ) { - const Vector2D required_vel = ( ball_pos - self_pos ) + const Vector2D self_final_pos = inertia_n_step_point( self_pos, self_vel, ball_step - step + 1, ptype.playerDecay() ); + const Vector2D required_vel = ( ball_pos - self_final_pos ) * ( ( 1.0 - ptype.playerDecay() ) / ( 1.0 - std::pow( ptype.playerDecay(), ball_step - step + 1 ) ) ); - const Vector2D required_accel = required_vel - self_vel; + //const Vector2D required_accel = required_vel - self_vel; + const Vector2D required_accel = required_vel; const double dash_dir = SP.discretizeDashAngle( ( required_accel.th() - wm.self().body() ).degree() ); const double dash_rate = SP.dashDirRate( dash_dir ) * ptype.dashPowerRate() * stamina_model.effort(); @@ -1381,8 +1387,8 @@ InterceptSimulatorSelfV17::simulateOmniDashAny( const WorldModel & wm, bool ok = false; - if ( self_pos.dist2( ball_pos ) < std::pow( ptype.kickableArea() - control_buf, 2 ) - || self_inertia.dist2( self_pos ) > self_inertia.dist2( ball_pos ) ) + if ( self_pos.dist2( ball_pos ) < std::pow( std::max( ptype.kickableArea() * 0.7, ptype.kickableArea() - control_buf ), 2 ) + || self_final_pos.dist2( self_pos ) > self_final_pos.dist2( ball_pos ) ) { ok = true; } @@ -1559,10 +1565,12 @@ InterceptSimulatorSelfV17::simulateOmniDashOld( const WorldModel & wm, #endif for ( int step = 1; step <= reach_step; ++step ) { - const Vector2D required_vel = ( ball_pos - self_pos ) + const Vector2D self_final_pos = inertia_n_step_point( self_pos, self_vel, reach_step - step + 1, ptype.playerDecay() ); + const Vector2D required_vel = ( ball_pos - self_final_pos ) * ( ( 1.0 - ptype.playerDecay() ) / ( 1.0 - std::pow( ptype.playerDecay(), reach_step - step + 1 ) ) ); - const Vector2D required_accel = required_vel - self_vel; + //const Vector2D required_accel = required_vel - self_vel; + const Vector2D required_accel = required_vel; double min_dist2 = 1000000.0; Vector2D best_self_pos = self_pos; @@ -1626,7 +1634,7 @@ InterceptSimulatorSelfV17::simulateOmniDashOld( const WorldModel & wm, if ( ! found ) { - if ( self_pos.dist2( ball_pos ) < std::pow( control_area - control_buf, 2 ) + if ( self_pos.dist2( ball_pos ) < std::pow( std::max( control_area * 0.7, control_area - control_buf ), 2 ) || ( wm.self().pos().dist2( self_pos ) > wm.self().pos().dist2( ball_pos ) && Line2D( wm.self().pos(), self_pos ).dist2( ball_pos ) < std::pow( control_area, 2 ) ) ) { diff --git a/rcsc/player/intercept_table.cpp b/rcsc/player/intercept_table.cpp index 6d4f796..889624b 100644 --- a/rcsc/player/intercept_table.cpp +++ b/rcsc/player/intercept_table.cpp @@ -36,6 +36,7 @@ #include "intercept_table.h" #include "intercept_simulator_self_v17.h" +#include "intercept_simulator_self.h" #include "intercept_simulator_player.h" #include "world_model.h" @@ -62,7 +63,8 @@ const int MAX_STEP = 50; */ InterceptTable::InterceptTable() - : M_update_time( 0, 0 ) + : M_update_time( 0, 0 ), + M_self_simulator( new InterceptSimulatorSelfV17 ) { M_self_results.reserve( ( MAX_STEP + 1 ) * 2 ); @@ -94,6 +96,13 @@ InterceptTable::clear() M_player_map.clear(); } +/*-------------------------------------------------------------------*/ +void +InterceptTable::setSimulator( std::shared_ptr< InterceptSimulatorSelf > self ) +{ + M_self_simulator = self; +} + /*-------------------------------------------------------------------*/ /*! @@ -339,8 +348,11 @@ InterceptTable::predictSelf( const WorldModel & wm ) constexpr int max_step = 50; - std::shared_ptr< InterceptSimulatorSelf > sim( new InterceptSimulatorSelfV17() ); - sim->simulate( wm, max_step, M_self_results ); + if ( ! M_self_simulator ) + { + M_self_simulator = std::make_shared< InterceptSimulatorSelfV17 >(); + } + M_self_simulator->simulate( wm, max_step, M_self_results ); if ( M_self_results.empty() ) { diff --git a/rcsc/player/intercept_table.h b/rcsc/player/intercept_table.h index bdeb171..45eb523 100644 --- a/rcsc/player/intercept_table.h +++ b/rcsc/player/intercept_table.h @@ -37,10 +37,12 @@ #include #include #include +#include namespace rcsc { class AbstractPlayerObject; +class InterceptSimulatorSelf; class PlayerObject; class WorldModel; @@ -56,6 +58,9 @@ class InterceptTable { //! last updated time GameTime M_update_time; + //! self intercept simulator + std::shared_ptr< InterceptSimulatorSelf > M_self_simulator; + //! predicted min reach step for self without stamina exhaust int M_self_step; //! predicted min reach step for self with stamina exhaust @@ -103,6 +108,12 @@ class InterceptTable { ~InterceptTable() { } + /*! + \brief set intercept simuator. + \param self pointer to the self intercept simulator + */ + void setSimulator( std::shared_ptr< InterceptSimulatorSelf > self ); + /*! \brief update table information \param wm const reference to the world model diff --git a/rcsc/player/penalty_kick_state.h b/rcsc/player/penalty_kick_state.h index a523af7..f17563c 100644 --- a/rcsc/player/penalty_kick_state.h +++ b/rcsc/player/penalty_kick_state.h @@ -29,8 +29,8 @@ ///////////////////////////////////////////////////////////////////// -#ifndef PENALTY_KICK_STATE_H -#define PENALTY_KICK_STATE_H +#ifndef RCSC_PLAYER_PENALTY_KICK_STATE_H +#define RCSC_PLAYER_PENALTY_KICK_STATE_H #include #include @@ -80,6 +80,10 @@ class PenaltyKickState { */ PenaltyKickState(); + // no copyable + PenaltyKickState( const PenaltyKickState & ) = delete; + const PenaltyKickState& operator=( const PenaltyKickState & ) = delete; + /*! \brief get time when playmode is changed \return game time diff --git a/rcsc/player/player_agent.cpp b/rcsc/player/player_agent.cpp index 4510f42..a7842bd 100644 --- a/rcsc/player/player_agent.cpp +++ b/rcsc/player/player_agent.cpp @@ -1333,6 +1333,11 @@ PlayerAgent::Impl::sendSettingCommands() ostr << "(synch_see)"; } + if ( agent_.config().gaussianSee() ) + { + ostr << "(gaussian_see)"; + } + // turn off opponent all audio message if ( ! agent_.config().hearOpponentAudio() ) @@ -2159,14 +2164,14 @@ PlayerAgent::Impl::analyzeInit( const char * msg ) // // see_state_.setProtocolVersion( agent_.config().version() ); - if ( agent_.config().version() >= 18.0 ) - { - std::cerr << agent_.world().teamName() << ' ' - << agent_.world().self().unum() << ": " - << agent_.world().time() - << " (v18+) force synch see mode." - << std::endl; - } + // if ( agent_.config().version() >= 18.0 ) + // { + // std::cerr << agent_.world().teamName() << ' ' + // << agent_.world().self().unum() << ": " + // << agent_.world().time() + // << " (v18+) force synch see mode." + // << std::endl; + // } // // call init message event handler @@ -2248,6 +2253,19 @@ PlayerAgent::Impl::analyzeOK( const char * msg ) agent_.world().self().viewQuality() ); return; } + + if ( ! std::strncmp( msg, + "(ok gaussian_see)", + std::strlen( "(ok gaussian_see)" ) ) ) + { + std::cerr << agent_.world().teamName() << ' ' + << agent_.world().self().unum() << ": " + << agent_.world().time() + << " set gaussian see mode." + << std::endl; + return; + } + if ( ! std::strncmp( msg, "(ok compression ", std::strlen( "(ok compression " ) ) ) @@ -2820,6 +2838,34 @@ PlayerAgent::doDash( const double & power, return true; } + +/*-------------------------------------------------------------------*/ +/*! + + */ +bool +PlayerAgent::doDash( const double left_power, + const AngleDeg & left_dir, + const double right_power, + const AngleDeg & right_dir ) +{ + if ( world().self().isFrozen() ) + { + dlog.addText( Logger::ACTION, + __FILE__": (PlayerAgent::doDash) [false ]tackle expire period %d", + world().self().tackleExpires() ); + std::cerr << world().teamName() << ' ' + << world().self().unum() << ": " + << world().time() + << " (PlayerAgent::doDash) [false] Tackle expire period" << std::endl; + return false; + } + + M_effector.setDash( left_power, left_dir, right_power, right_dir ); + return true; +} + + /*-------------------------------------------------------------------*/ /*! diff --git a/rcsc/player/player_agent.h b/rcsc/player/player_agent.h index 38080df..0eb0a82 100644 --- a/rcsc/player/player_agent.h +++ b/rcsc/player/player_agent.h @@ -221,6 +221,19 @@ class PlayerAgent bool doDash( const double & power, const AngleDeg & rel_dir = 0.0 ); + /*! + \brief register dash command for each leg + \param left_power command argument: dash power + \param left_dir command argument: dash direction relative to body (or reverse body) angle + \param right_power command argument: dash power + \param right_dir command argument: dash direction relative to body (or reverse body) angle + \return true if successfully registered. + */ + bool doDash( const double left_power, + const AngleDeg & left_dir, + const double right_power, + const AngleDeg & right_dir ); + /*! \brief register turn command \param moment command argument: turn moment diff --git a/rcsc/player/player_command.cpp b/rcsc/player/player_command.cpp index 21d96ce..2c1f1a6 100644 --- a/rcsc/player/player_command.cpp +++ b/rcsc/player/player_command.cpp @@ -134,14 +134,38 @@ PlayerMoveCommand::toCommandString( std::ostream & to ) const std::ostream & PlayerDashCommand::toCommandString( std::ostream & to ) const { - to << "(dash " << M_power; - if ( M_dir != 0.0 ) + if ( ! M_two_legs ) { - to << ' ' << M_dir; + to << "(dash " << M_power; + if ( M_dir != 0.0 ) + { + to << ' ' << M_dir; + } + to << ')'; + } + else + { + to << "(dash" + << " (l " << M_left_power << ' ' << M_left_dir << ')' + << " (r " << M_right_power << ' ' << M_right_dir << ')' + << ')'; } - return to << ')'; + + return to; } + +/*-------------------------------------------------------------------*/ +// std::ostream & +// PlayerLegDashCommand::toCommandString( std::ostream & to ) const +// { +// to << "(dash (" +// << ( side() == LEFT ? 'l' : side() == RIGHT ? 'r' : '?' ) +// << ' ' << M_power << ' ' << M_dir << "))"; + +// return to; +// } + /*-------------------------------------------------------------------*/ /*! diff --git a/rcsc/player/player_command.h b/rcsc/player/player_command.h index de320f4..6bf33aa 100644 --- a/rcsc/player/player_command.h +++ b/rcsc/player/player_command.h @@ -326,6 +326,81 @@ class PlayerBodyCommand }; +#if 0 +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// + +/*! + \class PlayerLegCommand + \brief abstract leg command +*/ +class PlayerLegCommand + : public PlayerCommand { +public: + enum Side { + LEFT, + RIGHT, + }; + + +private: + + + Side M_side; //!< left or right flag + + // not used + PlayerLegCommand() = delete; + +protected: + + /*! + \brief the default constructor is protected. + */ + explicit + PlayerLegCommand( Side side ) + : M_side( side ) + { } + +public: + + virtual + ~PlayerLegCommand() + { } + + /*! + \brief get command type (pure virtual) + \return command type Id + */ + virtual + Type type() const = 0; + + /*! + \brief put command string to ostream (pure virtual) + \param to reference to the output stream + \return reference to the output stream + */ + virtual + std::ostream & toCommandString( std::ostream & to ) const = 0; + + /*! + \brief get command name (pure virtual) + \return command name string + */ + virtual + std::string name() const = 0; + + /*! + \brief get the side flag + \return return the side flag valeu + */ + Side side() const + { + return M_side; + } +}; +#endif + ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// @@ -408,19 +483,51 @@ class PlayerDashCommand private: double M_power; //!< dash power double M_dir; //!< dash direction + + bool M_two_legs; + double M_left_power; //!< dash power for the left leg + double M_left_dir; //!< dash dir for the left leg + double M_right_power; //!< dash power for the right leg + double M_right_dir; //!< dash dir for the right leg public: /*! - \brief construct with dash power + \brief construct dash command \param power dash power \param dir dash direction */ explicit - PlayerDashCommand( const double & power, - const double & dir = 0.0 ) - : M_power( power ) - , M_dir( dir ) + PlayerDashCommand( const double power, + const double dir = 0.0 ) + : M_power( power ), + M_dir( dir ), + M_two_legs( false ), + M_left_power( 0.0 ), + M_left_dir( 0.0 ), + M_right_power( 0.0 ), + M_right_dir( 0.0 ) + { } + + /*! + \brief construct dash command for each leg + \param left_power dash power for the left leg + \param left_dir dash direction for the left leg + \param right_power dash power for the right leg + \param right_dir dash direction for the right leg + */ + PlayerDashCommand( const double left_power, + const double left_dir, + const double right_power, + const double right_dir ) + : M_power( 0.0 ), + M_dir( 0.0 ), + M_two_legs( true ), + M_left_power( left_power ), + M_left_dir( left_dir ), + M_right_power( right_power ), + M_right_dir( right_dir ) { } + /*! \brief get command type \return command type Id @@ -465,6 +572,83 @@ class PlayerDashCommand } }; +#if 0 +////////////////////////////////////////////////////////////////////// +/*! + \class PlayerDashCommand + \brief player's dash command + +
+  Format:
+  <- (dash  )
+  <- (dash (  ))
+  
+*/ +class PlayerLegDashCommand + : public PlayerLegCommand { +private: + double M_power; //!< dash power + double M_dir; //!< dash direction +public: + /*! + \brief construct with parameters + \param side leg side + \param power dash power + \param dir dash direction + */ + PlayerLegDashCommand( const Side side, + const double power, + const double dir ) + : PlayerLegCommand( side ), + M_power( power ), + M_dir( dir ) + { } + + /*! + \brief get command type + \return command type Id + */ + Type type() const + { + return DASH; + } + + /*! + \brief put command string to ostream + \param to reference to the output stream + \return reference to the output stream + */ + std::ostream & toCommandString( std::ostream & to ) const; + + /*! + \brief get command name + \return command name string + */ + std::string name() const + { + return std::string( "dash" ); + } + + /*! + \brief get dash command parameter + \return dash power + */ + double dashPower() const + { + return M_power; + } + + /*! + \brief get dash command parameter + \return dash direction + */ + double dashDir() const + { + return M_dir; + } +}; +#endif + ////////////////////////////////////////////////////////////////////// /*! \class PlayerTurnCommand diff --git a/rcsc/player/player_config.cpp b/rcsc/player/player_config.cpp index d0c8f2b..0c54777 100644 --- a/rcsc/player/player_config.cpp +++ b/rcsc/player/player_config.cpp @@ -102,6 +102,7 @@ PlayerConfig::setDefaultParam() M_debug_fullstate = false; M_synch_see = false; + M_gaussian_see = false; // accuracy threshold M_self_pos_count_thr = 20; @@ -215,6 +216,7 @@ PlayerConfig::createParamMap() ( "use_fullstate", "", &M_use_fullstate ) ( "debug_fullstate", "", &M_debug_fullstate ) ( "synch_see", "", &M_synch_see ) + ( "gaussian_see", "", &M_gaussian_see ) ( "self_pos_count_thr", "", &M_self_pos_count_thr ) ( "self_vel_count_thr", "", &M_self_vel_count_thr ) diff --git a/rcsc/player/player_config.h b/rcsc/player/player_config.h index d571da3..f7aea08 100644 --- a/rcsc/player/player_config.h +++ b/rcsc/player/player_config.h @@ -83,6 +83,7 @@ class PlayerConfig { bool M_debug_fullstate; //!< if true, the virtual fullstate worldmodel is used. bool M_synch_see; //!< if true, synchronous see mode is used. + bool M_gaussian_see; //!< gaussian observation mode or not // confidence value @@ -327,6 +328,12 @@ class PlayerConfig { */ bool synchSee() const { return M_synch_see; } + /*! + \brief get the gaussian_see mode flag + \return gaussian_see mode flag + */ + bool gaussianSee() const { return M_gaussian_see; } + // confidence value /*! diff --git a/rcsc/player/self_object.cpp b/rcsc/player/self_object.cpp index a9eff43..23e7429 100644 --- a/rcsc/player/self_object.cpp +++ b/rcsc/player/self_object.cpp @@ -211,7 +211,9 @@ SelfObject::update( const ActionEffector & act, M_pos_prev = M_pos; Vector2D accel( 0.0, 0.0 ); - double dash_power = 0.0; + double dash_rotation = 0.0; + double left_dash_power = 0.0; + double right_dash_power = 0.0; double turn_moment = 0.0, turn_err = 0.0; double neck_moment = 0.0; @@ -219,7 +221,8 @@ SelfObject::update( const ActionEffector & act, // base command switch ( act.lastBodyCommandType() ) { case PlayerCommand::DASH: - act.getDashInfo( &accel, &dash_power ); + //act.getDashInfo( &accel, &dash_power ); + act.getDashInfo( &accel, &dash_rotation, &left_dash_power, &right_dash_power ); break; case PlayerCommand::TURN: act.getTurnInfo( &turn_moment, &turn_err ); @@ -274,9 +277,13 @@ SelfObject::update( const ActionEffector & act, } // stamina - M_stamina.simulateDash( playerType(), dash_power ); + //M_stamina.simulateDash( playerType(), dash_power ); + M_stamina.simulateDash( playerType(), left_dash_power, right_dash_power ); #ifdef DEBUG_PRINT + dlog.addText( Logger::WORLD, + __FILE__" (update) estimated turn=%.1f dash_rot=%.1f", + turn_moment, dash_rotation ); dlog.addText( Logger::WORLD, __FILE__" (update) estimated stamina=%.1f effort=%f recovery=%f capacity=%.1f", M_stamina.stamina(), @@ -288,6 +295,7 @@ SelfObject::update( const ActionEffector & act, ///////////////////////////////////////////////////////////////// // turn M_body += turn_moment; + M_body += dash_rotation; ///////////////////////////////////////////////////////////////// // face @@ -308,6 +316,12 @@ SelfObject::update( const ActionEffector & act, M_pos += M_vel; } +#ifdef DEBUG_PRINT + dlog.addText( Logger::WORLD, + __FILE__" (update) estimated body=%.1f neck=%.1f face=%.1f", + M_body.degree(), M_neck.degree(), M_face.degree() ); +#endif + // rcssserver/src/object.C // PVector MPObject::noise() // { diff --git a/rcsc/player/world_model.cpp b/rcsc/player/world_model.cpp index 369998d..3d68596 100644 --- a/rcsc/player/world_model.cpp +++ b/rcsc/player/world_model.cpp @@ -36,6 +36,7 @@ #include "world_model.h" #include "action_effector.h" +#include "intercept_simulator_self.h" #include "localization_default.h" #include "body_sensor.h" #include "visual_sensor.h" @@ -266,30 +267,6 @@ get_their_goalie_loop( const WorldModel & wm ) return nullptr; } - -struct PlayerUpdater { - void operator()( PlayerObject & player ) - { - player.update(); - } -}; - -struct PlayerValidChecker { - bool operator()( const PlayerObject & player ) const - { - return ( ! player.posValid() ); - } -}; - -struct PlayerUnumSorter { - - bool operator()( const PlayerObject & lhs, - const PlayerObject & rhs ) const - { - return lhs.unum() < rhs.unum(); - } -}; - struct PlayerCountSorter { bool operator()( const PlayerObject & lhs, @@ -321,23 +298,6 @@ struct PlayerPtrAccuracySorter { } }; -struct PlayerPtrSelfDistSorter { - bool operator()( const PlayerObject * lhs, - const PlayerObject * rhs ) const - { - return lhs->distFromSelf() < rhs->distFromSelf(); - } -}; - - -struct PlayerPtrBallDistSorter { - bool operator()( const PlayerObject * lhs, - const PlayerObject * rhs ) const - { - return lhs->distFromBall() < rhs->distFromBall(); - } -}; - } @@ -358,7 +318,6 @@ WorldModel::WorldModel() M_localize(), M_intercept_table(), M_audio_memory( new AudioMemory() ), - M_penalty_kick_state( new PenaltyKickState() ), M_our_side( NEUTRAL ), M_time( -1, 0 ), M_sense_body_time( -1, 0 ), @@ -397,8 +356,6 @@ WorldModel::WorldModel() M_last_kicker_unum( Unum_Unknown ), M_view_area_cont( MAX_RECORD, ViewArea() ) { - assert( M_penalty_kick_state ); - for ( int i = 0; i < 11; ++i ) { M_our_recovery[i] = 1.0; @@ -425,11 +382,7 @@ WorldModel::WorldModel() */ WorldModel::~WorldModel() { - if ( M_penalty_kick_state ) - { - delete M_penalty_kick_state; - M_penalty_kick_state = nullptr; - } + } /*-------------------------------------------------------------------*/ @@ -504,17 +457,6 @@ WorldModel::setValid( bool is_valid ) M_valid = is_valid; } -/*-------------------------------------------------------------------*/ -/*! - - */ -const -PenaltyKickState * -WorldModel::penaltyKickState() const -{ - return M_penalty_kick_state; -} - /*-------------------------------------------------------------------*/ /*! @@ -535,6 +477,13 @@ WorldModel::setLocalization( std::shared_ptr< Localization > localization ) M_localize = localization; } +/*-------------------------------------------------------------------*/ +void +WorldModel::setInterceptSimulator( std::shared_ptr< InterceptSimulatorSelf > self ) +{ + M_intercept_table.setSimulator( self ); +} + /*-------------------------------------------------------------------*/ /*! @@ -719,7 +668,7 @@ void WorldModel::setPenaltyKickTakerOrder( const std::vector< int > & unum_set ) { if ( gameMode().isPenaltyKickMode() - && ( M_penalty_kick_state->ourTakerCounter() > 0 + && ( M_penalty_kick_state.ourTakerCounter() > 0 && gameMode().type() != GameMode::PenaltySetup_ ) ) { std::cerr << teamName() << " : " << self().unum() @@ -729,7 +678,7 @@ WorldModel::setPenaltyKickTakerOrder( const std::vector< int > & unum_set ) return; } - M_penalty_kick_state->setKickTakerOrder( unum_set ); + M_penalty_kick_state.setKickTakerOrder( unum_set ); } /*-------------------------------------------------------------------*/ @@ -875,16 +824,16 @@ WorldModel::update( const ActionEffector & act, } // update teammates - std::for_each( M_teammates.begin(), M_teammates.end(), PlayerUpdater() ); - M_teammates.remove_if( PlayerValidChecker() ); + std::for_each( M_teammates.begin(), M_teammates.end(), []( PlayerObject & p ) { p.update(); } ); + M_teammates.remove_if( []( const PlayerObject & p ) { return ( ! p.posValid() ); } ); // update opponents - std::for_each( M_opponents.begin(), M_opponents.end(), PlayerUpdater() ); - M_opponents.remove_if( PlayerValidChecker() ); + std::for_each( M_opponents.begin(), M_opponents.end(), []( PlayerObject & p ) { p.update(); } ); + M_opponents.remove_if( []( const PlayerObject & p ) { return ( ! p.posValid() ); } ); // update unknown players - std::for_each( M_unknown_players.begin(), M_unknown_players.end(), PlayerUpdater() ); - M_unknown_players.remove_if( PlayerValidChecker() ); + std::for_each( M_unknown_players.begin(), M_unknown_players.end(), []( PlayerObject & p ) { p.update(); } ); + M_unknown_players.remove_if( []( const PlayerObject & p ) { return ( ! p.posValid() ); } ); // update view area @@ -1388,7 +1337,7 @@ WorldModel::updateAfterFullstate( const FullstateSensor & fullstate, } // update opponents - for ( const FullstateSensor::PlayerT fp : fullstate.theirPlayers() ) + for ( const FullstateSensor::PlayerT & fp : fullstate.theirPlayers() ) { if ( fp.unum_ < 1 || 11 < fp.unum_ ) { @@ -1523,7 +1472,7 @@ WorldModel::updateGameMode( const GameMode & game_mode, // if ( pk_mode ) { - M_penalty_kick_state->update( game_mode, ourSide(), current ); + M_penalty_kick_state.update( game_mode, ourSide(), current ); } } @@ -2198,7 +2147,7 @@ WorldModel::localizeSelf( const VisualSensor & see, const ActionEffector & act, const GameTime & current ) { - const bool reverse_side = is_reverse_side( *this, *M_penalty_kick_state ); + const bool reverse_side = is_reverse_side( *this, M_penalty_kick_state ); double angle_face = -360.0; double angle_face_error = 0.0; @@ -2416,6 +2365,7 @@ WorldModel::localizeBall( const VisualSensor & see, && ! self().isKicking() && M_ball.seenPosCount() <= 6 && M_ball.seenPosCount() >= 2 // ball is not seen at least 2 or more cycles + && ball().heardVelCount() > ball().seenPosCount() && self().lastMove( 0 ).isValid() // no collision in this cycle && self().lastMove( 1 ).isValid() ) // no collision in previous cycle { @@ -3096,8 +3046,8 @@ WorldModel::localizePlayers( const VisualSensor & see ) // check invalid player // if exist, that player is removed from instance list - M_teammates.remove_if( PlayerValidChecker() ); - M_opponents.remove_if( PlayerValidChecker() ); + M_teammates.remove_if( []( const PlayerObject & p ) { return ( ! p.posValid() ); } ); + M_opponents.remove_if( []( const PlayerObject & p ) { return ( ! p.posValid() ); } ); ////////////////////////////////////////////////////////////////// // it is not necessary to check the all unknown list @@ -3884,11 +3834,27 @@ WorldModel::updatePlayerStateCache() // // sort by distance from self or ball // - std::sort( M_teammates_from_self.begin(), M_teammates_from_self.end(), PlayerPtrSelfDistSorter() ); - std::sort( M_opponents_from_self.begin(), M_opponents_from_self.end(), PlayerPtrSelfDistSorter() ); - - std::sort( M_teammates_from_ball.begin(), M_teammates_from_ball.end(), PlayerPtrBallDistSorter() ); - std::sort( M_opponents_from_ball.begin(), M_opponents_from_ball.end(), PlayerPtrBallDistSorter() ); + std::sort( M_teammates_from_self.begin(), M_teammates_from_self.end(), + []( const PlayerObject * lhs, const PlayerObject * rhs ) + { + return lhs->distFromSelf() < rhs->distFromSelf(); + } ); + std::sort( M_opponents_from_self.begin(), M_opponents_from_self.end(), + []( const PlayerObject * lhs, const PlayerObject * rhs ) + { + return lhs->distFromSelf() < rhs->distFromSelf(); + } ); + + std::sort( M_teammates_from_ball.begin(), M_teammates_from_ball.end(), + []( const PlayerObject * lhs, const PlayerObject * rhs ) + { + return lhs->distFromBall() < rhs->distFromBall(); + } ); + std::sort( M_opponents_from_ball.begin(), M_opponents_from_ball.end(), + []( const PlayerObject * lhs, const PlayerObject * rhs ) + { + return lhs->distFromBall() < rhs->distFromBall(); + } ); estimateUnknownPlayerUnum(); estimateGoalie(); @@ -3942,7 +3908,7 @@ WorldModel::updatePlayerStateCache() dlog.addText( Logger::WORLD, " opponentsFromBall %zd", M_opponents_from_ball.size() ); - M_teammates.sort( PlayerUnumSorter() ); + M_teammates.sort( []( const PlayerObject & lhs, const PlayerObject & rhs ) { return lhs.unum() < rhs.unum(); } ); for ( const PlayerObject & p : M_teammates ) { dlog.addText( Logger::WORLD, @@ -3951,7 +3917,7 @@ WorldModel::updatePlayerStateCache() ( p.goalie() ? "goalie" : "" ) ); } - M_opponents.sort( PlayerUnumSorter() ); + M_opponents.sort( []( const PlayerObject & lhs, const PlayerObject & rhs ) { return lhs.unum() < rhs.unum(); } ); for ( const PlayerObject & p : M_opponents ) { dlog.addText( Logger::WORLD, @@ -3960,7 +3926,6 @@ WorldModel::updatePlayerStateCache() ( p.goalie() ? "goalie" : "" ) ); } - //M_unknown_players.sort( PlayerCountSorter() ); for ( const PlayerObject & p : M_unknown_players ) { dlog.addText( Logger::WORLD, diff --git a/rcsc/player/world_model.h b/rcsc/player/world_model.h index 59fe6a3..e0c52c0 100644 --- a/rcsc/player/world_model.h +++ b/rcsc/player/world_model.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -54,8 +55,8 @@ class AudioMemory; class ActionEffector; class BodySensor; class FullstateSensor; +class InterceptSimualtorSelf; class Localization; -class PenaltyKickState; class PlayerPredicate; class PlayerType; class VisualSensor; @@ -82,8 +83,8 @@ class WorldModel { std::shared_ptr< Localization > M_localize; //!< localization module InterceptTable M_intercept_table; //!< interception info table - std::shared_ptr< AudioMemory > M_audio_memory; //!< heard deqinfo memory - PenaltyKickState * M_penalty_kick_state; //!< penalty kick mode status + std::shared_ptr< AudioMemory > M_audio_memory; //!< heard message holder + PenaltyKickState M_penalty_kick_state; //!< penalty kick mode status ////////////////////////////////////////////////// std::string M_our_team_name; //!< our teamname @@ -266,7 +267,10 @@ class WorldModel { \brief get penalty kick state \return const pointer to the penalty kick state instance */ - const PenaltyKickState * penaltyKickState() const; + const PenaltyKickState & penaltyKickState() const + { + return M_penalty_kick_state; + } /*! \brief get audio memory @@ -290,6 +294,12 @@ class WorldModel { */ void setLocalization( std::shared_ptr< Localization > localization ); + /*! + \brief set intercept simuator. + \param self pointer to the self intercept simulator + */ + void setInterceptSimulator( std::shared_ptr< InterceptSimulatorSelf > self ); + /*! \brief set server param. this method have to be called only once just after server_param message received. */ diff --git a/rcsc/rcg/CMakeLists.txt b/rcsc/rcg/CMakeLists.txt index 8c30f0f..f638370 100644 --- a/rcsc/rcg/CMakeLists.txt +++ b/rcsc/rcg/CMakeLists.txt @@ -1,19 +1,23 @@ add_library(rcsc_rcg OBJECT - handler.cpp - parser.cpp - parser_v1.cpp - parser_v2.cpp - parser_v3.cpp - parser_v4.cpp - serializer.cpp - serializer_v1.cpp - serializer_v2.cpp - serializer_v3.cpp - serializer_v4.cpp - serializer_v5.cpp - serializer_v6.cpp - util.cpp + simdjson/simdjson.cpp + handler.cpp + parser.cpp + parser_v1.cpp + parser_v2.cpp + parser_v3.cpp + parser_v4.cpp + parser_simdjson.cpp + serializer.cpp + serializer_v1.cpp + serializer_v2.cpp + serializer_v3.cpp + serializer_v4.cpp + serializer_v5.cpp + serializer_v6.cpp + serializer_json.cpp + types.cpp + util.cpp ) target_include_directories(rcsc_rcg @@ -31,6 +35,7 @@ install(FILES parser_v2.h parser_v3.h parser_v4.h + parser_simdjson.h serializer.h serializer_v1.h serializer_v2.h @@ -38,6 +43,7 @@ install(FILES serializer_v4.h serializer_v5.h serializer_v6.h + serializer_json.h types.h util.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rcsc/rcg diff --git a/rcsc/rcg/Makefile.am b/rcsc/rcg/Makefile.am index 8a45d8f..819c63a 100644 --- a/rcsc/rcg/Makefile.am +++ b/rcsc/rcg/Makefile.am @@ -1,15 +1,19 @@ ## Process this file with automake to produce Makefile.in +AUTOMAKE_OPTIONS = subdir-objects + noinst_LTLIBRARIES = librcsc_rcg.la #lib_LTLIBRARIES = librcsc_rcg.la librcsc_rcg_la_SOURCES = \ + simdjson/simdjson.cpp \ handler.cpp \ parser.cpp \ parser_v1.cpp \ parser_v2.cpp \ parser_v3.cpp \ parser_v4.cpp \ + parser_simdjson.cpp \ serializer.cpp \ serializer_v1.cpp \ serializer_v2.cpp \ @@ -17,7 +21,9 @@ librcsc_rcg_la_SOURCES = \ serializer_v4.cpp \ serializer_v5.cpp \ serializer_v6.cpp \ - util.cpp + serializer_json.cpp \ + util.cpp \ + types.cpp librcsc_rcgincludedir = $(includedir)/rcsc/rcg @@ -29,6 +35,7 @@ librcsc_rcginclude_HEADERS = \ parser_v2.h \ parser_v3.h \ parser_v4.h \ + parser_simdjson.h \ serializer.h \ serializer_v1.h \ serializer_v2.h \ @@ -36,9 +43,13 @@ librcsc_rcginclude_HEADERS = \ serializer_v4.h \ serializer_v5.h \ serializer_v6.h \ + serializer_json.h \ types.h \ util.h +noinst_HEADERS = \ + simdjson/simdjson.h + librcsc_rcg_la_LDFLAGS = -version-info 6:0:0 #libXXXX_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) # 1. Start with version information of `0:0:0' for each libtool library. @@ -65,6 +76,9 @@ AM_CFLAGS = -Wall -W AM_CXXFLAGS = -Wall -W AM_LDFLAGS = +EXTRA_DIST = \ + simdjson/LICENSE + CLEANFILES = *~ #EXTRA_DIST = diff --git a/rcsc/rcg/handler.cpp b/rcsc/rcg/handler.cpp index 0239972..759a434 100644 --- a/rcsc/rcg/handler.cpp +++ b/rcsc/rcg/handler.cpp @@ -37,9 +37,8 @@ #include "util.h" - -#ifdef HAVE_NETINET_IN_H -#include +#ifdef HAVE_ARPA_INET_H +#include #endif #ifdef HAVE_WINDOWS_H #include @@ -85,7 +84,7 @@ Handler::handleDispInfo( const dispinfo_t & dinfo ) break; case MSG_MODE: return handleMsg( M_read_time, - dinfo.body.msg.board, + ntohs( dinfo.body.msg.board ), std::string( dinfo.body.msg.message ) ); break; case DRAW_MODE: @@ -116,7 +115,7 @@ Handler::handleDispInfo2( const dispinfo_t2 & dinfo2 ) break; case MSG_MODE: return handleMsg( M_read_time, - dinfo2.body.msg.board, + ntohs( dinfo2.body.msg.board ), std::string( dinfo2.body.msg.message ) ); break; case PT_MODE: @@ -225,11 +224,7 @@ bool Handler::handleTeamInfo( const team_t & team_left, const team_t & team_right ) { - TeamT l, r; - convert( team_left, l ); - convert( team_right, r ); - - return handleTeam( M_read_time, l, r ); + return handleTeam( M_read_time, TeamT( team_left ), TeamT( team_right ) ); } /*-------------------------------------------------------------------*/ @@ -239,7 +234,7 @@ Handler::handleTeamInfo( const team_t & team_left, bool Handler::handlePlayerType( const player_type_t & type ) { - return handlePlayerType( to_string( type ) ); + return handlePlayerType( PlayerTypeT( type ) ); } /*-------------------------------------------------------------------*/ @@ -249,7 +244,7 @@ Handler::handlePlayerType( const player_type_t & type ) bool Handler::handleServerParam( const server_params_t & param ) { - return handleServerParam( to_string( param ) ); + return handleServerParam( ServerParamT( param ) ); } /*-------------------------------------------------------------------*/ @@ -259,7 +254,15 @@ Handler::handleServerParam( const server_params_t & param ) bool Handler::handlePlayerParam( const player_params_t & param ) { - return handlePlayerParam( to_string( param ) ); + return handlePlayerParam( PlayerParamT( param ) ); +} + +/*-------------------------------------------------------------------*/ +bool +Handler::handlePlayMode( const int time, + const std::string & playmode ) +{ + return handlePlayMode( time, to_playmode_enum( playmode ) ); } } // end namespace diff --git a/rcsc/rcg/handler.h b/rcsc/rcg/handler.h index c8ced99..d8a343b 100644 --- a/rcsc/rcg/handler.h +++ b/rcsc/rcg/handler.h @@ -35,6 +35,7 @@ #include #include +#include namespace rcsc { namespace rcg { @@ -48,9 +49,14 @@ namespace rcg { class Handler { private: - //! RCG version number(1-3, default:0) + //! RCG version number int M_log_version; + //! server version (available only in json) + std::string M_server_version; + //! timestamp (available only in json) + std::string M_timestamp; + //! last handled game time int M_read_time; @@ -96,6 +102,47 @@ class Handler { return M_log_version; } + /*! + \brief update the server version information + \param version string + \return result status + */ + virtual + bool handleServerVersion( const std::string & version ) + { + M_server_version = version; + return true; + } + + /*! + \brief get the server version string + \return server version string + */ + const std::string & serverVersion() const + { + return M_server_version; + } + + /*! + \brief update the time stamp information + \param timestamp string + \return result status + */ + bool handleTimestamp( const std::string & timestamp ) + { + M_timestamp = timestamp; + return true; + } + + /*! + \brief get the time stamp string + \return time stamp string + */ + const std::string & timestamp() const + { + return M_timestamp; + } + // // old version handers // all data are automatically converted to the intermediate format. @@ -170,21 +217,21 @@ class Handler { /*! \brief handle player_type_t - \param type handled data + \param type binary data \return result status */ bool handlePlayerType( const player_type_t & type ); /*! \brief handle server_params_t - \param param handled data + \param param binary data \return result status */ bool handleServerParam( const server_params_t & param ); /*! \brief handle player_params_t - \param param handled data + \param param binary data \return result status */ bool handlePlayerParam( const player_params_t & param ); @@ -256,27 +303,50 @@ class Handler { /*! \brief handle server_param message - \param msg raw message string + \param param parameter holder \return result status */ virtual - bool handleServerParam( const std::string & msg ) = 0; + bool handleServerParam( const ServerParamT & param ) = 0; /*! \brief handle player_param message - \param msg raw message string + \param param parameter holder \return result status */ virtual - bool handlePlayerParam( const std::string & msg ) = 0; + bool handlePlayerParam( const PlayerParamT & param ) = 0; /*! \brief handle player_type message + \param param parameter holder + \return result status + */ + virtual + bool handlePlayerType( const PlayerTypeT & param ) = 0; + + /*! + \brief handle team_graphic message \param msg raw message string \return result status */ virtual - bool handlePlayerType( const std::string & msg ) = 0; + bool handleTeamGraphic( const char side, + const int x, + const int y, + const std::vector< std::string > & xpm_data ) = 0; + + // + // + // + + /*! + \brief wrapper of handlePlayMode(int,PlayMode) + \param playmode playmode name + \return result status + */ + bool handlePlayMode( const int time, + const std::string & playmode ); }; diff --git a/rcsc/rcg/nlohmann/json.hpp b/rcsc/rcg/nlohmann/json.hpp new file mode 100644 index 0000000..8b72ea6 --- /dev/null +++ b/rcsc/rcg/nlohmann/json.hpp @@ -0,0 +1,24765 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +/****************************************************************************\ + * Note on documentation: The source files contain links to the online * + * documentation of the public API at https://json.nlohmann.me. This URL * + * contains the most recent documentation and should also be applicable to * + * previous versions; documentation for deprecated functions is not * + * removed, but marked deprecated. See "Generate documentation" section in * + * file docs/README.md. * +\****************************************************************************/ + +#ifndef INCLUDE_NLOHMANN_JSON_HPP_ +#define INCLUDE_NLOHMANN_JSON_HPP_ + +#include // all_of, find, for_each +#include // nullptr_t, ptrdiff_t, size_t +#include // hash, less +#include // initializer_list +#ifndef JSON_NO_IO + #include // istream, ostream +#endif // JSON_NO_IO +#include // random_access_iterator_tag +#include // unique_ptr +#include // string, stoi, to_string +#include // declval, forward, move, pair, swap +#include // vector + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// This file contains all macro definitions affecting or depending on the ABI + +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + +#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum) + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION + #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +#endif + +// Construct the namespace ABI tags component +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ + NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) + +#define NLOHMANN_JSON_ABI_TAGS \ + NLOHMANN_JSON_ABI_TAGS_CONCAT( \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) + +// Construct the namespace version component +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ + _v ## major ## _ ## minor ## _ ## patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) + +#if NLOHMANN_JSON_NAMESPACE_NO_VERSION +#define NLOHMANN_JSON_NAMESPACE_VERSION +#else +#define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ + NLOHMANN_JSON_VERSION_MINOR, \ + NLOHMANN_JSON_VERSION_PATCH) +#endif + +// Combine namespace components +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ + NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) + +#ifndef NLOHMANN_JSON_NAMESPACE +#define NLOHMANN_JSON_NAMESPACE \ + nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) \ + { +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_END +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann +#endif + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // transform +#include // array +#include // forward_list +#include // inserter, front_inserter, end +#include // map +#include // string +#include // tuple, make_tuple +#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible +#include // unordered_map +#include // pair, declval +#include // valarray + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // nullptr_t +#include // exception +#if JSON_DIAGNOSTICS + #include // accumulate +#endif +#include // runtime_error +#include // to_string +#include // vector + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // array +#include // size_t +#include // uint8_t +#include // string + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // declval, pair +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +// https://en.cppreference.com/w/cpp/experimental/is_detected +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template class Op, class... Args> +using is_detected = typename detector::value_t; + +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + + +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson +// SPDX-License-Identifier: MIT + +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + */ + +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION +#endif +#define JSON_HEDLEY_VERSION 15 + +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX +#endif +#define JSON_HEDLEY_STRINGIFY_EX(x) #x + +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY +#endif +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) + +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX +#endif +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT +#endif +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) + +#if defined(JSON_HEDLEY_CONCAT3_EX) + #undef JSON_HEDLEY_CONCAT3_EX +#endif +#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c + +#if defined(JSON_HEDLEY_CONCAT3) + #undef JSON_HEDLEY_CONCAT3 +#endif +#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) + +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE +#endif +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION +#endif +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(JSON_HEDLEY_MSVC_VERSION) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #undef JSON_HEDLEY_INTEL_CL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) + #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION +#endif +#if \ + defined(__TI_COMPILER_VERSION__) && \ + ( \ + defined(__TMS470__) || defined(__TI_ARM__) || \ + defined(__MSP430__) || \ + defined(__TMS320C2000__) \ + ) +#if (__TI_COMPILER_VERSION__ >= 16000000) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif +#endif + +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #undef JSON_HEDLEY_TI_CL2000_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) + #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #undef JSON_HEDLEY_TI_CL430_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) + #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #undef JSON_HEDLEY_TI_ARMCL_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) + #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) + #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #undef JSON_HEDLEY_TI_CL6X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) + #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #undef JSON_HEDLEY_TI_CL7X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) + #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #undef JSON_HEDLEY_TI_CLPRU_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) + #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #undef JSON_HEDLEY_MCST_LCC_VERSION +#endif +#if defined(__LCC__) && defined(__LCC_MINOR__) + #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) + #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION +#endif +#if \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_CRAY_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ + !defined(__COMPCERT__) && \ + !defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE +#endif +#if \ + defined(__has_attribute) && \ + ( \ + (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ + ) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if \ + defined(__has_cpp_attribute) && \ + defined(__cplusplus) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS +#endif +#if !defined(__cplusplus) || !defined(__has_cpp_attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#elif \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define JSON_HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + +/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") +# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") +# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# endif +#endif +#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x +#endif + +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ + ((T) (expr)) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) +# endif +#else +# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif + +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED +#endif +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define JSON_HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) +#elif defined(_Check_return_) /* SAL */ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ +#else + #define JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) +#endif + +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define JSON_HEDLEY_SENTINEL(position) +#endif + +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN +#endif +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define JSON_HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define JSON_HEDLEY_NO_RETURN +#endif + +#if defined(JSON_HEDLEY_NO_ESCAPE) + #undef JSON_HEDLEY_NO_ESCAPE +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) + #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) +#else + #define JSON_HEDLEY_NO_ESCAPE +#endif + +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE +#endif +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN +#endif +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #if defined(__cplusplus) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif defined(JSON_HEDLEY_ASSUME) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif +#if !defined(JSON_HEDLEY_ASSUME) + #if defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) + #else + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) + #endif +#endif +#if defined(JSON_HEDLEY_UNREACHABLE) + #if \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) + #else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() + #endif +#else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) +#endif +#if !defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif + +JSON_HEDLEY_DIAGNOSTIC_PUSH +#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") + #pragma clang diagnostic ignored "-Wpedantic" +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(JSON_HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define JSON_HEDLEY_NON_NULL(...) +#endif +JSON_HEDLEY_DIAGNOSTIC_POP + +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) + #endif +#endif +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR +#endif + +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT +#endif +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY +#endif +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY +#endif +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE +#endif +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) +#elif \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) +#else + #define JSON_HEDLEY_MALLOC +#endif + +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) +# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ + ) +# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else +# define JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_CONST __attribute__((__const__)) +#elif \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_CONST _Pragma("no_side_effect") +#else + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT restrict +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict +#else + #define JSON_HEDLEY_RESTRICT +#endif + +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define JSON_HEDLEY_INLINE inline +#elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_INLINE __inline +#else + #define JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) +# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ + ) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else +# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define JSON_HEDLEY_NEVER_INLINE +#endif + +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE +#endif +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC +#endif +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC __declspec(dllexport) +# define JSON_HEDLEY_IMPORT __declspec(dllimport) +#else +# if \ + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + ( \ + defined(__TI_EABI__) && \ + ( \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ + ) \ + ) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) +# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) +# else +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC +# endif +# define JSON_HEDLEY_IMPORT extern +#endif + +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) +#else + #define JSON_HEDLEY_NO_THROW +#endif + +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) +#elif defined(__fallthrough) /* SAL */ + #define JSON_HEDLEY_FALL_THROUGH __fallthrough +#else + #define JSON_HEDLEY_FALL_THROUGH +#endif + +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define JSON_HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) +#else + #define JSON_HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT +#endif +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#endif +/* JSON_HEDLEY_IS_CONSTEXPR_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #undef JSON_HEDLEY_IS_CONSTEXPR_ +#endif +#if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + ( \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ + defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ + defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ + defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ + defined(__clang__) +# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) +#else + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS +#endif +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS +#endif +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" +#else + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL +#endif + +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) +#else +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(JSON_HEDLEY_NULL) + #undef JSON_HEDLEY_NULL +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) + #elif defined(NULL) + #define JSON_HEDLEY_NULL NULL + #else + #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) + #endif +#elif defined(NULL) + #define JSON_HEDLEY_NULL NULL +#else + #define JSON_HEDLEY_NULL ((void*) 0) +#endif + +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE +#endif +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), #expr, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), msg, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) +# endif +#else +# define JSON_HEDLEY_REQUIRE(expr) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) +#endif + +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#else + #define JSON_HEDLEY_FLAGS +#endif + +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST +#endif +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) +#endif + +#if defined(JSON_HEDLEY_EMPTY_BASES) + #undef JSON_HEDLEY_EMPTY_BASES +#endif +#if \ + (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) +#else + #define JSON_HEDLEY_EMPTY_BASES +#endif + +/* Remaining macros are deprecated. */ + +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#endif +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) + +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE +#endif +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) + +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#endif +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) + +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING +#endif +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ + + +// This file contains all internal macro definitions (except those affecting ABI) +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// #include + + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// C++ language standard detection +// if the user manually specified the used c++ version this is skipped +#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) + #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 + #endif + // the cpp 11 flag is always specified because it is the minimal required version + #define JSON_HAS_CPP_11 +#endif + +#ifdef __has_include + #if __has_include() + #include + #endif +#endif + +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1914 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + #endif +#endif + +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_THREE_WAY_COMPARISON + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ + && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #else + #define JSON_HAS_THREE_WAY_COMPARISON 0 + #endif +#endif + +#ifndef JSON_HAS_RANGES + // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error + #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 + #define JSON_HAS_RANGES 0 + #elif defined(__cpp_lib_ranges) + #define JSON_HAS_RANGES 1 + #else + #define JSON_HAS_RANGES 0 + #endif +#endif + +#ifndef JSON_HAS_STATIC_RTTI + #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 + #define JSON_HAS_STATIC_RTTI 1 + #else + #define JSON_HAS_STATIC_RTTI 0 + #endif +#endif + +#ifdef JSON_HAS_CPP_17 + #define JSON_INLINE_VARIABLE inline +#else + #define JSON_INLINE_VARIABLE +#endif + +#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) + #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define JSON_NO_UNIQUE_ADDRESS +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" +#endif + +// allow disabling exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #include + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +// allow overriding assert +#if !defined(JSON_ASSERT) + #include // assert + #define JSON_ASSERT(x) assert(x) +#endif + +// allow to access some private functions (needed by the test suite) +#if defined(JSON_TESTS_PRIVATE) + #define JSON_PRIVATE_UNLESS_TESTED public +#else + #define JSON_PRIVATE_UNLESS_TESTED private +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [&j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer, \ + class BinaryType, \ + class CustomBaseClass> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + +// Macros to simplify conversion from/to types + +#define NLOHMANN_JSON_EXPAND( x ) x +#define NLOHMANN_JSON_GET_MACRO(_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, NAME,...) NAME +#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) +#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) +#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) +#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) +#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) +#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) +#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) +#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) +#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) +#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) +#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) +#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) +#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) +#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) +#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) +#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) +#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) +#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) +#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) +#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) +#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) +#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) +#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) +#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) +#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) +#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) +#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) +#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) +#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) +#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) +#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) +#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) +#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) +#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) +#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) +#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) +#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) +#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) +#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) +#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) +#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) +#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) + +#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; +#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); +#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +// inspired from https://stackoverflow.com/a/26745591 +// allows to call any std function as if (e.g. with begin): +// using std::begin; begin(x); +// +// it allows using the detected idiom to retrieve the return type +// of such an expression +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 { \ + struct std_name##_tag \ + { \ + }; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail:: \ + is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + { \ + } + +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif + +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif + +#ifndef JSON_USE_GLOBAL_UDLS + #define JSON_USE_GLOBAL_UDLS 1 +#endif + +#if JSON_HAS_THREE_WAY_COMPARISON + #include // partial_ordering +#endif + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/////////////////////////// +// JSON type enumeration // +/////////////////////////// + +/*! +@brief the JSON type enumeration + +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. + +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. + +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type + +@since version 1.0.0 +*/ +enum class value_t : std::uint8_t +{ + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + binary, ///< binary array (ordered collection of bytes) + discarded ///< discarded by the parser callback function +}; + +/*! +@brief comparison operator for JSON types + +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string < binary +- furthermore, each type is not smaller than itself +- discarded values are not comparable +- binary is represented as a b"" string in python and directly comparable to a + string; however, making a binary array directly comparable with a string would + be surprising behavior in a JSON file. + +@since version 1.0.0 +*/ +#if JSON_HAS_THREE_WAY_COMPARISON + inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* +#else + inline bool operator<(const value_t lhs, const value_t rhs) noexcept +#endif +{ + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, + 6 /* binary */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); +#if JSON_HAS_THREE_WAY_COMPARISON + if (l_index < order.size() && r_index < order.size()) + { + return order[l_index] <=> order[r_index]; // *NOPAD* + } + return std::partial_ordering::unordered; +#else + return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; +#endif +} + +// GCC selects the built-in operator< over an operator rewritten from +// a user-defined spaceship operator +// Clang, MSVC, and ICC select the rewritten candidate +// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) +#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) +inline bool operator<(const value_t lhs, const value_t rhs) noexcept +{ + return std::is_lt(lhs <=> rhs); // *NOPAD* +} +#endif + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/*! +@brief replace all occurrences of a substring by another string + +@param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t +@param[in] f the substring to replace with @a t +@param[in] t the string to replace @a f + +@pre The search string @a f must not be empty. **This precondition is +enforced with an assertion.** + +@since version 2.0.0 +*/ +template +inline void replace_substring(StringType& s, const StringType& f, + const StringType& t) +{ + JSON_ASSERT(!f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != StringType::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} +} + +/*! + * @brief string escaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to escape + * @return escaped string + * + * Note the order of escaping "~" to "~0" and "/" to "~1" is important. + */ +template +inline StringType escape(StringType s) +{ + replace_substring(s, StringType{"~"}, StringType{"~0"}); + replace_substring(s, StringType{"/"}, StringType{"~1"}); + return s; +} + +/*! + * @brief string unescaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to unescape + * @return unescaped string + * + * Note the order of escaping "~1" to "/" and "~0" to "~" is important. + */ +template +static void unescape(StringType& s) +{ + replace_substring(s, StringType{"~1"}, StringType{"/"}); + replace_substring(s, StringType{"~0"}, StringType{"~"}); +} + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // size_t + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const + { + return chars_read_total; + } +}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-FileCopyrightText: 2018 The Abseil Authors +// SPDX-License-Identifier: MIT + + + +#include // array +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type +#include // index_sequence, make_index_sequence, index_sequence_for + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template +using uncvref_t = typename std::remove_cv::type>::type; + +#ifdef JSON_HAS_CPP_14 + +// the following utilities are natively available in C++14 +using std::enable_if_t; +using std::index_sequence; +using std::make_index_sequence; +using std::index_sequence_for; + +#else + +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h +// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. + +//// START OF CODE FROM GOOGLE ABSEIL + +// integer_sequence +// +// Class template representing a compile-time integer sequence. An instantiation +// of `integer_sequence` has a sequence of integers encoded in its +// type through its template arguments (which is a common need when +// working with C++11 variadic templates). `absl::integer_sequence` is designed +// to be a drop-in replacement for C++14's `std::integer_sequence`. +// +// Example: +// +// template< class T, T... Ints > +// void user_function(integer_sequence); +// +// int main() +// { +// // user_function's `T` will be deduced to `int` and `Ints...` +// // will be deduced to `0, 1, 2, 3, 4`. +// user_function(make_integer_sequence()); +// } +template +struct integer_sequence +{ + using value_type = T; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +// index_sequence +// +// A helper template for an `integer_sequence` of `size_t`, +// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `std::index_sequence`. +template +using index_sequence = integer_sequence; + +namespace utility_internal +{ + +template +struct Extend; + +// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. +template +struct Extend, SeqSize, 0> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; +}; + +template +struct Extend, SeqSize, 1> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; +}; + +// Recursion helper for 'make_integer_sequence'. +// 'Gen::type' is an alias for 'integer_sequence'. +template +struct Gen +{ + using type = + typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; +}; + +template +struct Gen +{ + using type = integer_sequence; +}; + +} // namespace utility_internal + +// Compile-time sequences of integers + +// make_integer_sequence +// +// This template alias is equivalent to +// `integer_sequence`, and is designed to be a drop-in +// replacement for C++14's `std::make_integer_sequence`. +template +using make_integer_sequence = typename utility_internal::Gen::type; + +// make_index_sequence +// +// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, +// and is designed to be a drop-in replacement for C++14's +// `std::make_index_sequence`. +template +using make_index_sequence = make_integer_sequence; + +// index_sequence_for +// +// Converts a typename pack into an index sequence of the same length, and +// is designed to be a drop-in replacement for C++14's +// `std::index_sequence_for()` +template +using index_sequence_for = make_index_sequence; + +//// END OF CODE FROM GOOGLE ABSEIL + +#endif + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + +// taken from ranges-v3 +template +struct static_const +{ + static JSON_INLINE_VARIABLE constexpr T value{}; +}; + +#ifndef JSON_HAS_CPP_17 + template + constexpr T static_const::value; +#endif + +template +inline constexpr std::array make_array(Args&& ... args) +{ + return std::array {{static_cast(std::forward(args))...}}; +} + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // numeric_limits +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval +#include // tuple +#include // char_traits + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // random_access_iterator_tag + +// #include + +// #include + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template +struct iterator_types {}; + +template +struct iterator_types < + It, + void_t> +{ + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; +}; + +// This is required as some compilers implement std::iterator_traits in a way that +// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. +template +struct iterator_traits +{ +}; + +template +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types +{ +}; + +template +struct iterator_traits::value>> +{ + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; +}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); + +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); + +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.3 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann +// SPDX-License-Identifier: MIT + +#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ + #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + + #include // int64_t, uint64_t + #include // map + #include // allocator + #include // string + #include // vector + + // #include + + + /*! + @brief namespace for Niels Lohmann + @see https://github.com/nlohmann + @since version 1.0.0 + */ + NLOHMANN_JSON_NAMESPACE_BEGIN + + /*! + @brief default JSONSerializer template argument + + This serializer ignores the template arguments and uses ADL + ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) + for serialization. + */ + template + struct adl_serializer; + + /// a class to store JSON values + /// @sa https://json.nlohmann.me/api/basic_json/ + template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector, // cppcheck-suppress syntaxError + class CustomBaseClass = void> + class basic_json; + + /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document + /// @sa https://json.nlohmann.me/api/json_pointer/ + template + class json_pointer; + + /*! + @brief default specialization + @sa https://json.nlohmann.me/api/json/ + */ + using json = basic_json<>; + + /// @brief a minimal map-like container that preserves insertion order + /// @sa https://json.nlohmann.me/api/ordered_map/ + template + struct ordered_map; + + /// @brief specialization that maintains the insertion order of object keys + /// @sa https://json.nlohmann.me/api/ordered_json/ + using ordered_json = basic_json; + + NLOHMANN_JSON_NAMESPACE_END + +#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ + + +NLOHMANN_JSON_NAMESPACE_BEGIN +/*! +@brief detail namespace with internal helper functions + +This namespace collects functions that should not be exposed, +implementations of some @ref basic_json methods, and meta-programming helpers. + +@since version 2.1.0 +*/ +namespace detail +{ + +///////////// +// helpers // +///////////// + +// Note to maintainers: +// +// Every trait in this file expects a non CV-qualified type. +// The only exceptions are in the 'aliases for detected' section +// (i.e. those of the form: decltype(T::member_function(std::declval()))) +// +// In this case, T has to be properly CV-qualified to constraint the function arguments +// (e.g. to_json(BasicJsonType&, const T&)) + +template struct is_basic_json : std::false_type {}; + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +struct is_basic_json : std::true_type {}; + +// used by exceptions create() member functions +// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t +// false_type otherwise +template +struct is_basic_json_context : + std::integral_constant < bool, + is_basic_json::type>::type>::value + || std::is_same::value > +{}; + +////////////////////// +// json_ref helpers // +////////////////////// + +template +class json_ref; + +template +struct is_json_ref : std::false_type {}; + +template +struct is_json_ref> : std::true_type {}; + +////////////////////////// +// aliases for detected // +////////////////////////// + +template +using mapped_type_t = typename T::mapped_type; + +template +using key_type_t = typename T::key_type; + +template +using value_type_t = typename T::value_type; + +template +using difference_type_t = typename T::difference_type; + +template +using pointer_t = typename T::pointer; + +template +using reference_t = typename T::reference; + +template +using iterator_category_t = typename T::iterator_category; + +template +using to_json_function = decltype(T::to_json(std::declval()...)); + +template +using from_json_function = decltype(T::from_json(std::declval()...)); + +template +using get_template_function = decltype(std::declval().template get()); + +// trait checking if JSONSerializer::from_json(json const&, udt&) exists +template +struct has_from_json : std::false_type {}; + +// trait checking if j.get is valid +// use this trait instead of std::is_constructible or std::is_convertible, +// both rely on, or make use of implicit conversions, and thus fail when T +// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) +template +struct is_getable +{ + static constexpr bool value = is_detected::value; +}; + +template +struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if JSONSerializer::from_json(json const&) exists +// this overload is used for non-default-constructible user-defined-types +template +struct has_non_default_from_json : std::false_type {}; + +template +struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if BasicJsonType::json_serializer::to_json exists +// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. +template +struct has_to_json : std::false_type {}; + +template +struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +template +using detect_key_compare = typename T::key_compare; + +template +struct has_key_compare : std::integral_constant::value> {}; + +// obtains the actual object key comparator +template +struct actual_object_comparator +{ + using object_t = typename BasicJsonType::object_t; + using object_comparator_t = typename BasicJsonType::default_object_comparator_t; + using type = typename std::conditional < has_key_compare::value, + typename object_t::key_compare, object_comparator_t>::type; +}; + +template +using actual_object_comparator_t = typename actual_object_comparator::type; + +///////////////// +// char_traits // +///////////////// + +// Primary template of char_traits calls std char_traits +template +struct char_traits : std::char_traits +{}; + +// Explicitly define char traits for unsigned char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = unsigned char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(EOF); + } +}; + +// Explicitly define char traits for signed char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = signed char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(EOF); + } +}; + +/////////////////// +// is_ functions // +/////////////////// + +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B { }; +template +struct conjunction +: std::conditional(B::value), conjunction, B>::type {}; + +// https://en.cppreference.com/w/cpp/types/negation +template struct negation : std::integral_constant < bool, !B::value > { }; + +// Reimplementation of is_constructible and is_default_constructible, due to them being broken for +// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). +// This causes compile errors in e.g. clang 3.5 or gcc 4.9. +template +struct is_default_constructible : std::is_default_constructible {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_constructible : std::is_constructible {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_iterator_traits : std::false_type {}; + +template +struct is_iterator_traits> +{ + private: + using traits = iterator_traits; + + public: + static constexpr auto value = + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value; +}; + +template +struct is_range +{ + private: + using t_ref = typename std::add_lvalue_reference::type; + + using iterator = detected_t; + using sentinel = detected_t; + + // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator + // and https://en.cppreference.com/w/cpp/iterator/sentinel_for + // but reimplementing these would be too much work, as a lot of other concepts are used underneath + static constexpr auto is_iterator_begin = + is_iterator_traits>::value; + + public: + static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; +}; + +template +using iterator_t = enable_if_t::value, result_of_begin())>>; + +template +using range_value_t = value_type_t>>; + +// The following implementation of is_complete_type is taken from +// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ +// and is written by Xiang Fan who agreed to using it in this library. + +template +struct is_complete_type : std::false_type {}; + +template +struct is_complete_type : std::true_type {}; + +template +struct is_compatible_object_type_impl : std::false_type {}; + +template +struct is_compatible_object_type_impl < + BasicJsonType, CompatibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + using object_t = typename BasicJsonType::object_t; + + // macOS's is_constructible does not play well with nonesuch... + static constexpr bool value = + is_constructible::value && + is_constructible::value; +}; + +template +struct is_compatible_object_type + : is_compatible_object_type_impl {}; + +template +struct is_constructible_object_type_impl : std::false_type {}; + +template +struct is_constructible_object_type_impl < + BasicJsonType, ConstructibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + using object_t = typename BasicJsonType::object_t; + + static constexpr bool value = + (is_default_constructible::value && + (std::is_move_assignable::value || + std::is_copy_assignable::value) && + (is_constructible::value && + std::is_same < + typename object_t::mapped_type, + typename ConstructibleObjectType::mapped_type >::value)) || + (has_from_json::value || + has_non_default_from_json < + BasicJsonType, + typename ConstructibleObjectType::mapped_type >::value); +}; + +template +struct is_constructible_object_type + : is_constructible_object_type_impl {}; + +template +struct is_compatible_string_type +{ + static constexpr auto value = + is_constructible::value; +}; + +template +struct is_constructible_string_type +{ + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + + static constexpr auto value = + conjunction < + is_constructible, + is_detected_exact>::value; +}; + +template +struct is_compatible_array_type_impl : std::false_type {}; + +template +struct is_compatible_array_type_impl < + BasicJsonType, CompatibleArrayType, + enable_if_t < + is_detected::value&& + is_iterator_traits>>::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value >> +{ + static constexpr bool value = + is_constructible>::value; +}; + +template +struct is_compatible_array_type + : is_compatible_array_type_impl {}; + +template +struct is_constructible_array_type_impl : std::false_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t::value >> + : std::true_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t < !std::is_same::value&& + !is_compatible_string_type::value&& + is_default_constructible::value&& +(std::is_move_assignable::value || + std::is_copy_assignable::value)&& +is_detected::value&& +is_iterator_traits>>::value&& +is_detected::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 +!std::is_same>::value&& + is_complete_type < + detected_t>::value >> +{ + using value_type = range_value_t; + + static constexpr bool value = + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; +}; + +template +struct is_constructible_array_type + : is_constructible_array_type_impl {}; + +template +struct is_compatible_integer_type_impl : std::false_type {}; + +template +struct is_compatible_integer_type_impl < + RealIntegerType, CompatibleNumberIntegerType, + enable_if_t < std::is_integral::value&& + std::is_integral::value&& + !std::is_same::value >> +{ + // is there an assert somewhere on overflows? + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits; + + static constexpr auto value = + is_constructible::value && + CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; +}; + +template +struct is_compatible_integer_type + : is_compatible_integer_type_impl {}; + +template +struct is_compatible_type_impl: std::false_type {}; + +template +struct is_compatible_type_impl < + BasicJsonType, CompatibleType, + enable_if_t::value >> +{ + static constexpr bool value = + has_to_json::value; +}; + +template +struct is_compatible_type + : is_compatible_type_impl {}; + +template +struct is_constructible_tuple : std::false_type {}; + +template +struct is_constructible_tuple> : conjunction...> {}; + +template +struct is_json_iterator_of : std::false_type {}; + +template +struct is_json_iterator_of : std::true_type {}; + +template +struct is_json_iterator_of : std::true_type +{}; + +// checks if a given type T is a template specialization of Primary +template