change the config::debug() function to return a string,

seems easier to use that way to me..
This commit is contained in:
Gunter Labes 2007-10-29 14:57:10 +00:00
parent 94e0c29dcc
commit 4d5862ffd9
5 changed files with 8 additions and 6 deletions

View file

@ -687,8 +687,9 @@ void config::reset_translation() const
}
}
void config::debug(std::ostream& outstream) const
std::string config::debug() const
{
std::ostringstream outstream;
static int i = 0;
i++;
for(string_map::const_iterator val = values.begin(); val != values.end(); ++val) {
@ -699,11 +700,12 @@ void config::debug(std::ostream& outstream) const
for(all_children_iterator list = ordered_begin(); list != ordered_end(); ++list) {
{ for (int j = 0; j < i-1; j++){ outstream << char(9); } }
outstream << "[" << *(*list).first << "]\n";
(*list).second->debug(outstream);
outstream << (*list).second->debug();
{ for (int j = 0; j < i-1; j++){ outstream << char(9); } }
outstream << "[/" << *(*list).first << "]\n";
}
i--;
return outstream.str();
}
std::string config::hash() const

View file

@ -90,7 +90,7 @@ public:
void clear();
bool empty() const;
void debug(std::ostream& outstream=std::cerr) const;
std::string debug() const;
std::string hash() const;
struct error {

View file

@ -2164,7 +2164,7 @@ static void commit_wmi_commands() {
mref->command.add_child("allow_undo");
}
LOG_NG << "setting command for " << mref->name << "\n";
wcc.second->debug(lg::info(lg::engine));
LOG_NG << wcc.second->debug();
delete wcc.second;
wmi_command_changes.pop_back();
}

View file

@ -1131,7 +1131,7 @@ game_state::~game_state() {
void game_state::set_variables(const config& vars) {
if(!variables.empty()) {
WRN_NG << "clobbering the game_state variables\n";
variables.debug(WRN_NG);
WRN_NG << variables.debug();
}
variables = vars;
}

View file

@ -140,7 +140,7 @@ void level_to_gamestate(config& level, game_state& state, bool saved_game)
LOG_NG << "No variables were found for the game_state." << std::endl;
} else {
LOG_NG << "Variables found and loaded into game_state:" << std::endl;
state.get_variables().debug(LOG_NG);
LOG_NG << state.get_variables().debug();
}
}